level0 done

This commit is contained in:
2025-04-28 14:53:40 +02:00
commit 7a00213c96
4 changed files with 31 additions and 0 deletions

23
level0/source.c Normal file
View File

@ -0,0 +1,23 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int ac, char **av)
{
char *cmd;
int nb = atoi(av[1]);
if (nb == 423) {
cmd = strdup("/bin/sh");
gid_t gid = getegid();
uid_t uid = geteuid();
setresgid(gid, gid, gid);
setresuid(uid, uid, uid);
execv("/bin/sh", &cmd);
} else {
fwrite("No !\n", 1, 5, (FILE *)stderr);
}
return 0;
}