Created
November 18, 2016 19:47
-
-
Save mstemm/3e29df625052616fffcd667ff59bf32a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <fcntl.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <linux/seccomp.h> | |
#include <sys/prctl.h> | |
int main(int argc, char **argv) | |
{ | |
int output = open("output.txt", O_WRONLY); | |
const char *val = "test"; | |
printf("Calling prctl() to set seccomp strict mode...\n"); | |
prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT); | |
printf("Writing to an already open file...\n"); | |
write(output, val, strlen(val)+1); | |
printf("Trying to open file for reading...\n"); | |
int input = open("output.txt", O_RDONLY); | |
printf("You will not see this message--the process will be killed first\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment