-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve format string generator #1216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool stuff! It's missing some function-level documentation and doctests, and there are some general design questions (nested functions vs. an object with methods).
If we can get this cleaned up, it would be cool to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A huge +1, this module was pretty useless on 64-bit stuff so far. But there are some minor issues concerning python 3 compatibility or coding style.
This means that the format string can now also work in certain cases even if the pointers contain null bytes. That's especially important on 64 bit where most pointers contain null bytes.
I've done most of the cleanup now (there's still one nested function and some docs remaining). Remaining todo before this is merge ready:
Optional:
|
Would it be ok to commit compiled, static binaries for tests to the repo? The binary for mips for example is about 600kb. Requiring a cross-compiler for tests is painful. |
@bennofs Yes, I believe this was part of my format string branch. I would greatly prefer a flexible binary that allows lots of tests. You can see what I had in mind here: https://github.com/zachriggle/pwntools/tree/format-string/pwnlib/data/formatstring If you're interested, you can also see how I planned to perform "automatic" format string exploration and exploitation here: https://github.com/zachriggle/pwntools/blob/format-string/pwnlib/formatstring.py And look at the documentation here: https://github.com/zachriggle/pwntools/blob/format-string/docs/source/fmtstr.rst Specifically, I wanted to leverage a prefix stub ("get me to the format string") and then use the |
Ah, there is also an The intent here is to capture the register state and stack at the time The obvious limitation is that this will trap on the first |
I now verified that the code works correctly in a basic test for: MIPS, MIPS64, MIPSEL, MIPS64EL, X86, X86_64, PPC, PPC64, ARM, AARCH64. There is a Makefile that uses the cross compilers available on Ubuntu bionic (that's the version I used for tests) to build example vulnerable binaries for each arch. |
Should be ready for merge now from my side. |
It looks like we must resolve some build problems before merging this, but looks ready to me |
Yes, I need to do a |
For the sake of being able to run the tests provided, would you mind adding the |
I added the binaries. Wasn't sure on whether to add them since they increase the size of the git repo. The command to build them, run in |
They do inflate the size of the repo slightly, but having binaries that don't change due to toolchain / CI / etc. differences is preferable. |
This PR improves the format string generator:
fmt_str_split
)AtomWrite
primitive)