VladimirRamirez07/api-security-fuzzing-suite
GitHub: VladimirRamirez07/api-security-fuzzing-suite
一个针对GitHub REST API v3的安全测试套件,集成了API模糊测试、速率限制分析和错误披露检测功能,用于全面评估API安全性。
Stars: 0 | Forks: 0
# 🔐 API 安全模糊测试套件













## 🎯 功能
- 💉 **模糊测试** — 发送损坏的参数、无效类型、SQL 注入、超大负载和边界值以发现意外行为
- ⚡ **速率限制测试** — 发送突发请求以验证 API 是否正确阻止滥用并返回正确的 `Retry-After` 头部
- 🔎 **错误披露检测** — 设计旨在触发详细错误的输入,并检查 API 是否泄露堆栈跟踪、内部路径、数据库名称或框架详情
- 📄 **自动生成报告** — 生成结构化的 JSON 结果和一份带有暗色模式仪表板的完整可视化 HTML 安全报告
## 🏗️ 项目结构
```
api-security-fuzzing-suite/
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions — auto-run tests on every push
├── src/
│ ├── auth.py # GitHub Personal Access Token auth
│ ├── config.py # Target URLs, endpoints, constants
│ ├── fuzzer/
│ │ └── fuzzer.py # Core fuzzing engine + payload library
│ ├── rate_limiter/
│ │ └── rate_limiter.py # Burst tester + rate limit header analysis
│ ├── error_detector/
│ │ └── error_detector.py # Info disclosure scanner
│ └── reporter/
│ └── reporter.py # JSON + HTML report generator
├── results/ # Auto-generated test results (gitignored)
│ ├── fuzzing/
│ ├── rate_limit/
│ └── errors/
├── tests/
│ ├── test_auth.py # Auth module unit tests
│ ├── test_fuzzer.py # Fuzzing engine unit tests
│ └── test_error_detector.py # Error detector unit tests
├── main.py # Entry point — interactive CLI
├── .env.example # Credentials template
└── requirements.txt
```
## ⚙️ 设置
### 2. 获取 GitHub 个人访问令牌
1. 前往 [github.com/settings/tokens](https://github.com/settings/tokens)
2. 点击 **"Generate new token (classic)"**
3. 选择范围:`public_repo` 和 `read:user`
4. 复制生成的令牌
### 3. 配置您的 `.env` 文件
```
cp .env.example .env
# 编辑 .env 并添加您的 token
```
```
GITHUB_TOKEN=your_token_here
GITHUB_BASE_URL=https://api.github.com
```
### 4. 运行
```
python main.py
```
CLI 将会交互式地询问要运行哪些模块。
## 🧪 模糊测试载荷类别
| 类别 | 示例 | 测试目标 |
|----------|----------|---------------|
| SQL 注入 | `' OR 1=1--`, `'; DROP TABLE` | 输入净化 |
| 类型混淆 | `null`, `[]`, `{}`, `True`, `-0.0` | 类型验证 |
| 特殊字符 | `\x00`, `%00`, `../../etc/passwd` | 编码与路径处理 |
| 超大负载 | `"A" * 10000`, `"🔥" * 500` | 大小限制与 DoS 抵抗能力 |
| 边界值 | `-1`, `2147483648`, `9999999999` | 整数溢出处理 |
| 格式破坏 | 无效日期、畸形 ID、URI 注入 | 格式验证 |
| 路径遍历 | `../../../etc/passwd`, `%2e%2e%2f` | 目录遍历 |
## 🔎 错误披露严重级别
| 严重性 | 检测内容 | 示例 |
|----------|----------------|---------|
| 🔴 严重 | 堆栈跟踪、错误中的凭据 | `Traceback (most recent call last)` |
| 🟠 高 | 数据库名称、内部路径、服务器错误 | `MongoDB connection refused` |
| 🟡 中 | 框架信息、调试模式、异常 | `Django version 3.2.1` |
| 🔵 低 | 参数名称、验证逻辑 | `field 'username' is required` |
## ⚡ 速率限制分析
本套件发送突发请求并测量:
- API 开始阻止时的请求编号
- `Retry-After` 头部是否存在
- 暴露了哪些速率限制头部(`X-RateLimit-Limit`、`X-RateLimit-Remaining` 等)
- API 是否返回 `429 Too Many Requests` 或静默丢弃请求
## 📊 示例输出
```
🔐 API Security Fuzzing Suite
Target: GitHub REST API v3
Modules: Fuzzer · Rate Limiter · Error Detector · Reporter
🔑 Authenticating with GitHub...
✅ Authenticated as: VladimirRamirez07 (Vladimir Ramirez)
MODULE 1 — Fuzzing Engine
🔍 Fuzzing: /search/repositories → param: q
INTERESTING payload={} status=200
INTERESTING payload=AAAA...AAAA status=200
MODULE 2 — Rate Limit Tester
⚡ Rate Limit Burst Test: /search/repositories
✓ 10/40 requests OK
⚠ Request #26 → status 403
MODULE 3 — Error Disclosure Detector
🔎 Error Disclosure Scan: /search/repositories
✅ No information disclosure detected
✅ HTML Report generated: results/security_report_20260520_015517.html
🔐 Final Report
━━━━━━━━━━━━━━━━━━━━━━━
Security Assessment Complete
Critical: 0 | High: 0 | Medium: 0
✅ No critical findings
```
结果保存为:
- `results/fuzzing/fuzzing_YYYYMMDD_HHMMSS.json`
- `results/rate_limit/rate_limit_YYYYMMDD_HHMMSS.json`
- `results/errors/errors_YYYYMMDD_HHMMSS.json`
- `results/security_report_YYYYMMDD_HHMMSS.html` ← 可视化仪表板
## 🤖 CI/CD 流程
每次推送到 `main` 分支将自动:
1. 启动一个 Ubuntu 环境
2. 安装所有依赖项
3. 通过 pytest 运行所有 12 个单元测试
4. 上传测试产物
```
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
```
## 🛡️ 道德使用
此工具仅用于**授权的安全测试**。
所有测试均针对**在其文档限制范围内的公开 API**。
请勿在没有明确许可的情况下对任何 API 使用此工具。
## 👤 作者
**Vladimir Ramirez** — [@VladimirRamirez07](https://github.com/VladimirRamirez07)
标签:API安全, API测试, GitHub API, JSON输出, Python, REST API, 字符串匹配, 安全报告, 安全测试, 攻击性安全, 无后门, 渗透测试辅助, 网络安全, 请求伪造, 逆向工具, 速率限制测试, 错误处理, 错误泄露检测, 防御测试, 隐私保护