當
--level
的參數設定為2或者2以上的時候,sqlmap會嘗試注入Cookie參數。當
--level
參數設定為3或者3以上的時候,會嘗試對User-Angent和referer進行注入。
1、sqlmap設定User-Agent頭
--user-agent=AGENT
指定HTTP User - Agent頭
預設情況下sqlmap的HTTP請求頭中User-Agent值是:
sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org)
可以使用
--user-agent
來僞造
使用Firefox浏覽器通路頁面時的User-Agent

使用
python sqlmap.py -u "http://172.17.0.1/Less-1/index.php/?id=1" --banner
并用wireshark抓取http包,檢視User-Agent
為了避免觸發安全機制,使用參數設定User-Agent
此時可以看到User-Agent頭改變
也可以使用
--random-agent
使用随機標明的HTTP User - Agent頭
檢視可使用的User - Agent
[email protected]:/usr/share/sqlmap# ls
COMMITMENT data doc extra http.txt lib LICENSE plugins README.md sqlmapapi.py sqlmap.conf sqlmap.py tamper test test.txt thirdparty url.txt wget-log
[email protected]:/usr/share/sqlmap# cd data
[email protected]:/usr/share/sqlmap/data# ls
html procs shell txt udf xml
[email protected]:/usr/share/sqlmap/data# cd txt
[email protected]:/usr/share/sqlmap/data/txt# ls
common-columns.txt common-files.txt common-outputs.txt common-tables.txt keywords.txt smalldict.txt user-agents.txt wordlist.tx_
可以在user-agents.txt中檢視可使用的User - Agent
注意:針對User - Agent的值探測SQL注入,需要設定
--level
值為3
以Less-18為例
開啟burpsuite進行截斷,将請求放入test.txt中
使用sqlmap進行自動化探測
如果使用
python sqlmap.py -r test.txt
不加
--level 3
,則不會對User - Agent進行探測
2、sqlmap設定host頭
對HTTP主機頭進行SQL注入,需要設定
--level
為5
3、sqlmap設定referer頭
以Less19為例
如果直接使用
python sqlmap.py -r test.txt
會提示
當設定level參數時
python sqlmap.py -r test.txt --level 3
4、sqlmap設定額外http頭
方式一:
通過設定選項
--headers
,可以提供額外的HTTP頭,每個頭必須用換行符分割
可以看到設定成功
設定多個時,使用分隔符
'\n'
方式二:
從sqlmap.conf檔案中設定
[email protected]:/usr/share/sqlmap# ls
COMMITMENT data doc extra http.txt lib LICENSE plugins README.md sqlmapapi.py sqlmap.conf sqlmap.py tamper test.txt thirdparty url.txt wget-log
[email protected]:/usr/share/sqlmap# cat sqlmap.conf
# At least one of these options has to be specified to set the source to
# get target URLs from.
[Target]
...
修改完sqlmap.conf後使用
python sqlmap.py -c sqlmap.conf