rosehgal / BinExp

Linux Binary Exploitation
MIT License
1.28k stars 211 forks source link

Extract the hexadecimal shellcode #6

Open JohnRyk opened 4 years ago

JohnRyk commented 4 years ago

For some reason this code do not work for me :

for i in `objdump -d shellcode.o | tr '\t' ' ' | tr ' ' '\n' | egrep '^[0-9a-f]{2}$' ` ; do echo -n "\x$i" ; done

And I found that you can use the following code to extract hexadecimal shellcode from the objdump disassemble output :

for i in `objdump -d shellcode.o | tr '\t' ' ' | tr ' ' '\n' | egrep '^[0-9a-f]{2}$' ` ; do printf \\%c%b x $i ; done
chettriyuvraj commented 5 months ago

For anyone reading this. Do not expect portability from shell scripts. Unix has x number of lineages and descendants, each with slightly different implementations -> always try out shell scripts before using them :)