Pyhroff/redteam-toolkit
GitHub: Pyhroff/redteam-toolkit
一款用于授权红队演练与渗透测试教育的 Python 工具包,整合了从侦察到后渗透的全流程脚本并内置独有的 OPSEC 安全评分机制。
Stars: 0 | Forks: 0
# redteam-toolkit ⚔
用于授权红队演练的高级 Python 工具包。
从零开始为 BTech 网络安全 → 红队顾问路线而打造。




## 法律声明
## 与现有框架的不同之处
| 功能 | Metasploit | Empire | reconftw | **本工具包** |
|---------|-----------|--------|----------|-----------------|
| OPSEC 风险评分 | ❌ | ❌ | ❌ | ✅ `opsec_advisor.py` |
| 演练会话追踪器 | ❌ | ❌ | ❌ | ✅ `core/session.py` |
| 自动化链式 orchestrator | ❌ | ❌ | 部分 | ✅ `core/orchestrator.py` |
| 感知 OSINT 的密码生成器 | ❌ | ❌ | ❌ | ✅ `smart_passwords.py` |
| WAF 检测 + 绕过提示 | ❌ | ❌ | ❌ | ✅ `waf_detector.py` |
| SE 借口生成器 + Cialdini | ❌ | ❌ | ❌ | ✅ `pretext_builder.py` |
| 技术栈 → CVE 映射 | ❌ | ❌ | 部分 | ✅ `tech_fingerprint.py` |
| 结合 GTFOBins 的 Linux 提权 | 外部依赖 | 外部依赖 | ❌ | ✅ `privesc_linux.py` |
| LFI + wrapper + 日志污染 | ❌ | ❌ | ❌ | ✅ `lfi_tester.py` |
## Windows AV — 请先执行此操作
Defender **会隔离**这些文件。请添加排除项:
```
# 以管理员身份运行 PowerShell
Add-MpPreference -ExclusionPath "C:\path\to\redteam-toolkit"
```
## 设置
```
pip install -r requirements.txt
```
## 完整工具包图谱
```
redteam-toolkit/
│
├── core/ ← Session management + automation
│ ├── session.py ★ Engagement state tracker (all findings → JSON)
│ └── orchestrator.py ★ Full recon pipeline, auto-chains tools
│
├── recon/ ← Information gathering
│ ├── port_scanner.py Multi-threaded TCP scanner + banners
│ ├── subdomain_enum.py DNS brute-force subdomain discovery
│ ├── dir_fuzzer.py Web directory/file fuzzer
│ ├── waf_detector.py ★ WAF fingerprint + bypass suggestions
│ └── tech_fingerprint.py ★ Tech stack ID → CVE mapping
│
├── exploitation/ ← Vulnerability exploitation
│ ├── sqli_tester.py Error/boolean/time-based SQLi detector
│ ├── ssh_brute.py SSH credential brute-forcer
│ └── lfi_tester.py ★ LFI + PHP wrappers + log poisoning
│
├── post_exploit/ ← Post-compromise actions
│ ├── hash_tools.py Hash ID + dictionary cracker
│ └── privesc_linux.py ★ Full Linux privesc audit + GTFOBins
│
├── social_eng/ ← Social engineering
│ └── pretext_builder.py ★ Cialdini-based SE pretext generator
│
├── osint/ ← Open source intelligence
│ └── email_osint.py SMTP verify + SPF/DMARC + breach check
│
├── utils/ ← Support tools
│ ├── payload_gen.py Reverse shell one-liners (12 shell types)
│ ├── smart_passwords.py ★ OSINT-aware password generator
│ └── opsec_advisor.py ★ OPSEC risk scoring + pre-flight checklists
│
├── engagements/ ← Auto-created session JSON files
├── wordlists/
│ └── README.md Where to download SecLists
└── requirements.txt
```
★ = 本工具包独有(不在 Metasploit/Empire/reconftw 中)
## Kill Chain → 脚本映射
```
RECONNAISSANCE
└─ Port scan → recon/port_scanner.py
└─ Subdomain enum → recon/subdomain_enum.py
└─ Dir fuzzing → recon/dir_fuzzer.py
└─ Tech stack → recon/tech_fingerprint.py
└─ WAF detection → recon/waf_detector.py
└─ Email OSINT → osint/email_osint.py
└─ [ALL IN ONE] → core/orchestrator.py ← start here
INITIAL ACCESS
└─ SSH brute → exploitation/ssh_brute.py
└─ SQLi → exploitation/sqli_tester.py
└─ LFI / RCE → exploitation/lfi_tester.py
└─ Social eng → social_eng/pretext_builder.py
COMMAND & CONTROL
└─ Reverse shell → utils/payload_gen.py
CREDENTIAL ACCESS
└─ Hash cracking → post_exploit/hash_tools.py
└─ Smart wordlist → utils/smart_passwords.py
PRIVILEGE ESCALATION
└─ Linux privesc → post_exploit/privesc_linux.py
```
## 快速入门工作流
### 新演练 — 从这里开始
```
# 启动全自动侦察 pipeline
python core/orchestrator.py -t 192.168.1.10 --domain target.local
# 在进行任何嘈杂操作前检查你的 OPSEC 风险
python utils/opsec_advisor.py --check port_scan
python utils/opsec_advisor.py --checklist pre-engagement
# 扫描后查看 engagement session
python core/session.py --list
python core/session.py --load engagements/session_.json --report
```
### Web 应用演练
```
# 1. 首先检查 WAF
python recon/waf_detector.py -u http://target.com --active
# 2. Fingerprint tech stack
python recon/tech_fingerprint.py -u http://target.com --deep
# 3. Fuzz 隐藏路径(使用有针对性的 wordlist,而不是 1M 列表)
python recon/dir_fuzzer.py -u http://target.com -w wordlists/dirs.txt -x php,html,bak
# 4. 测试 SQLi
python exploitation/sqli_tester.py -u "http://target.com/item?id=1"
# 5. 测试 LFI
python exploitation/lfi_tester.py -u "http://target.com/page?file=home" --wrappers
```
### 社会工程学演练
```
# 1. 在目标上构建 email OSINT
python osint/email_osint.py -e cto@target.com --smtp-verify
# 2. 生成针对目标的密码列表以备后用
python utils/smart_passwords.py --company "AcmeCorp" --name "John Smith" \
--username jsmith --context "IT,security,acme" --output wordlist_acme.txt
# 3. 选择并自定义 pretext
python social_eng/pretext_builder.py --list-roles
python social_eng/pretext_builder.py --role it_helpdesk --company "AcmeCorp"
# 4. 评估你的 pretext 质量
python social_eng/pretext_builder.py --analyse
```
### 权限沦陷后的 Linux 操作
```
# 将 script 传输到被攻陷的 host
# scp post_exploit/privesc_linux.py user@target:/tmp/
# 运行 privesc 审计
python3 /tmp/privesc_linux.py
# 快速模式(仅包含最高价值的检查)
python3 /tmp/privesc_linux.py --quick
```
## 脚本参考
### `core/session.py` ★
演练状态追踪器。其他所有脚本都可以向其记录日志。可生成报告。
```
python core/session.py --new --target 192.168.1.10 --name "Lab Engagement"
python core/session.py --list
python core/session.py --load engagements/session_20240608_192_168_1_10_abc12345.json --report
```
**在你的脚本中导入:**
```
from core.session import Session
s = Session.load_or_create(target="192.168.1.10")
s.log_port(22, "open", "SSH")
s.log_finding("SQLi", "http://target/item?id=1", severity="HIGH")
s.log_credential("admin", "password123", service="ssh")
s.save()
```
### `core/orchestrator.py` ★
自动化全方位侦察 pipeline。执行端口扫描 → HTTP 分析 → 目录 fuzz → 子域名枚举。
```
python core/orchestrator.py -t 192.168.1.10
python core/orchestrator.py -t target.com --domain target.com --aggressive
python core/orchestrator.py -t 192.168.1.10 --skip-fuzz --skip-subs
```
### `recon/waf_detector.py` ★
WAF 指纹识别 + 绕过技术建议。
```
python recon/waf_detector.py -u http://target.com
python recon/waf_detector.py -u http://target.com --active # sends attack probes
python recon/waf_detector.py -u http://target.com --active --verbose
```
### `recon/tech_fingerprint.py` ★
识别 Web 技术栈并映射到 CVE。
```
python recon/tech_fingerprint.py -u http://target.com
python recon/tech_fingerprint.py -u http://target.com --deep # checks for .env, .git, etc.
python recon/tech_fingerprint.py -u http://target.com --json # machine-readable output
```
### `exploitation/lfi_tester.py` ★
LFI 包含目录遍历深度、编码绕过、PHP wrapper、日志污染检测。
```
python exploitation/lfi_tester.py -u "http://target.com/page?file=home"
python exploitation/lfi_tester.py -u "http://target.com/page?file=home" --depth 8
python exploitation/lfi_tester.py -u "http://target.com/page?file=home" --wrappers
python exploitation/lfi_tester.py -u "http://target.com/page?file=home" --os windows
```
### `post_exploit/privesc_linux.py` ★
全面的自动化 Linux 提权审计。在被攻陷的 host 上运行。
```
python3 privesc_linux.py
python3 privesc_linux.py --quick # fast: sudo/SUID/kernel only
python3 privesc_linux.py --output /tmp/report.txt
```
检查项:内核漏洞利用 · sudo NOPASSWD · SUID + GTFOBins · cron jobs ·
可写的 /etc/passwd · capabilities · LD_PRELOAD · Docker 逃逸
### `utils/smart_passwords.py` ★
感知 OSINT 的密码生成器。生成针对特定目标的字典。
```
# 来自公司 OSINT
python utils/smart_passwords.py --company "AcmeCorp" --domain acme.com \
--output acme_wordlist.txt
# 来自个人 OSINT(LinkedIn 目标)
python utils/smart_passwords.py --name "John Smith" --username jsmith \
--birthday 1990 --context "labrador,mumbai,ACM" --output john_wordlist.txt
# 然后输入到 brute force
python exploitation/ssh_brute.py -t 192.168.1.10 -u jsmith -w john_wordlist.txt
```
### `utils/opsec_advisor.py` ★
OPSEC 风险评分。在执行任何技术之前对其进行评分。
```
# 按名称评估 technique
python utils/opsec_advisor.py --check ssh_brute
python utils/opsec_advisor.py --check port_scan
python utils/opsec_advisor.py --check-all # noise score table for all techniques
# 评估原始命令
python utils/opsec_advisor.py --rate "nmap -sV -A -p- 192.168.1.0/24"
# Pre-flight 检查清单
python utils/opsec_advisor.py --checklist pre-engagement
python utils/opsec_advisor.py --checklist pre-exploit
python utils/opsec_advisor.py --checklist post-compromise
```
### `social_eng/pretext_builder.py` ★
生成完整的 SE 借口:电话话术、电子邮件模板、Cialdini 分析。
```
python social_eng/pretext_builder.py # overview
python social_eng/pretext_builder.py --list-roles
python social_eng/pretext_builder.py --role it_helpdesk --company AcmeCorp
python social_eng/pretext_builder.py --role vendor --target-name "Sarah"
python social_eng/pretext_builder.py --role recruiter
python social_eng/pretext_builder.py --role it_audit
python social_eng/pretext_builder.py --analyse # rate your own pretext
```
可用借口:`it_helpdesk` · `vendor` · `recruiter` · `it_audit`
## OPSEC 快速参考
| 技术 | 噪音 | 生成的日志 |
|-----------|-------|---------------|
| OSINT (被动) | 5/100 | 无 |
| 子域名 DNS 爆破 | 30/100 | DNS 服务器日志 |
| 端口扫描 (谨慎) | 55/100 | 防火墙/IDS 日志 |
| 目录 fuzzing | 60/100 | Web access.log |
| SQLi 测试 | 65/100 | WAF 告警,应用日志 |
| LFI 测试 | 40/100 | Web 日志 |
| SSH 暴力破解 | 80/100 | auth.log, fail2ban |
| 反向 shell | 85/100 | EDR,防火墙,进程日志 |
**经验法则:** 在执行任何操作之前,务必先运行 `opsec_advisor.py --check <技术>`。
## 练习环境
| 平台 | 最适合 |
|----------|----------|
| TryHackMe — Jr Pentester / Red Teaming 路径 | 结构化学习 |
| HackTheBox | 真实机器,实际中的 CVE |
| PortSwigger Web Academy | SQLi, LFI, XSS, SSRF — 免费,在线最佳实验室 |
| DVWA (Docker) | 涵盖所有 OWASP 漏洞的本地 Web 应用 |
| Metasploitable2 | 满载漏洞的本地 Linux 虚拟机 |
| VulnHub | 可下载的虚拟机 |
```
# 在本地启动 DVWA:
docker run -d -p 80:80 vulnerables/web-dvwa
```
## 学习路径
```
Month 1 → Recon : orchestrator + port_scanner + dir_fuzzer + opsec_advisor
Month 2 → Web : waf_detector + tech_fingerprint + sqli_tester + lfi_tester
Month 3 → Access : ssh_brute + smart_passwords + payload_gen
Month 4 → Post : hash_tools + privesc_linux
Month 5 → SE : pretext_builder + email_osint
Month 6 → Full : complete HTB machines, write engagement reports
```
## 许可证
MIT — 见 [许可证](LICENSE)。教育/作品集项目;请负责任地使用,且仅限于对你被授权测试的系统使用。
标签:AI合规, ESC4, OSINT, Python, Web报告查看器, 协议分析, 域名收集, 安全测试, 实时处理, 攻击性安全, 攻击编排, 无后门, 权限提升, 逆向工具