dvwa-02-Command Injection

Security – 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>";
}

?> 

果然 代码中进行了如下转义

// Set blacklist
    $substitutions = array(
        '&&' => '',
        ';'  => '',
    );

Security – high

道高级别时发现 | 也已经不能用了
emmm
看下源码

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    
    
    // Get input
    $target = trim($_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>";
}

?> 

这次厉害
一段操作后全给转义了

万万没想到 这里竟然有这样一个漏洞(。。。。。。。。。。。
仔细看这里有什么不同???
多了一个空格。。。
那么我们不加空格不就ok了!
直接
|xxxx

'| ' => '',

猜你喜欢

转载自blog.csdn.net/qq_53755216/article/details/114327032
今日推荐