-
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
I386 ascii shellcode #1667
I386 ascii shellcode #1667
Conversation
It looks like your change to changelog.md modifies a lot of lines it shouldn't. Can you fix this? (git checkout origin/master -- CHANGELOG.md then add your change again) |
Sorry, my bad. I guess my IDE's auto-formatting kicked in and I've just not noticed. Hopefully it's good now. |
I did not realize you still support Python 2, so now that's fixed. |
pwnlib/ascii_shellcode.py
Outdated
|
||
Examples: | ||
|
||
>>> sc = hex2bytes('83c41831c031dbb006cd8053682f747479682f64657689e331c966b91227b005cd806a175831dbcd806a2e5853cd8031c050682f2f7368682f62696e89e3505389e199b00bcd80') |
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.
I would prefer we also have an ELF.from_bytes().process()
test that actually runs some shellcode to ensure that it works. e.g.
>>> sc = shellcraft.echo("Hello world") + shellcraft.exit()
>>> ascii = ascii_shellcode(asm(sc))
>>> ELF.from_bytes(ascii).process().recvall()
b"Hello world"
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.
Added doctest.
Since the shellcode is executing from the code segment and is being unpacked onto the stack, I had to add a jmp esp
to the end of the unpacker.
(Usually, the unpacker also runs on the stack, and when eip
bumps into esp
the unpacked shellcode starts executing).
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.
FYI we also have a run_shellcode
shortcut somewhere (with a similar debug_shellcode
to aid development) that accepts bytes and returns a running process tube, just as above.
This code must be moved under |
@Arusekk moved under |
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.
Ooofff. That's some great stuff! But I would like it better if it changed a bit. Here you have my MASSIVE review you will find helpful.
Thanks for taking the time to review my code! I'll fix all the cosmetic / pack / bytearray stuff soon. As for python 2 <-> 3 compatible code, It'll probably take me a little longer since I'm less familiar with writing backwords compatible code. |
Don't worry, it is here all about using bytearray and avoiding ord / chr and consrtucts that are obsolete or too fresh
|
Co-authored-by: Arusekk <arek_koz@o2.pl>
Forgot to update a few doctests to use bytearrays instead of bytes
Test correctness of avoid parameter processing
* add parameter max_subs to __init__ (cherry picked from commit d331be5) * Beautify doc string (cherry picked from commit ceebf47) * Fix some typos (cherry picked from commit 6bbbdce) * Update CHANGELOG.md * Revert changelog #1693 (comment) * Trigger CI
I've written a module based on the Riley "Caezar" Eller's technique to bypass data filters, for buffer overflow exploits, on Intel x86 platforms.
http://julianor.tripod.com/bc/bypass-msb.txt
The algorithm to calculate the subtractions for warping around eax is based on https://github.com/VincentDary/PolyAsciiShellGen