Last active
January 25, 2023 17:23
-
-
Save offlinemark/5be8375ba28d5b7dd2d0 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated the code to run on python 3.x
https://www.online-python.com/5DldoxN9hn