Created
June 21, 2019 20:30
-
-
Save lattera/c3e41bca2527426c31a9d9174990c620 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 <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/mman.h> | |
int | |
main(int argc, char *argv[]) | |
{ | |
void *addr; | |
addr = mmap(NULL, getpagesize(), | |
PROT_MAX(PROT_READ|PROT_WRITE|PROT_EXEC) | PROT_READ | | |
PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); | |
printf("addr: 0x%016lx\n", (unsigned long)addr); | |
if (mprotect(addr, getpagesize(), PROT_READ|PROT_EXEC)) | |
perror("mprotect"); | |
while (printf("%d\n", getpid())) | |
sleep(5); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment