Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdisas sets the disassembly-flavor to intel #100

Open
danielhenrymantilla opened this issue Apr 9, 2017 · 2 comments
Open

pdisas sets the disassembly-flavor to intel #100

danielhenrymantilla opened this issue Apr 9, 2017 · 2 comments

Comments

@danielhenrymantilla
Copy link

danielhenrymantilla commented Apr 9, 2017

File 'peda.py', lines 759 and 777:

def disassemble(self, *arg):
        [...]
        self.execute("set disassembly-flavor intel") 

I, as many other users, prefer the GAS syntax. Other users may prefer the Intel syntax, and that's why there is a set disassembly-flavor XXX setting.
I can't see a reason as to why pdisas, a supposedly improved disas, should blatantly ignore such a setting and impose either flavor.

@longld
Copy link
Owner

longld commented May 22, 2017

peda sets disassembly-flavor to intel by default for instruction parsing and will not support GAS syntax.

@danielhenrymantilla
Copy link
Author

danielhenrymantilla commented May 28, 2017

@longld Actually you happen to support both syntaxes. For intance,
both-syntaxes-are-well-parsed
That shouldn't come as a surprise, since when looking at your code, you look for "cmp","test", "call", "j" and "ret" to be substrings of the opcodes mnemonics:
image

# lib/utils.py, in function format_disasm_code
# line 526
addr, opcode = to_int(m.group(1)), m.group(2)
            for c in colorcodes:
                if c in opcode:
                    color = colorcodes[c]
                    if c == "call":
                        for f in VULN_FUNCTIONS:
                            if f in line.split(":\t", 1)[-1]:
                                style = "bold, underline"
                                color = "red"
                                break
                    break

It so happens that both AT&T's (GAS) syntax and Intel's use the same opcodes mnemonics, at least at their core. Your "is a substring of" test means you maintain compatiblity regarding both syntaxes, which won't evolve in the future by the way.

Ergo, you do support both syntaxes with your parsing, and should therefore not favour one syntax over another.

The suggested fix, as said in my initial post, is to delete the line 777 from peda.py:

self.execute("set disassembly-flavor intel") # get rid of this line

I have commented out this line in my code and haven't encountered any problem whatsoever.

@longld longld mentioned this issue Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants