DVWA - Command Injection (low, medium, high)

low

查看源码

// Get input
$target = $_REQUEST[ 'ip' ];
// 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 ); 
}

功能是ping我们提供的IP,一般可用
;
|
||
&
&&
来连接命令执行,low这个等级挑一个自己喜欢的就可以了。注入代码如下

;ls

返回结果如下

help
index.php
source

medium

查看源码,可发现PHP以黑名单的方式,过滤(删除)&&和;两个连接符,思路是选择其他的连接符即可,比如|, ||, &。

high

查看源码,可发现PHP以黑名单方式,过滤(删除)&, ;, | , -, $, (, ), `和||,但是细心一点可以发现|后面有一个空格,所以还是可以用|来连接命令,即注入命令为

|ls

你可能感兴趣的:(CTF)