-
Notifications
You must be signed in to change notification settings - Fork 206
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
Detect invalid gadgets #140
base: master
Are you sure you want to change the base?
Conversation
it culled valid but weird gadgets (e.g. bx pc) which is allowed but deprecated
…d truncates the gadget
Hi, why is that gadget a problem? I do not think, that this gadget is invalid. You can use that gadget, with the first instruction. Nevertheless, both parts of that gadgets are included in the gadget collection, since the first part is a gadget which will be found and the second part as well. |
I think its more useful to split this detected gadget into two separate gadgets which is what this PR is trying to do. The only practical time that series of instructions is executed is when a payload is setup to execute the |
Both parts of that gadget are part of the gadget collection, so it is not necessary to split this gadget. |
Few years ago I removed all those gadgets, however, I decided to change that again, since I needed one of those removed gadgets. Unfortunately, I cannot remember which gadget it was, otherwise I could show you an example |
Some gadgets that Ropper would generate would have an ARM 'pop {..., pc}' instruction or an x86 'ret' instruction in the middle because the instruction happen to land in the previous 'n' instructions of the gadget.
This pull requests detects these and removes all previous instructions from the currently built gadget because it is impossible to execute the full gadget without invoking it as two separate gadgets.
e.g.
becomes
There are definitely still ways this could be improved. Mainly determining if any JOP style gadgets should also trigger a reset of the gadget. My first thoughts for arm/x86 are that bl/call should not be included because it is possible to return to the gadget after a call, whereas unconditional bx/jmp should because it's impossible for execution to return on it's own