level0 done

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

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
RainFall.iso
rainfall*
level*/level*
passwd

1
level0/flag Normal file
View File

@ -0,0 +1 @@
423

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;
}

3
level0/walkthrough Normal file
View File

@ -0,0 +1,3 @@
# Level0
Using ghidra, we can decompile the code and see that it executes `/bin/sh` as the user `level1` in case `atoi(av[1]) == 423`