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

Fix bug that makes peda not show register, code, stack information #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

minhbq-99
Copy link

peda uses gdb command x/i to get assembly code. In small sized termial,
gdb may return something like this

0x4003f0:\t\njmp    QWORD PTR [rip+0x200c22]        # 0x601018\n

In context_code function, the above result will become 2 lines, if the
first line reach the else case in this if:

if idx <= pc_idx:
	text += line + "\n"
else:
	text += " | %s\n" % line.strip()

and it will become

0x4003f0: (without the tab)

When this line is processed by format_disasm_code function

prefix = line.split(":\t")[0]
addr = re.search("(0x[^\s]*)", prefix)
if addr:
	addr = to_int(addr.group(1))

to_int is called with "0x4003f0:" argument and it will return None which
will raise an exception in later comparison.

context_code function has msg.bufferize decorator so the exception prevents
msg.flush to be called, the msg.buffering will not be decreased. As a result,
no information can be displayed later since we get the output only when
msg.buffering equals to 0.

peda uses gdb command x/i to get assembly code. In small sized termial,
gdb may return something like this

	0x4003f0:\t\njmp    QWORD PTR [rip+0x200c22]        # 0x601018\n

In context_code function, the above result will become 2 lines, if the
first line reach the else case in this if:

	if idx <= pc_idx:
		text += line + "\n"
	else:
		text += " | %s\n" % line.strip()

and it will become

	0x4003f0: (without the tab)

When this line is processed by format_disasm_code function

	prefix = line.split(":\t")[0]
	addr = re.search("(0x[^\s]*)", prefix)
	if addr:
		addr = to_int(addr.group(1))

to_int is called with "0x4003f0:" argument and it will return None which
will raise an exception in later comparison.

context_code function has msg.bufferize decorator so the exception prevents
msg.flush to be called, the msg.buffering will not be decreased. As a result,
no information can be displayed later since we get the output only when
msg.buffering equals to 0.
@minhbq-99 minhbq-99 changed the title Fix bug that makes peda now showing register, code, stack information Fix bug that makes peda not showing register, code, stack information Jan 18, 2021
@minhbq-99 minhbq-99 changed the title Fix bug that makes peda not showing register, code, stack information Fix bug that makes peda not show register, code, stack information Jan 18, 2021
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

Successfully merging this pull request may close these issues.

1 participant