Created
March 30, 2021 08:17
-
-
Save h4sh5/1462c149416663f4e5e990f3bdf2d2ee to your computer and use it in GitHub Desktop.
objdump dump shellcode from a function of a binary file. Better used with gcc -static -fPIC to compile your C src
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
| #!/bin/bash | |
| # linux only! if on osx, use gpaste and gsed instead of paste and sed | |
| if (( $# != 2 )); then | |
| echo "Usage: $0 <file> <function>" | |
| exit 1 | |
| fi | |
| #set -x | |
| FILE=$1 | |
| FUNC=$2 | |
| echo "disasm:" >2 | |
| objdump -d $FILE | awk -v RS= '/^[[:xdigit:]]+ <'$FUNC'>/' 1>&2 | |
| objdump -d $FILE | awk -v RS= '/^[[:xdigit:]]+ <'$FUNC'>/' | grep '[0-9a-f]:'|grep -v 'file'|cut -f2 -d:|cut -f1-6 -d' '|tr -s ' '|tr '\t' ' '|sed 's/ $//g'|sed 's/ /\\x/g'|paste -d '' -s |sed 's/^/"/'|sed 's/$/"/g' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment