命令 | 说明 |
---|---|
A || B | A 执行失败后才会执行 B 命令 |
A | B | A 执行的输出结果,作为 B 命令的参数,A 不论正确与否都会执行 B 命令 |
A&&B | A 执行成功后才会执行 B 命令 |
A&B | A后台运行,A和B同时执行 |
A;B | A不论正确与否都会执行B命令 |
Low
对目标ip进行不同的ping测试,但是这里对用户输入的ip并没有进行任何的过滤,所以我们可以进行命令执行漏洞,我们ping一个ip(随便一个能ping得通的就行,比如本机ip 127.0.0.1
)
利用windows命令的连接符&&进行测试:
127.0.0.1&&dir
Medium
<?php
if( isset( $_POST[ 'Submit' ] ) ) {
// Get input
$target = $_REQUEST[ 'ip' ];
// Set blacklist
$substitutions = array(
'&&' => '',
';' => '',
);
// Remove any of the charactars in the array (blacklist).
$target = str_replace( array_keys( $substitutions ), $substitutions, $target );
// Determine OS and execute the ping command.
if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
// Windows
$cmd = shell_exec( 'ping ' . $target );
}
else {
// *nix
$cmd = shell_exec( 'ping -c 4 ' . $target );
}
// Feedback for the end user
echo "<pre>{$cmd}</pre>";
}
?>
medium级别的代码增加了对 && 和 ;的过滤,但并未过滤&,|,||。所以其它的依旧可以。
High
细心的小伙伴可以发现过滤代码”|”后面有个空格,所以我们后面不加空格是可以绕过的。
127.0.0.1|whoami
好啦!
先就这样了
有一起学习安全的可以加我QQ:CD0752C90C7A809655447F2768D98948
提示一下MD5哦