-
-
Save CerebralMischief/55e47de2333a6ab782122490ef01d748 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
#include <stdio.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
int main(int argc, char **argv) { | |
unsigned char bytes[] = { | |
0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0x90, // rep*14 nop | |
0xc3 // ret | |
}; | |
unsigned char *code = (unsigned char *) mmap(NULL, 0x1000, PROT_READ|PROT_WRITE|PROT_EXEC, | |
MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); | |
printf("Code mapped at %p\n", code); | |
memcpy(code, bytes, 16); | |
((void (*)(void))code)(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment