【Pyhon】利用BurpSuite到SQLMap批量测试SQL注入
前言
通过Python脚本把Burp的HTTP请求提取出来交给SQLMap批量测试,提升找大门户网站SQL注入点的效率。
导出Burp的请求包
配置到Burp的代理后浏览门户站点,Burp会将URL纪录存储在HTTP History选项卡的内容里

导出Burp的请求包到SQLMAP中测试SQL注入漏洞,可以通过【Filter】选择【Show only parametrized requests】筛选出需要测试的URL请求。

Ctrl+A全选所有的请求条目,右击点击保存【Save items】

默认输出的HTTP请求包是经过Base64编码后的。可以选择勾选掉【Base64-encode requests and responses】
配置SQLMap
环境变量里把SQLMap设置为直接打开cmd窗口就可以使用。
Burp-To-SQLMap Script
测试环境:Windows10、Python2。
脚本测试命令,使用示例代码保存的Brup包不需要勾选掉Base64的编码。因为不用Base64编码的文件数据看起来太混乱了。
- 导出的文件名如果是burp情况
把Burp导出的文件放到脚本目录下,直接用这个脚本就可以了。
> Burp-to-sqlmap.py
- 自定义参数
Usage: ./burp-to-sqlmap.py [options]"
print" Options: -f, --file <BurpSuit State File>"
print" Options: -o, --outputdirectory <Output Directory>"
print" Options: -s, --sqlmappath <SQLMap Path>"
print" Options: -p, --proxy <Use Proxy>"
print" Example: python burp-to-sqlmap.py -f [BURP-STATE-FILE] -o [OUTPUT-DIRECTORY] -s [SQLMap-Path] -p [Proxy]"
代码:
#encoding: utf-8
import os
from bs4 import BeautifulSoup
import os.path
import argparse
import sys
import base64
# SQLMap自定义选项
_options = " --technique BEST --batch --threads 10 "
def usage():
print" "
print" Usage: ./burp-to-sqlmap.py [options]"
print" Options: -f, --file <BurpSuit State File>"
print" Options: -o, --outputdirectory <Output Directory>"
print" Options: -s, --sqlmappath <SQLMap Path>"
print" Options: -p, --proxy <Use Proxy>"
print" Example: python burp-to-sqlmap.py -f [BURP-STATE-FILE] -o [OUTPUT-DIRECTORY] -s [SQLMap-Path] -p [Proxy]"
print" "
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file",default="burp")
parser.add_argument("-o", "--outputdirectory",default="output")
parser.add_argument("-s", "--sqlmappath")
parser.add_argument("-p", "--proxy")
args = parser.parse_args()
if not args.file or (os.path.exists("burp") == False):
usage()
sys.exit(0)
if os.path.exists("output") == False:
os.mkdir("output")
if args.proxy:
proxyvalue = "--proxy " + args.proxy
else:
proxyvalue = ""
vulnerablefiles = []
filename = args.file
directory = args.outputdirectory
sqlmappath = args.sqlmappath
if not os.path.exists(directory):
os.makedirs(directory)
# 提取数据包
packetnumber = 0
print " [+] Exporting Packets ..."
with open(filename, 'r') as f:
soup = BeautifulSoup(f.read(), "html.parser")
for i in soup.find_all("request"):
packetnumber = packetnumber + 1
print " [-] Packet " + str(packetnumber) + " Exported."
outfile = open(os.path.join(args.outputdirectory, str(packetnumber) + ".txt"), "w")
outfile.write(base64.b64decode(i.text.strip()))
print " "
print str(packetnumber) + " Packets Exported Successfully."
print " "
# SQLMap测试
print " [+] Testing SQL Injection on packets ... (Based on your network connection Test can take up to 5 minutes.)"
for file in os.listdir(directory):
print " [-] Performing SQL Injection on packet number " + file[:-4] + ". Please Wait ..."
_command = "sqlmap -r " + directory + "\\" + file + _options + proxyvalue + " > " + directory + "\\testresult" + file
print _command
os.system(_command)
if 'is vulnerable' in open(directory + "\\testresult" + file).read() or "Payload:" in open(
directory + "\\testresult" + file).read():
print " - URL is Vulnerable."
vulnerablefiles.append(file)
else:
print " - URL is not Vulnerable."
print " - Output saved in " + directory + "\\testresult" + file
print " "
print "--------------"
print "Test Done."
print "Result:"
if not vulnerablefiles:
print "No vulnerabilities found on your target."
else:
for items in vulnerablefiles:
print "Packet " + items[:-4] + " is vulnerable to SQL Injection. for more information please see " + items
print "--------------"
print " "
测试效果


参考
https://www.exploit-db.com/docs/english/45428-bulk-sql-injection-using-burp-to-sqlmap.pdf
【Pyhon】利用BurpSuite到SQLMap批量测试SQL注入的更多相关文章
- sqlmap开源 测试sql注入的工具 各种参考链接
https://www.cnblogs.com/insane-Mr-Li/p/10150165.html https://github.com/sqlmapproject/sqlmap 官网 http ...
- sqlmap和burpsuite绕过csrf token进行SQL注入检测
利用sqlmap和burpsuite绕过csrf token进行SQL注入 转载请注明来源:http://www.cnblogs.com/phoenix--/archive/2013/04/12/30 ...
- 利用osql/ocmd批处理批量执行sql文件
原文:利用osql/ocmd批处理批量执行sql文件 上周在测试环境建了几十张表,保存了.sql文件,准备在正式环境重建的时候懒得一个个打开建了,做一在网上搜寻了一下,果然有简单点的方法. 利用osq ...
- python使用sqlmap API检测SQL注入
0x00前言: 大家都知道sqlmap是非常强大的sql注入工具,最近发现他有个sqlmap API,上网查了一下.发现这是 sqlmap的微端.(可以叫做sqlmap在线检测sql注入= =) 0x ...
- 利用sqlmap和burpsuite绕过csrf token进行SQL注入 (转)
问题:post方式的注入验证时遇到了csrf token的阻止,原因是csrf是一次性的,失效导致无法测试. 解决方案:Sqlmap配合burpsuite,以下为详细过程,参照国外牛人的blog(不过 ...
- Burpsuite+sqlmap批量扫描sql漏洞
1.burpsuite设置导出log n'd'k 输入文件名保存 2.sqlmap批量扫描 python sqlmap.py -l 文件名 --batch -smart batch:自 ...
- (五)SQLMap工具检测SQL注入漏洞、获取数据库中的数据
目录结构 一.判断被测url的参数是否存在注入点 二.获取数据库系统的所有数据库名称(暴库) 三.获取Web应用当前所连接的数据库 四.获取Web应用当前所操作的DBMS用户 五.列出数据库中的所有用 ...
- web安全测试--sql注入攻击
先要自行了解sql的几个概念: 1. or '1'='1' 2. order by 3. union : 联合查询需要表字段相同 sql注入攻击漏洞判断步骤: 1.‘ 2.查看数据库信息 3.绕过过 ...
- PHP:测试SQL注入以及防止SQL注入
在写登录注册的时候发现了SQL和JS注入这个危害网站的用户举动: 测试方法: SQL注入: 先来做一个测试: 用户名:’ or 1 # 密码:随便写8位以上 验证码:写正确 好吧,就那么简单就进去了: ...
随机推荐
- Day Ten
站立式会议 站立式会议内容总结 331 今天:话题单选对话框 遇到问题:无 442 今天:数据库交互,解决timepicker问题 遇到的问题:无 439 今天:测试模块功能 遇到问题:无 会议照片 ...
- 在eclipse中编译调试ns3
1首先把ns3项目导入eclipse 然后把上面的的ns3按照上面的提示即可导入成功. 然后可以运行一下 ./waf configure 2 配置C/C++ Build 右键工程,选择属性 ...
- We are a 团队
虽然在团队中只是拖后腿的存在,但是几个人一起摸索着前进也确实有着不一样的感觉. 我们队伍共有五个人:董强强.张振鑫.王鼎.高庆阳还有我(排名不分先后) 我们有自己的关于软件工程的QQ群,会在群里讨论一 ...
- # 蜗牛慢慢爬 LeetCode 21. Merge Two Sorted Lists [Difficulty: Easy]
题目 Merge two sorted linked lists and return it as a new list. The new list should be made by splicin ...
- 『编程题全队』Alpha阶段发布说明
1. 这一版本的功能 (1)管理个人的任务事项,管理用户的提醒事项,提供一个简洁的操作界面,将其分类为全部.今天.明日.最近七天.更远.还有已完成,方便用户进行事务管理和整理. (2)提供一个便捷的备 ...
- vue中npm run dev运行项目不能自动打开浏览器! 以及 webstorm跑vue项目jshint一直提示错误问题的解决方法!
vue中npm run dev运行项目不能自动打开浏览器!以及 webstorm跑vue项目jshint一直提示错误问题的解决方法! 1.上个项目结束就很久没有使用vue了,最近打算用vue搭建自己的 ...
- mybatis之接口方法多参数的三种实现方式
关键代码举例: DaoMapper.xml <!-- 传入多个参数时,自动转换为map形式 --> <insert id="insertByColumns" us ...
- gson 说明
JSON对象格式 法兹测试仪测试案例编纂JavaScript对象表示法(JSON)格式的特殊字符转义,类型等,由于谷歌GSON是底层的JSON库处理类型的详细说明,请参阅到GSON文档的详细信息,请参 ...
- MT【181】横穿四象限
设函数$f(x)=\dfrac{1}{x-a}-\dfrac{\lambda}{x-2}$,其中$a,\lambda\in R$记$A_1=\{(x,y)|x>0,y>0\},A_2=\{ ...
- 【BZOJ1044】[HAOI2008]木棍分割(动态规划,贪心)
[BZOJ1044][HAOI2008]木棍分割(动态规划,贪心) 题面 BZOJ 洛谷 题解 第一问随便二分一下就好了,贪心\(check\)正确性显然. 第二问随便前缀和+单调队列优化一下\(dp ...