-
-
Save retornam/bf32b1fe7edc6c6df2b87aa9ead62b79 to your computer and use it in GitHub Desktop.
Shellcode helper. Given a string, generate push instructions to push string onto stack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Tool for writing shellcode. Give it a string to push onto the stack and it | |
generates the corresponding push instructions. | |
''' | |
import sys | |
def print_word(word): | |
print 'push', '0x' + word[::-1].encode('hex') | |
if len(sys.argv) != 2: | |
print 'usage: <program> text' | |
sys.exit() | |
if len(sys.argv[1]) % 4 != 0: | |
print 'text must be multiple of 4. pad your slashes or something.' | |
sys.exit() | |
chunks = map(lambda x: sys.argv[1][x:x+4], range(0, len(sys.argv[1]), 4))[::-1] | |
map(print_word, chunks) |
Author
retornam
commented
Jan 15, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment