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

pop ds; ret gadgets are not properly handled. #98

Closed
astewart-bah opened this issue Apr 15, 2024 · 3 comments
Closed

pop ds; ret gadgets are not properly handled. #98

astewart-bah opened this issue Apr 15, 2024 · 3 comments
Labels

Comments

@astewart-bah
Copy link
Contributor

Description

angrop assumes that "pop ds; ret;" gadgets are acceptable for shifting 8 bytes on the stack. This is a bad assumption, and causes failed chains.

The below is the output of the included example scripts.

Since a "pop ds; ret;" gadget appeared early in the binary, it appears to be the default gadget for shifting 8 bytes on the stack.
This is the result of rop.shift(8):
code_base = 0x0
chain = b""
chain += p32(code_base + 0x11fd)	# pop ds; ret 
chain += p32(0x0)




Now when we try to build a chain for a function call that only takes 1 argument, the stack needs to shift 8 bytes to clean up the argument off of the stack.
This chain calls close(0) followed by exit(0):
code_base = 0x0
chain = b""
chain += p32(code_base + 0x1060)	# close@plt
chain += p32(code_base + 0x11fd)	# pop ds; ret 
chain += p32(0x0)
chain += p32(code_base + 0x1050)	# exit@plt
chain += p32(code_base + 0x11fd)	# pop ds; ret 
chain += p32(0x0)


The chain will fail. There is a cheat to see this failure by uncommenting the call to show_failure_scenario() in test.c.

Steps to reproduce the bug

angrop_issue_pop_ds.zip

Attached is a zip file. Unzip and run ./start.sh.

This will build the included binary, init a python venv, install angr and angrop, and run the example python scrip. This will print out the above description.

Environment

Tested on ubuntu 22.04 with pyhton 3.10.

Additional context

No response

@Kyle-Kyle
Copy link
Collaborator

I encountered this as well and thought I already fixed it. But apparently I haven't. Looking into it.

@Kyle-Kyle
Copy link
Collaborator

the patch can be found at #99

@Kyle-Kyle
Copy link
Collaborator

should be fixed by the patch

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

No branches or pull requests

2 participants