Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Run Your Shellcode with mman on Linux
// ( segmentation fault – core dumped problem solver )
#include <stdio.h>
#include <sys/mman.h>
#include <string.h>
#include <stdlib.h>
int (*shellcode)();
char code[] = "\xeb\x19\x31\xc0\x31\xdb\x31\xd2\x31\xc9\xb0\x04\xb3\x01\x59\xb2\x05\xcd"\
int main(int argc, char **argv) {
void *p = mmap(0, sizeof(code), PROT_EXEC | PROT_WRITE | PROT_READ, MAP_ANON | MAP_PRIVATE, -1, 0);
if (p == MAP_FAILED) { perror("mmap"); exit(-1); }
memcpy(p, code, sizeof(code));
shellcode = p;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment