Created
February 16, 2021 21:48
-
-
Save adililhan/090480a6244fdf9afbb2f6ec4b7fdc79 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 <linux/seccomp.h> | |
#include <seccomp.h> | |
#include <sys/prctl.h> | |
void main() { | |
FILE *filePoint; | |
filePoint = fopen("/tmp/test.txt", "a"); | |
if(filePoint == NULL) { | |
puts("File can not be opened"); | |
exit(1); | |
} | |
fputs("qwe\n", filePoint); | |
fclose(filePoint); | |
filePoint = fopen("/tmp/test.txt", "a"); | |
if(filePoint == NULL) { | |
puts("File can not be opened"); | |
exit(1); | |
} | |
scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_KILL); | |
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(fstat), 0); | |
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); | |
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0); | |
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); | |
seccomp_load(ctx); | |
fputs("xyz", filePoint); | |
fclose(filePoint); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment