sqlmap源碼解析(二)
init()
_basicOptionValidation
這里檢查了所有的參數(shù)的正確性并給出使用建議
_listTamperingFunctions
這里有一個(gè)可以列舉tamper 的方法=适掰。=
以前居然不知道
可以找到用--list-tamper就可以打開
__priority__
通過這個(gè)做標(biāo)識(shí)符來匹配下面的介紹
_setTamperingFunctions
加載插件
首先判斷文件存在不存在以及更改工作路徑等事情
然后用內(nèi)置函數(shù)import()將文件導(dǎo)入
在對(duì)插件的優(yōu)先級(jí)進(jìn)行判斷
_setTrafficOutputFP
沒想到sqlmap還可以將http記錄到文件中
只要-t參數(shù)就好了
_setHostname
從url中取出hostname
_doSearch
之前全是很簡(jiǎn)單的給請(qǐng)求頭賦值
這里看樣子有點(diǎn)意思了
This function performs search dorking, parses results
and saves the testable hosts into the knowledge base.
可以直接獲得google搜索的結(jié)果
可以這樣用
sqlmap -g "inurl:\".php?id=1\""
不過我的命令行好像連接不到google
_setBulkMultipleTargets()
sqlmap 的 -m參數(shù)
getFileItems
在這里讀取文件
將文件中的url一個(gè)一個(gè)讀取放到kb.target
_setSitemapTargets
sqlmap的-x的參數(shù)
通過parseSitemap
來解析target
將url從Sitemap中提取出來
_setCrawler
--crawl:從起始位置爬站深度
如果沒有標(biāo)簽
訪問一個(gè)網(wǎng)站用
r'(?i)<a[^>]+href="(?P<href>[^>"]+)"'
這個(gè)正則
將別的url提取出來
checkSameHost
sqlmap 在爬蟲的時(shí)候?qū)ο嗤瑄rl的處理
findPageForms
Parses given page content for possible forms (Note: still not implemented for Python3)
>> findPageForms('<html><form action="/input.php" method="POST"><input type="text" name="id" value="1"><input type="submit" value="Submit"></form></html>', '')
set([(u'/input.php', 'POST', u'id=1', None, None)])
從form中獲得所有的參數(shù)
使用了clientform的ParseResponse來解析
沒了解過這個(gè)第三方庫以后學(xué)習(xí)一下
loadBoundaries
接下來都是一些set來初始化的
這兩個(gè)差不多最后都用了
parseXmlNode
來解析了xml
parseXmlNode
for element in node.getiterator("boundary"):
boundary = AttribDict()
for child in element.getchildren():
if child.text:
values = cleanupVals(child.text, child.tag)
boundary[child.tag] = values
else:
boundary[child.tag] = None
conf.boundaries.append(boundary)
for element in node.getiterator("test"):
test = AttribDict()
for child in element.getchildren():
if child.text and child.text.strip():
values = cleanupVals(child.text, child.tag)
test[child.tag] = values
else:
if len(child.getchildren()) == 0:
test[child.tag] = None
continue
else:
test[child.tag] = AttribDict()
for gchild in child.getchildren():
if gchild.tag in test[child.tag]:
prevtext = test[child.tag][gchild.tag]
test[child.tag][gchild.tag] = [prevtext, gchild.text]
else:
test[child.tag][gchild.tag] = gchild.text
conf.tests.append(test)
差不多就是解析處理了之后放入到conf中
update
--update
這個(gè)命令行可以更新
首先先檢查有沒有.git文件
然后會(huì)詢問要不要通過zip來下載安裝
一個(gè)通過https://github.com/sqlmapproject/sqlmap/zipball/master
下來zip來更新
另一個(gè)這樣更新git checkout . && git pull %s HEAD
后記
終于看完了init要往下繼續(xù)看了=结窘。=
是我看的太不認(rèn)真了