Command Injection,即命令注入,是指通过提交恶意构造的参数破坏命令语句结构,从而达到执行恶意命令的目的。PHP命令注入攻击漏洞是PHP应用程序中常见的脚本漏洞之一,国内著名的Web应用程序Discuz!、DedeCMS等都曾经存在过该类型漏洞。

low

127.0.0.1&&ipconfig

DVWA2.0 Command Injection_php应用

medium

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

// Remove any of the charactars in the array (blacklist).
$target = str_replace( array_keys( $substitutions ), $substitutions, $target );

设置了黑名单:​​&&​​​和​​;​​,但是仍然有遗漏的:

127.0.0.1&ipconfig
127.0.0.1&;&ipconfig

High

High级别的代码进一步完善了黑名单,但由于黑名单机制的局限性,没有过滤掉管道符​​|​​。

127.0.0.1|ipconfig

DVWA2.0 Command Injection_php应用_02

Impossible

Impossible级别把ip分割成四个数字,这样的白名单模式才能执行。