sqlmap支援自動偽靜態批次檢測
wyzsk發表於2020-08-19
作者:
路飛
·
2016/04/19 10:31
0x00 前言
由於還沒有找到一款比較適合批次檢測sql注入點的工具(proxy+sqlmapapi的方式批次檢測之類的批次sql注入點檢測),我的目光就轉向了sqlmap。雖然sqlmap沒有支援偽靜態注入點的測試(需要手動新增註入標記),由於是python寫的,可以快速方便的進行二次開發。
0x01 思路
我的思路是在有.html之類的字尾或者既沒有.html或者包含"?"的url進行修改。
偽靜態注入點一般都在數字,所以我就在數字後面新增註入標記。字串的偽靜態就不搞了,搞了工作量就會新增很多。
用如下的URL進行測試
#!bash
http://www.site.com/index.php/index/id/14
http://www.site.com/index.php/newsContent/id/341.html
http://www.site.com/show/?29-575.html
結果如下
#!bash
http://www.site.com/index.php/index/id/14*
http://www.site.com/index.php/newsContent/id/341*.html
http://www.site.com/show/?29*-575*.html
程式碼如下:
#!python
if re.search('html|htm|sthml',url) or url.find("?") == -1:
flag = 0
suffix = ""
if re.search('html|htm|sthml',url):
suffix = "." + re.search('html|htm|sthml',url).group()
urlList = url.split("/")
returnList = []
for i in urlList:
i = re.sub('\.html|\.htm','', i)
if i.isdigit():
returnList.append(i + "*")
flag = 1
else:
returnList.append(i)
url = '/'.join(returnList) + suffix
returnList = []
if flag == 0:
for i in urlList:
if re.search('html|htm|sthml',i):
digitList = re.findall('\d+',i)
for digit in digitList:
i = i.replace(digit, digit + "*")
returnList.append(i)
else:
returnList.append(i)
url = '/'.join(returnList)
print url
0x02 sqlmap支援單個自動檢測偽靜態
相關檔案
- https://github.com/sqlmapproject/sqlmap/blob/master/sqlmap.py
- https://github.com/sqlmapproject/sqlmap/blob/master/lib/controller/controller.py
- https://github.com/sqlmapproject/sqlmap/blob/master/lib/core/target.py
流程
Sqlmap.py 116行start()->controller.py 256行setupTargetEnv()->target.py 72行_setRequestParams()->target.py 117行
#!python
if kb.processUserMarks is None and CUSTOM_INJECTION_MARK_CHAR in conf.data:
message = "custom injection marking character ('%s') found in option " % CUSTOM_INJECTION_MARK_CHAR
message += "'--data'. Do you want to process it? [Y/n/q] "
test = readInput(message, default="Y")
if test and test[0] in ("q", "Q"):
raise SqlmapUserQuitException
else:
kb.processUserMarks = not test or test[0] not in ("n", "N")
if kb.processUserMarks:
kb.testOnlyCustom = True
這裡檢測是否使用了注入標記。
sqlmap獲取完所有你指定的資訊後,開始正式檢測是否有注入之前,會檢測是否使用了注入標記"*
",如果有的話就先處理這個注入標記的點進行測試。
這樣就明白注入標記的流程,只要_setRequestParams函式呼叫之前處理好URL,就可以支援自動的偽靜態注入的測試了。
只要在260行處新增
#!python
if re.search('html|htm|sthml',conf.url) or conf.url.find("?") == -1:
flag = 0
suffix = ""
if re.search('html|htm|sthml',conf.url):
suffix = "." + re.search('html|htm|sthml',conf.url).group()
urlList = conf.url.split("/")
returnList = []
for i in urlList:
i = re.sub('\.html|\.htm','', i)
if i.isdigit():
returnList.append(i + "*")
flag = 1
else:
returnList.append(i)
conf.url = '/'.join(returnList) + suffix
returnList = []
if flag == 0:
for i in urlList:
if re.search('html|htm|sthml',i):
digitList = re.findall('\d+',i)
for digit in digitList:
i = i.replace(digit, digit + "*")
returnList.append(i)
else:
returnList.append(i)
conf.url = '/'.join(returnList)
logger.info(conf.url)
這樣就可以了。
效果圖
這裡只是單個的,要支援批次檢測注入點。修改這裡是不行的。
0x03 sqlmap支援批次自動檢測偽靜態
相關檔案
https://github.com/sqlmapproject/sqlmap/blob/master/lib/core/option.py
583行處
#!python
for line in getFileItems(conf.bulkFile):
if re.match(r"[^ ]+\?(.+)", line, re.I) or CUSTOM_INJECTION_MARK_CHAR in line:
found = True
kb.targets.add((line.strip(), conf.method, conf.data, conf.cookie, None))
一行一行讀取檔案裡面的url。只要匹配到有問號"?"或者有注入標記"*"才進行測試。
在583處新增
#!python
if re.search('html|htm|sthml',line) or line.find("?") == -1:
flag = 0
suffix = ""
if re.search('html|htm|sthml',line):
suffix = "." + re.search('html|htm|sthml',line).group()
urlList = line.split("/")
returnList = []
for i in urlList:
i = re.sub('\.html|\.htm','', i)
if i.isdigit():
returnList.append(i + "*")
flag = 1
else:
returnList.append(i)
line = '/'.join(returnList) + suffix
returnList = []
if flag == 0:
for i in urlList:
if re.search('html|htm|sthml',i):
digitList = re.findall('\d+',i)
for digit in digitList:
i = i.replace(digit, digit + "*")
returnList.append(i)
else:
returnList.append(i)
line = '/'.join(returnList)
效果圖:
0x04 最後
如果有好的建議,可以在評論中給我留言。
本文章來源於烏雲知識庫,此映象為了方便大家學習研究,文章版權歸烏雲知識庫!
相關文章
- 偽靜態、靜態和動態的區別2020-12-18
- 利用Sqlmap API介面聯動Google Hacking批次SQL隱碼攻擊檢測2024-04-14SQLAPIGo
- wamp整合環境開啟rewrite偽靜態支援2018-01-16
- ASP.NET偽靜態及靜態2013-10-09ASP.NET
- Nginx偽靜態教程2013-07-12Nginx
- 網站偽靜態和純靜態區別2012-06-23網站
- nginx偽靜態檔案2020-12-22Nginx
- wordpress偽靜態的原理2017-10-08
- 徹底搞懂訪問者模式的靜態、動態和偽動態分派2021-11-24模式
- Typecho程式偽靜態規則2019-05-08
- PHP重定向與偽靜態2019-02-16PHP
- 偽靜態配置apache 和nginx2018-08-16ApacheNginx
- 網站提速-偽靜態(3)2017-11-14網站
- urlrewrite偽靜態匹配問題2012-10-15
- Helix QAC—原始碼級靜態自動化測試工具2024-03-15原始碼
- 機器學習&惡意程式碼靜態檢測2022-01-14機器學習
- .NET偽靜態使用以及和純靜態的區別2010-02-08
- Nginx常用Rewrite偽靜態規則2017-04-24Nginx
- Apache偽靜態html(URLRewrite)設定法2012-12-28ApacheHTML
- eclipse 匯入靜態類,自動程式碼提示靜態方法2016-02-03Eclipse
- 自動儲存、靜態儲存和動態儲存2017-04-18
- Klocwork — 符合功能安全要求的自動化靜態測試工具2021-07-07
- 選擇靜態程式碼安全檢測工具指南2023-09-19
- 靜態程式碼檢測工具(SAST)有哪些作用2023-12-07AST
- 微信域名檢測線上批次檢測如何實現?——利用域名檢測api介面實現批次檢測工具教程2020-04-22API
- PLSQL Language Referenc-PL/SQL靜態SQL-靜態SQL的描述-偽列2014-03-14SQL
- python指令碼處理偽靜態注入2020-08-19Python指令碼
- Laravel 專案 偽靜態分頁處理2019-12-31Laravel
- Yii2配置Nginx偽靜態的方法2019-04-15Nginx
- iOS中動/靜態庫支援bitcode的問題2018-03-22iOS
- 如何高效實施靜態程式碼檢測工具SAST?2021-06-17AST
- 如何檢視oracle引數是靜態或者是動態2015-05-07Oracle
- 偽AP檢測技術研究2020-08-19
- 批次檢測主機IP(一)2020-06-18
- 一個可以自動生成靜態庫,自動安裝程式的Makefile2014-08-08
- 自動化漏洞挖掘:靜態程式分析入門2022-12-07
- 帝國CMS 7.5 tags偽靜態設定教程2020-06-09
- .NET探索模型路由約定實現偽靜態2021-02-19模型路由