前言

通过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

最新文章

  1. FZU 2105Digits Count(线段树 + 成段更新)
  2. 用FileInputStream实现文本复制
  3. fastDFS 一二事 - 简易服务器搭建(单linux)
  4. SQL的主键和外键
  5. Hibernate-细细道来-01
  6. 一步步学习ASP.NET MVC3 章节总结
  7. Frank自动化测试
  8. 驱动lx4f120h,头文件配置,没有完全吃透,望指点
  9. javascript圆形排列
  10. [C#]Windows文件分类器小程序
  11. A:点排序-poj
  12. dijkstra最小花费
  13. 01-Django介绍和安装
  14. MySQL数据库开发的三十六条军规
  15. pytorch中tensorboardX的用法
  16. Spring boot 配置https 实现java通过https接口访问
  17. selenium之测试卫星资料页面操作(元素遍历)
  18. android: 实现强制下线功能
  19. auto sudo password in shell
  20. sqlserver数据库的分离与附加

热门文章

  1. 20135316王剑桥Linux内核学习笔记第三周
  2. 第二个Sprint冲刺第 七天(燃尽图)
  3. node模块加载机制。
  4. Thinkphp3.2 入口绑定问题记录
  5. Ubuntu17安装maven3.5.2
  6. 01 Maven构建的项目中,把.xml等配置文件添加到编译目录
  7. 动态规划DP的优化
  8. Django入门项目实践(中)
  9. Windows 7 安装VS2008 SP1 失败
  10. js中全局变量修改后的值不生效【jsp页面中各个js中内容的加载顺序】