-
Notifications
You must be signed in to change notification settings - Fork 33
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
My Ubuntu 18 confused about 32" binaries #2
Comments
Does pwntools not work correctly on Ubuntu 18 without this change? What is the error you get without changing this? From looking at the source code of pwntools, it appears that setting the arch as 'i386' should imply bits=32. If this actually makes a difference, then we may need to make more changes than just the one shown here, depending on pwntool's behavior. |
with bits=32
|
Thank you, it looks like this may actually be a more common error than I realized. What is your version of pwntools? The bug may depend on the pwntools version, and this change looks like it should handle versions that might otherwise have problems. I notice you're still getting some errors with rewriting a binary, even after fixing the pwntools issue. I would like to try to explain this problem, because our solution looks kind of messy, but we came to this solution after a lot of experimentation. Certain binaries make it difficult-to-impossible to construct a rewritten binary that will be accepted by the loader without moving the text section. This is avoidable---modifying the loader can address this. Since this problem has nothing to do with rewriting or instrumenting instructions, we didn't spend the engineering efforts getting this working for all edge-case binaries. For example, the binary you are using appears to be a very small example that's directly assembled, and it probably gives us very little flexibility to insert our new segments. Therefore, the ELFManip library is encountering an unusual case it doesn't expect. From the error message, I'm guessing your test binary may not have any sort of .data section. I tried to make this work for most typical binaries, and I implemented an approach that should work for almost any moderately-sized 64-bit binary (it is not implemented for 32-bit binaries), but binaries with very small text sections may encounter an error if there's no room to insert new segment header entries. |
pwntools is just a git clone from the 14th of may. I wanted to be sure I looked at the correct code when debugging. If I produce file with gcc it works (but generated binary segfaulted but that's another issue). The test file above was a trivial hand compiled bare minimum asm file.
|
Would you please consider this?
The text was updated successfully, but these errors were encountered: