Last active
July 10, 2018 18:32
-
-
Save kkirsche/ceb6f613f0cc8d53370752a7ebac3841 to your computer and use it in GitHub Desktop.
Shellcode C Harness
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 | |
if [ $# -ne 1 ]; then | |
echo "{$0} <program to dump as shellcode>" | |
exit 1 | |
fi | |
# https://www.commandlinefu.com/commands/view/6051/get-all-shellcode-on-binary-file-from-objdump | |
objdump -d ./${1}|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' |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
unsigned char code[] = \ | |
"SHELLCODE: "; | |
int main() { | |
printf("Shellcode Length: %d\n", strlen(code)); | |
int (*ret)() = (int(*)())code; | |
ret() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment