dvwa-command injection

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


<?php

if( 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

<?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>";
}

?> 
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。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值