Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/prctl.h>
- #include <linux/seccomp.h>
- #include <seccomp.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/syscall.h>
- int main() {
- int fd;
- char buffer[200];
- printf("[+] Staring process\n");
- scmp_filter_ctx scmp = seccomp_init(SCMP_ACT_KILL);
- seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(read), 0);
- seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(write), 0);
- seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(exit), 0);
- //seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(open), 0);
- //seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(open), 1, SCMP_A1(SCMP_CMP_EQ, O_RDONLY));
- printf("[+] Launching seccomp mode\n");
- seccomp_load(scmp);
- //fd = open("/etc/passwd", O_RDWR, 0666);
- fd = open("/etc/passwd", O_RDONLY, 0666);
- read(fd, buffer, sizeof(buffer));
- write(STDOUT_FILENO, buffer, sizeof(buffer));
- printf("\n\n");
- printf("\n[+} Ending process\n");
- syscall(SYS_exit, EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement