命令执行原因
`
$target = $_REQUEST[ 'ip' ];
// Determine OS and execute the ping command.
if (stristr(php_uname('s'), 'Windows NT')) {
$cmd = shell_exec( 'ping ' . $target );
echo '<pre>'.$cmd.'</pre>';
} else {
$cmd = shell_exec( 'ping -c 3 ' . $target );
echo '<pre>'.$cmd.'</pre>';
`将用户输入的参数带入了shell_exec函数执行了系统命令,在系统命令中可以通过 ; && &执行多条命令,如
图片
这里就同时执行了ping和ls命令
命令执行绕过
1.命令分隔符绕过
过滤这种黑名单防护是很不可靠的,有多种方法可以绕过,比如使用它没有过滤的方法(如&,|)和利用过滤本身来绕过(&;&)
|将前面命令的输出当作后面命令的输入,例如
ls|uame
%0a符号--换行符
%0d符号--回车符
2.空格绕过
1.< 符号
2.%09
3.$IFS$9 符号${IFS} 符号
3.命令终止符绕过
%00
%20 #
4.命令黑名单绕过
$a=if;$b=config;$a$b
网友评论