标签:block 通过 header tail one pat group clean tom
MarkdownPad Document
这道题挺有意思,这里详细的记录一下;
1 #include <stdio.h> 2 #include <string.h> 3 4 int filter(char* cmd){ 5 int r=0; 6 r += strstr(cmd, "flag")!=0; 7 r += strstr(cmd, "sh")!=0; 8 r += strstr(cmd, "tmp")!=0; 9 return r; 10 } 11 int main(int argc, char* argv[], char** envp){ 12 putenv("PATH=/fuckyouverymuch"); 13 if(filter(argv[1])) return 0; 14 system( argv[1] ); 15 return 0; 16 }
int tmp = strstr(cmd,"flag")? 0 : 1;
r += tmp;
其中,argv[1] == "/bin/cat f* "中使用了通配符来避免出现关键字符串flag;
则flag即为 mommy now I get what PATH environment is for :)
2017-2-11 14:52;38
标签:block 通过 header tail one pat group clean tom
原文地址:http://www.cnblogs.com/WangAoBo/p/6389160.html