Skip to content

Instantly share code, notes, and snippets.

@azet
Created August 15, 2013 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azet/6242543 to your computer and use it in GitHub Desktop.
Save azet/6242543 to your computer and use it in GitHub Desktop.
just testing SECCOMP kernel feature. apparently this really works :)
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/prctl.h>
void main(int argc) {
printf("-- SECCOMP Test --\n\n");
if(prctl(PR_SET_SECCOMP, 1, 0, 0) == 0)
printf("[+]\tSECCOMP (via prctl(2)): ON\n");
int loop = argc - 1;
do {
if(access("/proc/self/numa_maps", R_OK) == 0)
printf("[-]\tcould use access(2) on /proc!\n");
if(fopen("/etc/passwd", "r") != 0)
printf("[-]\tcould fopen(3) /etc/passwd!\n");
} while(loop);
}
write(1, "-- SECCOMP Test --\n", 22-- SECCOMP Test --
) = 22
write(1, "\n", 1
) = 1
prctl(PR_SET_SECCOMP, 0x1, 0, 0, 0xffffffff) = 0
write(1, "[+]\tSECCOMP (via prctl(2)): ON\n", 31[+] SECCOMP (via prctl(2)): ON
) = 31
+++ killed by SIGKILL +++
zsh: killed strace ./a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment