TrueNix/bugbounty-ctf
GitHub: TrueNix/bugbounty-ctf
面向授权安全测试和 CTF 竞赛的 Python 黑盒漏洞扫描与利用工具包,提供多种 Web 漏洞的自动化检测、payload 库及报告生成能力。
Stars: 1 | Forks: 0
# 漏洞赏金与 CTF 工具包
一个用于 CTF 挑战和经授权漏洞赏金狩猎的 Python 工具包。采用黑盒测试方法论 —— 通过观察和系统性测试来发现漏洞,而不是通过阅读源代码。
**核心理念:去发现,而不是去阅读。**
## 安装说明
```
pip install bugbounty-ctf
# 可选:用于 binary exploitation
pip install bugbounty-ctf[pwn]
# 开发
pip install -e ".[dev]"
```
## 快速开始
```
from bugbounty_ctf import SecurityScanner
from bugbounty_ctf.api import test_login_sqli, test_xss, map_surface, save_report
# 映射攻击面
scanner = SecurityScanner("http://target/")
surface = map_surface("http://target/")
# 测试登录表单的 SQLi
test_login_sqli("http://target/login", scanner=scanner)
# 测试带有 filter-bypass escalation 的 XSS
test_xss("http://target/search", param_name="q", scanner=scanner)
# 生成并保存报告
save_report(scanner)
```
## 功能特性
| 功能 | 函数 |
|:-----------|:---------|
| Payload 测试 | `run_payload_set()` 结合 baseline 比较 |
| 响应差异比对 | 状态码、长度、响应时间、内容模式 |
| 攻击面映射 | `map_surface()` — 表单(支持任意属性顺序)、链接、技术栈 |
| WAF 检测 | `detect_defenses()` — WAF、速率限制、过滤器、缺失标头 |
| SQL 注入 | `test_login_sqli()` |
| SSTI | `test_ssti()` — 通过 baseline 比较进行确认 |
| 命令注入 | `test_command_injection()` |
| 路径遍历 | `test_path_traversal()` |
| NoSQL 注入 | `test_nosqli()` |
| LDAP 注入 | `test_ldap_injection()` |
| SSRF | `test_ssrf()` |
| XSS | `test_xss()` — 8 级过滤器绕过提权阶梯 |
| IDOR | `test_idor()` — 序列 ID 探测与差异检测 |
| XXE | `test_xxe()` |
| 竞态条件 | `test_race_condition()` — 并发请求测试 |
| 反序列化 | `test_pickle_deserialization()` / `test_yaml_deserialization()` |
| JWT 攻击 | `test_jwt_attacks()` — alg=none、弱 HS256 密钥暴力破解 |
| 文件上传 | `test_file_upload()` — 9 种绕过变体 + RCE 验证 |
| GraphQL | `test_graphql_alias_batch()` — 别名批处理暴力破解 |
| 链式漏洞利用 | `ChainContext` — 在漏洞利用之间传递 token |
| 报告生成 | `generate_report()` / `save_report()` — Markdown 或 JSON |
## 架构
```
bugbounty_ctf/
├── engine.py # SecurityScanner, ResponseDiff, derive_base_url
├── quick_tests.py # One-liner test functions (SQLi, SSTI, CMDi, etc.)
├── advanced_tests.py # WAF detection, race conditions, XXE, JWT, XSS, IDOR, GraphQL
├── web_recon.py # Automated web target recon (shell-injection-safe)
├── callback_listener.py # HTTP listener for XSS/SSRF callback detection
├── alpine_pty_extract.py # SUID binary file extraction via PTY
└── api.py # Public API exports
```
## 参考库
`references/` 目录包含基于真实 CTF 和漏洞赏金经验构建的方法论文档:
| 文件 | 用途 |
|:-----|:---------|
| `payload-library.md` | 按漏洞类别整理的 Payload 集合 |
| `escalate-ctf-walkthrough.md` | SQLi → webshell → SUID → Docker root 链 |
| `advanced-escalation.md` | SUID PTY、PAM 脚本、Docker 逃逸 |
| `suid-webshell-exploitation.md` | 通过 webshell 利用 SUID 二进制文件 |
| `suid-sg-docker-escalation.md` | `setresuid()` + `sg docker` 模式 |
| `docker-privilege-escalation.md` | Docker 组 → root |
| `curl-executor-webshell.md` | SSRF curl 执行器 → webshell → RCE |
| `sqlite-php-sqli-playbook.md` | PHP+SQLite SQLi 攻击树 |
| `sqlite-sqli-deep-dive.md` | pragma_*、sqlite_dbpage、FTS3 tokenizer |
| `htb-recon-methodology.md` | HTB 侦察:机器 ID、GitHub 源码发现 |
| `aclabs-platform-patterns.md` | ACLabs.pro 模式、漏洞 ID 与 flag 捕获 |
| `aclabs-drtbp-architecture.md` | DRTBP 挑战架构 |
| `aclabs-source-exploitation.md` | ACLabs 源代码漏洞利用方法论 |
| `nginx-ui-exploitation.md` | nginx-ui:未经身份验证的备份、RSA 登录 |
| `nginx-ui-login-encryption.md` | nginx-ui RSA 登录工作流 |
| `nginx-ui-backdoor.md` | nginx-ui 后门分析 |
| `recreating-ctf-labs-locally.md` | 使用 Docker Compose 重建 CTF 靶机 |
| `ctf_helper.py` | `analyze_challenge()`、编码检测、XOR、哈希破解 |
## 模板
- **`templates/exploit_template.py`** — Pwntools 漏洞利用骨架
- **`templates/bug-bounty-report.md`** — 用于赏金提交的报告模板
## 测试
```
pytest --cov=bugbounty_ctf --cov-report=term-missing
```
测试使用 `responses` 库进行模拟 HTTP 请求 —— 无真实网络调用。
## 安全性
本工具包仅用于经授权的安全测试。在对任何目标进行测试之前,请务必获得明确许可。有关报告本项目漏洞的信息,请参阅 [SECURITY.md](SECURITY.md)。
## 开源许可
MIT
标签:Bug Bounty, CISA项目, CTF工具, DOE合作, Python, XXE攻击, 可自定义解析器, 安全测试, 安全规则引擎, 攻击性安全, 无后门, 漏洞搜索, 逆向工具