Last active
June 18, 2021 11:42
-
-
Save fervagar/45341ee012533721b0e8 to your computer and use it in GitHub Desktop.
Bash script that prints out the shellcode of a binary in C string format (using objdump)
This file contains 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
#!/bin/bash | |
## Prints the shellcode in little endian | |
RAW=$(objdump -d "$1" | grep "^ "|awk -F"[\t]" '{print $2}') | |
SHELLCODE="" | |
COUNT=0 | |
for word in $RAW | |
do | |
SHELLCODE=${SHELLCODE}${word:6:2}${word:4:2}${word:2:2}${word:0:2} | |
((COUNT++)) | |
done | |
echo $SHELLCODE | sed 's/ //g'| sed 's/.\{2\}/\\x&/g'|paste -d '' -s | |
echo "Shellcode size: ${COUNT} bytes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment