Created
October 4, 2011 23:45
-
-
Save aczid/1263176 to your computer and use it in GitHub Desktop.
bash aliases for shellcoding
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
# Some bash aliases for working with shellcode. i386-specific, no configuration etc. | |
# Probably of no use to professionals :) | |
# Thanks for the help, friends! | |
# outputs C array of shellcode from .s file, using s-proc (http://www.safemode.org/files/zillion/shellcode/tools/s-proc.c) | |
function tocshellcode() { gcc -m32 "$@" -o tmp.elf -nostartfiles -nostdlib ; objcopy -O binary -j .text tmp.elf tmp.bin ; s-proc -p tmp.bin ; rm tmp.bin; rm tmp.elf; } | |
# Morphs the tocshellcode into a single string | |
function toshellcode() { echo `tocshellcode "$@" | tail -n+4 | tr -d '\n' | tr -d '\t' | tr -d '"' | tr -d ';'`; } | |
# Test .s in gdb | |
function testshellcode() { echo `tocshellcode "$@"` > testshellcode.c ; echo "int main(int argc, char* argv[]){int (*f)(); f = (int (*)()) shellcode; (int)(*f)();}" >> testshellcode.c ; gcc -m32 -z execstack -o testshellcode testshellcode.c; gdb ./testshellcode; } | |
# Disassemble shellcode string | |
function toasm() { perl -e 'print "'$@'" ' > tmp.bin ; objdump -D -b binary -mi386 tmp.bin; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment