Skip to content

Instantly share code, notes, and snippets.

@CerebralMischief
Forked from moyix/noptest.c
Created May 16, 2018 01:47
Show Gist options
  • Save CerebralMischief/55e47de2333a6ab782122490ef01d748 to your computer and use it in GitHub Desktop.
Save CerebralMischief/55e47de2333a6ab782122490ef01d748 to your computer and use it in GitHub Desktop.
#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