Created
August 31, 2020 02:40
-
-
Save AXDOOMER/41ace7c726a67afcdfd12af723cd13d7 to your computer and use it in GitHub Desktop.
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
// Shellcode executor | |
// Expects hex as a command line parameter | |
// | |
// Compile with: gcc -fno-stack-protector -z execstack main.c | |
#include <string.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]) | |
{ | |
if (argc == 2) | |
{ | |
char code[32000] = { 0 }; // may overflow | |
int codeindex = 0; | |
char temp[3] = { 0 }; | |
int length = strlen(argv[1]); | |
for (int i = 0; i < length; i += 2) | |
{ | |
strncpy(temp, argv[1] + i, 2); | |
code[codeindex] = strtol(temp, NULL, 16); | |
codeindex++; | |
} | |
int (*foo)() = (int(*)())code; | |
foo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment