setuid C program - 1-fares/notes GitHub Wiki
Think of this as a more dangerous sudo
:
asroot.c
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
int main(int argc, char ** argv) {
if (argc < 2) {
printf("Usage: asroot \"<args>\"\n");
return 1;
}
setuid(0);
return system(argv[1]);
}
Build:
gcc -o asroot asroot.c
Run:
./asroot <args>