dvwa-command injection

来源:互联网 发布:淘宝网店装修模板 编辑:程序博客网 时间:2024/05/22 01:37

Command Injection,即命令注入,是指通过提交恶意构造的参数破坏命令语句结构,从而达到执行恶意命令的目的。


<?phpif( isset( $_POST[ 'Submit' ]  ) ) {    // Get input    $target = $_REQUEST[ 'ip' ];    // Determine OS and execute the ping command.    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {        // Windows   php_uname('s')操作系统名称        $cmd = shell_exec( 'ping  ' . $target );//连接字符    }    else {        // *nix        $cmd = shell_exec( 'ping  -c 4 ' . $target );    }    // Feedback for the end user    echo "<pre>{$cmd}</pre>";}?> 

1. 127.0.0.1&&net user 列出本机网络连接(ubuntu 下没有net user,我随便换了一个命令groups,多了个daemon)


(ttl 存活时间 time 延迟 icmp_seq 报文 第几个 rrt 往返时延)

medium

<?phpif( 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>";}?> 
1.127.0.0.1&net user(不管前面是否成功都执行下一个),如上图所示

2.127.0.0.1&ipconfig(ubuntu下是ifconfig)


high

多了一些而已

       '&'  => '',
        
';'  => '',
        
'| ' => '',
        
'-'  => '',
        
'$'  => '',
        
'('  => '',
        
')'  => '',
        
'`'  => '',
        
'||' => '',

注意:我们的思想就是找漏网之鱼,我们这里的‘|’后面有个空格,那么‘|’就成为了漏网之鱼。

结果就是一个“daemon”


impossible

这里加上了几个函数

stripslashes
explode 把字符串打散为数组,返回字符串的数组。
is_numeric
检测string是否为数字或数字字符串,如果是返回TRUE,否则返回FALSE。



原创粉丝点击