使用hackhttp框架重放数据包

0x00 关于hackhttp

hackhttp是一个GitHub上的开源项目。官方的简介是:hackhttp 是四叶草安全旗下 BugscanTeam 打造的一款 Python 语言的 HTTP 第三方库。是分布式漏洞扫描框架 BugScan 中核心库之一。

hackhttp 致力于帮助安全测试人员快速编写代码,除众多基础功能外,hackhttp 支持直接发送 HTTP 原始报文,开发者可以直接将浏览器或者 Burp Suite 等抓包工具中截获的 HTTP 报文复制后,无需修改报文,可直接使用 hackhttp 进行重放。

hackhttp 使用连接池技术,在应对大量请求时自动对连接进行复用,节省建立连接时间与服务器资源,这种天生的特性,在编写爬虫时尤为显著,测试用例中提供了一个爬取乌云所有漏洞的爬虫。

可以发现,hackhttp的核心代码存在与文件https://github.com/BugScanTeam/hackhttp/blob/master/hackhttp/hackhttp.py中(import 的模块均是Python的原生模块)。

0x01 小试hackhttp

save hackhttp.py.png

burp.png

  • 在Jupyter的notebook中重放BurpSuite抓取的数据包,Python脚本如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import hackhttp
hh = hackhttp.hackhttp()
raw='''GET / HTTP/1.1
Host: 192.168.114.131:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSID=e3ddf82f35b66149fd856936ad03d6a3
Upgrade-Insecure-Requests: 1'''
code, head, html, redirect, log = hh.http('http://192.168.114.131:8080', raw=raw)
code
print html

执行结果如下图所示。

run script.png