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

telescope: display retaddrs #794

Closed

Conversation

disconnect3d
Copy link
Member

Extends telescope command so it displays not only register names, but
also return addresses names (ret0, ret1, ret2, ...).

The names are also set as GDB variables so they can be referenced via
$retX similarly as registers are by default.

Additionally, I moved the retaddr command from
pwndbg/commands/stack.py to pwndbg/commands/retaddr.py.

Extends `telescope` command so it displays not only register names, but
also return addresses names (ret0, ret1, ret2, ...).

The names are also set as GDB variables so they can be referenced via
`$retX` similarly as registers are by default.

Additionally, I moved the `retaddr` command from
pwndbg/commands/stack.py to pwndbg/commands/retaddr.py.
@disconnect3d
Copy link
Member Author

Example display:
image

@disconnect3d
Copy link
Member Author

One thing I am concerned about: I guess it will crash the command if stack frame is totally broken. We should probably handle this gracefully.

Also: setting GDB variables is not ideal: they are not refreshed e.g. on break and only on telescope, so a variable may hold old values or, e.g., a $retX may be set when there is no more X return address...

import pwndbg.arch
import pwndbg.chain
import pwndbg.commands
import pwndbg.regs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those imports need to be fixed

name = 'ret%d' % idx
names_values[retaddr].append(name)
# Set $retX variable so it can be used by the user
gdb.execute("set $%s=0x%x" % (name, retaddr))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the GDB variable setting, should probably be removed from the PR.

@zachriggle
Copy link
Contributor

We already have ROP handling through Unicorn emulation, we may be able to rely on that in order to get higher-quality information so we don't have to worry about crashing the stack command.

@disconnect3d
Copy link
Member Author

I am closing this for now, I will add an issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants