SHARE
TWEET

Untitled

a guest Apr 18th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <sys/prctl.h>
  3. #include <linux/seccomp.h>
  4. #include <seccomp.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <fcntl.h>
  8. #include <sys/syscall.h>
  9.  
  10. int main() {
  11.   int fd;
  12.   char buffer[200];
  13.  
  14.   printf("[+] Staring process\n");
  15.  
  16.   scmp_filter_ctx scmp = seccomp_init(SCMP_ACT_KILL);
  17.  
  18.   seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(read), 0);
  19.   seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(write), 0);
  20.   seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(exit), 0);
  21.  
  22.   //seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(open), 0);
  23.   //seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(open), 1, SCMP_A1(SCMP_CMP_EQ, O_RDONLY));
  24.  
  25.   printf("[+] Launching seccomp mode\n");
  26.   seccomp_load(scmp);
  27.  
  28.   //fd = open("/etc/passwd", O_RDWR, 0666);
  29.   fd = open("/etc/passwd", O_RDONLY, 0666);
  30.  
  31.   read(fd, buffer, sizeof(buffer));
  32.   write(STDOUT_FILENO, buffer, sizeof(buffer));
  33.   printf("\n\n");
  34.  
  35.   printf("\n[+} Ending process\n");
  36.   syscall(SYS_exit, EXIT_SUCCESS);
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top