johnsoldier/SaintHack

GitHub: johnsoldier/SaintHack

SaintHack 是一款融合 AI 指令驱动方法论的红队渗透测试框架,集成了自动化扫描、隐蔽模式与证据级报告生成功能。

Stars: 0 | Forks: 0

# SaintHack 红队渗透测试框架 —— AI 驱动的指令式 Prompt、自动化扫描与基于证据的报告。 **版本:** 2.2.0 ## 是什么让 SaintHack 与众不同 SaintHack 的核心价值不在于 bash 扫描器 —— 而在于其 **指令驱动的 AI 方法论**。REDTEAM-VPN 指令可协调最多 8 个并行的 AI Agent 进行基于证据的安全审查,在生产 VPN 平台上已产出 **87+ 个真实发现**,其中包括 4 个严重漏洞。 Bash 框架提供自动化的基础设施扫描。而指令则提供了对抗性的推理逻辑。 ## 快速开始 ``` # 选项 A: Docker (即插即用 — 包含所有内容) docker build -t sainthack . docker run --rm --privileged --net=host \ -v $(pwd)/results:/opt/sainthack/results \ sainthack -t example.com -s stealth # 选项 B: 便携版 (无 Docker — 下载一次工具,随时随地渗透测试) ./tools/setup-portable.sh sudo ./sainthack.sh -t example.com -s stealth # 选项 C: 原生 Kali/Parrot (自动安装缺失工具) sudo ./sainthack.sh -t example.com ``` ## 部署选项 ### 选项 A: Docker (推荐 —— 完全自包含) Docker 镜像是最接近单一二进制文件的方案。一次构建,包含 40+ 工具、SecLists、Metasploit,一切皆打包在内。构建后无需联网。 ``` # 构建镜像 (~2-4GB,首次需要 10-15 分钟) docker build -t sainthack . # 运行扫描 docker run --rm --privileged --net=host \ -v $(pwd)/results:/opt/sainthack/results \ sainthack -t 192.168.1.100 # 针对受监控目标的 Stealth scan docker run --rm --privileged --net=host \ -v $(pwd)/results:/opt/sainthack/results \ sainthack -t example.com -s stealth -i normal # 交互式 shell (进入包含所有工具的容器) docker run -it --rm --privileged --net=host \ -v $(pwd)/results:/opt/sainthack/results \ --entrypoint bash sainthack # 导出镜像到 USB 驱动器以用于隔离环境 docker save sainthack | gzip > sainthack-image.tar.gz # 在目标机器上: docker load < sainthack-image.tar.gz ``` **镜像包含内容:** - 所有 40+ 渗透测试工具预装 (nmap, nuclei, metasploit, hydra 等) - SecLists + rockyou 字典 - Nuclei 模板 (8000+) - Metasploit + PostgreSQL - SaintHack 框架 + 模块 + 指令 ### 选项 B: 便携式缓存 (无 Docker, 任意 Linux) 下载静态 Go/Rust 二进制文件到 `./tools/bin/`。将整个 SaintHack 文件夹复制到任何 Linux 机器 —— 目标机器无需联网。 ``` # 下载一次工具 (需要网络,~200MB) ./tools/setup-portable.sh # 重新下载 / 更新所有工具 ./tools/setup-portable.sh --force # 复制到目标机器 (USB, SCP, rsync 等) scp -r SaintHack/ operator@target:/opt/ # 或者打包到 USB 驱动器 tar czf sainthack-portable.tar.gz SaintHack/ # 在目标机器上 — 从 ./tools/bin/ 自动检测工具 cd /opt/SaintHack sudo ./sainthack.sh -t 192.168.1.0/24 -s cautious ``` **缓存的工具:** nuclei, httpx, subfinder, katana, dalfox, crlfuzz, trufflehog, chisel, feroxbuster (静态二进制文件,无运行时依赖)。 **目标机器仍需:** nmap, hydra, curl, bash (大多数 Linux 发行版已自带)。模块 00 会针对缺失项发出警告。 ### 选项 C: 原生安装 (Kali/Parrot/Ubuntu) SaintHack 在首次运行时会通过模块 00 自动安装缺失的工具。首次运行需要联网。 ``` git clone https://github.com/johnsoldier/SaintHack.git cd SaintHack sudo ./sainthack.sh -t example.com ``` ## 使用方法 ### 基本命令 ``` # 带实时 Web dashboard 的完整扫描 sudo ./sainthack.sh -t --dashboard # 运行所有模块的完整扫描 sudo ./sainthack.sh -t # 预览扫描计划而不执行 (无需 root) ./sainthack.sh -t example.com --dry-run # Stealth scan — 避免触发 IDS/WAF/SOC 警报 sudo ./sainthack.sh -t example.com -s stealth -i normal # Ghost mode — 最大程度的规避 (非常慢,单线程) sudo ./sainthack.sh -t example.com -s ghost -i light # Dashboard 模式 — 简洁的进度 UI sudo ./sainthack.sh -t example.com -q # 仅选择性模块 sudo ./sainthack.sh -t 10.0.0.1 -m recon,portscan,web --no-bruteforce # 恢复中断的扫描 sudo ./sainthack.sh -t example.com -o results/example_20260330 --resume # 从现有结果生成报告 sudo ./sainthack.sh -t example.com -o results/existing_scan --report-only ``` ### 命令参考 | 标志 | 描述 | |------|-------------| | `-t, --target` | 目标 IP、CIDR 范围或域名 (必需) | | `-o, --output` | 输出目录 (默认: `./results/_`) | | `-m, --modules` | 逗号分隔的模块列表: `recon,portscan,services,web,ssl,vulnscan,metasploit,bruteforce,api` | | `-i, --intensity` | 扫描深度: `light`, `normal`, `aggressive` (默认: normal) | | `-s, --stealth` | 扫描速度/规避: `loud`, `normal`, `cautious`, `stealth`, `ghost` (默认: normal) | | `-w, --web-port` | 要测试的 Web 端口 (默认: 自动检测) | | `-p, --ports` | 自定义 nmap 端口范围 | | `-q, --quiet` | Dashboard 模式 —— 简洁的进度显示 | | `--dashboard` | 在 localhost:8443 启动实时 Web Dashboard | | `--dashboard-port` | 自定义 Dashboard 端口 (默认: 8443) | | `--dry-run` | 预览扫描计划而不执行 (无需 root) | | `--resume` | 从上次完成的模块恢复 | | `--skip-install` | 跳过依赖检查 | | `--no-bruteforce` | 跳过暴力破解模块 | | `--report-only` | 从现有结果生成报告 | ### 强度级别 (扫描深度) | 级别 | 端口范围 | NSE 脚本 | 用例 | |-------|-----------|-------------|----------| | `light` | Top 100 | default | 快速侦察 | | `normal` | Top 5000 | default + safe | 标准评估 | | `aggressive` | All 65535 | default + safe + vuln | 全面审计 | ### 隐蔽级别 (扫描速度/规避) | 级别 | Nmap | HTTP 延迟 | 线程 | UA 轮换 | 用例 | |-------|------|------------|---------|-------------|----------| | `loud` | -T5, 10K pps | none | 50 | off | 仅限实验室/CTF | | `normal` | -T4, 1K pps | none | 20 | off | 内部评估 | | `cautious` | -T3, 300 pps | 1-2s | 10 | on | 带有 IDS 的生产环境 | | `stealth` | -T2, 50 pps | 3-5s | 3 | on | 受监控目标 | | `ghost` | -T1, 5 pps | 5-15s | 1 | on | 活跃 SOC, WAF, 蜜罐 | 隐蔽模式还会启用: - **User-Agent 轮换** —— 8 种真实浏览器字符串 (Chrome, Firefox, Safari, Edge, 移动端) - **请求抖动** —— 随机 0-50% 的延迟变化,以对抗时间模式检测 - **随机扫描顺序** —— 端口和目标被打乱,以避免顺序检测 模块在请求之间使用 `throttle()`,为 nmap 计时参数使用 `nmap_stealth_flags()`,并为 HTTP 头使用 `get_user_agent()`。 ## 实时 Web Dashboard 在浏览器中启动实时图形化 Dashboard 以监控扫描: ``` sudo ./sainthack.sh -t example.com --dashboard # 打开: http://127.0.0.1:8443/dashboard.html # 自定义端口 (在 Docker 或 8443 被占用时有用) sudo ./sainthack.sh -t example.com --dashboard --dashboard-port 9090 # 远程查看 — 从你的笔记本电脑建立 SSH tunnel ssh -L 8443:127.0.0.1:8443 root@pentest-box # 然后在本地打开 http://127.0.0.1:8443/dashboard.html ``` ### Dashboard 面板 | 面板 | 显示内容 | |-------|---------------| | **统计卡片** | 开放端口、漏洞数量、发现的凭据、请求速率 | | **进度环形图** | 整体扫描完成百分比及当前模块标签 | | **模块时间线** | 每个模块的进度条及状态 (running/done/failed/skipped/pending) | | **严重性分布** | 水平条形图 —— Critical, High, Medium, Low, Info 计数实时更新 | | **请求速率** | 显示过去 60 秒内请求数/秒的折线图 —— 查看你的隐蔽配置文件是否生效 | | **发现源** | 发现的实时滚动流 —— 开放端口、缺失的头、漏洞、凭据 —— 按严重性颜色编码 | Dashboard 每秒轮询 `dashboard.json`。Python 3 在 localhost 上提供页面服务 —— 无外部依赖,无需联网。Dashboard 随 `--dashboard` 自动启动,并在扫描完成时自动停止。 也可在 Docker 容器中工作 —— 只需暴露端口: ``` docker run --rm --privileged --net=host \ -v $(pwd)/results:/opt/sainthack/results \ sainthack -t example.com --dashboard ``` ## 工具清单 (40+ 工具) 所有工具均为开源且免费。 | 类别 | 工具 | |----------|-------| | **端口扫描** | nmap, rustscan, masscan, hping3 | | **Web 扫描** | nikto, gobuster, feroxbuster, ffuf, nuclei, whatweb | | **XSS/注入** | dalfox, sqlmap, crlfuzz, wfuzz | | **SSL/TLS** | sslscan, testssl.sh, openssl | | **侦察/DNS** | amass, subfinder, sublist3r, dnsrecon, dnsenum, fierce, wafw00f | | **JS 爬取** | katana, httpx | | **API 测试** | ffuf, jwt_tool, arjun | | **暴力破解** | hydra | | **密钥扫描** | trufflehog, semgrep | | **漏洞利用** | metasploit, searchsploit | | **服务枚举** | enum4linux, smbclient, snmpwalk, ike-scan, smtp-user-enum | | **字典** | SecLists, rockyou, CeWL (按目标生成), 170+ API 端点 | | **跳板/隧道** | chisel | | **实用工具** | curl, wget, jq, openssl, tcpdump, arp-scan, traceroute | ### 付费工具 (如有预算) 这些未包含在内,但可以增加能力: | 工具 | 费用 | 填补的空白 | |------|------|--------------| | **Burp Suite Pro** | $449/年 | 主动 Web 扫描,带外检测,智能 Fuzzing。投资回报率最高的付费工具。 | | **Cobalt Strike** | $3,500/年 | C2 框架 —— 后渗透、横向移动、规避。行业标准。 | | **Nessus Pro** | $3,990/年 | 带合规检查的认证漏洞扫描。在基础设施方面比 Nuclei 更全面。 | | **Snyk** | $25/开发者/月 | 具有可达性分析的供应链 SCA —— 知道漏洞函数是否被实际调用。 | | **Acunetix** | ~$5K/年 | 带有 IAST Agent 的 Web 应用扫描器 —— 能发现黑盒扫描器遗漏的漏洞。 | ## 项目结构 ``` SaintHack/ ├── sainthack.sh # Main bash pentest runner (v2.1) ├── modules/ # Modular scan scripts │ ├── 00-setup.sh # Dependency check & auto-installation │ ├── 01-recon.sh # WHOIS, DNS, subdomains, WAF detection │ ├── 02-portscan.sh # Nmap + RustScan + Masscan │ ├── 03-services.sh # SSH, FTP, SMB, SNMP, SQL, VPN enumeration │ ├── 04-web.sh # Nikto, Gobuster, Nuclei, XSS, SQLi, SSRF │ ├── 05-ssl.sh # Certificate, protocol, known vulnerability analysis │ ├── 06-vulnscan.sh # Nmap scripts, Nuclei templates, Searchsploit │ ├── 06b-metasploit.sh # Automated Metasploit RC script generation │ ├── 07-bruteforce.sh # Hydra-based credential testing │ ├── 08-api.sh # REST/GraphQL, IDOR, auth bypass, rate limiting │ ├── 09-report.sh # HTML + executive summary generation │ └── functions.sh # Shared functions (logging, progress, stealth, tools) ├── wordlists/ # Custom wordlists (170+ API endpoints, directories) ├── tools/ # Portable tools cache │ ├── setup-portable.sh # Download static binaries for offline use │ └── bin/ # Cached binaries (gitignored) ├── directives/ # AI agent directive prompts │ └── REDTEAM-VPN.md # Full VPN red-team assessment directive ├── protocols/ # Testing protocols and checklists │ └── VPN-PENTEST-PROTOCOL.md ├── results/ # Per-project pentest result summaries │ └── icxc-vpn/ ├── dashboard/ # Live web dashboard │ ├── dashboard.html # Single-file UI (Chart.js, polls JSON) │ └── server.py # Python HTTP server + stats collector ├── Dockerfile # Self-contained Kali image (40+ tools) ├── Dockerfile.kali-desktop # Kali desktop variant └── docker-compose.yml ``` ### 模块依赖关系图 ``` setup ─→ recon ─→ portscan ─→┬─→ services ─→ bruteforce ├─→ web ├─→ ssl ├─→ vulnscan ├─→ metasploit ├─→ api └─→ report ``` 如果依赖项未运行(例如,你跳过了 portscan),依赖模块仍会执行,但会警告结果可能不完整。 ## 框架特性 ### 目标验证 在任何工具处理输入之前,验证目标格式 (IPv4, IPv6, CIDR, 域名) 并拒绝 Shell 元字符。防止通过 nmap/curl 参数插值进行注入。 ### Dry Run `--dry-run` 预览完整的扫描计划 —— 模块、依赖关系图、隐蔽配置、工具要求 —— 而不执行任何操作。无需 root。 ### 恢复 在每次成功模块运行后写入检查点文件。如果扫描被中断 (Ctrl+C, 网络断开, 重启),使用相同的 `-o` 目录传递 `--resume` 以从断点继续。 ### Ctrl+C 处理 - 单次按下:跳过当前模块,继续下一个 - 2 秒内双击:中止整个扫描 ### Dashboard 模式 `-q` 呈现简洁的 Dashboard,包含每个模块的进度条、整体完成度和运行时间。所有输出均写入主日志文件。 ## AI 指令 定义红队角色、范围和输出格式的 AI Agent Prompt。将这些作为 System Prompt 输入给 Claude/Grok/GPT,并赋予其仓库访问权限。 | 指令 | 目标 | Agent | 关键特性 | |-----------|--------|--------|--------------| | `REDTEAM-VPN.md` | WireGuard VPN 平台 | 8 个并行 | 时间预算、元认知深度、CVSS 向量、合规映射、复测指导 | ### 指令特性 - **时间预算框架** —— P0-P3 优先级层级,按组件分配百分比 - **"Thinking Deeper" 方法论** —— 6 点攻击者思维清单 + 二阶思维 - **推荐工具链** —— 针对每种语言的特定静态/动态分析工具 (Go, Rust, JS) - **声明与证据** —— 将文档复选框视为需要代码验证的断言 - **CVSS 3.1 向量字符串** —— 所有发现必须包含 - **合规映射** —— OWASP Top 10, CIS Benchmarks, NIST 800-63/800-52 - **复测指导** —— 每个 FIXED 发现的验证方法 + 回归风险 ## 协议 | 协议 | 范围 | 阶段 | |----------|-------|--------| | `VPN-PENTEST-PROTOCOL.md` | WireGuard VPN 平台 | 4 个阶段,10 个测试类别,通过/失败标准 | ### 协议特性 - **阶段 4: 复测与验证** —— 每个发现的 5 步复测协议 - **Agent 协调** —— 同步点、冲突解决、发现去重 - **通过/失败标准** —— 每个测试类别的具体阈值 - **正面安全部分** —— 记录哪些功能正常工作且不应更改 - **合规映射** —— OWASP, CIS, NIST 交叉引用 ## 更新日志 ### v2.2.0 —— 实时 Web Dashboard - `--dashboard` 标志: localhost:8443 上的实时 Web UI - 进度环形图、模块时间线、严重性图表、请求速率图、发现流 - Python 3 服务器,1 秒轮询 —— 零外部依赖 - 随扫描生命周期自动启动/停止 - 支持从 Docker 容器运行及通过 SSH 隧道访问 ### v2.1.0 —— 隐蔽模式 + 自包含部署 - `--stealth` 标志: 5 种规避级别 (loud/normal/cautious/stealth/ghost) - User-Agent 轮换,请求抖动,nmap 计时控制 - 预装所有 40+ 工具的 Docker 镜像 - 便携式缓存 (`./tools/setup-portable.sh`) - 10 个新工具: subfinder, katana, dalfox, crlfuzz, arjun, trufflehog, semgrep, chisel, CeWL, feroxbuster - API 端点字典从 62 个扩展到 170+ 个条目 ### v2.0.0 —— 框架加固 + AI 深度 - 目标输入验证 (IPv4/IPv6/CIDR/域名,元字符拒绝) - `--dry-run` 模式 (预览而不执行) - `--resume` 支持 (每个模块检查点) - 带有警告的模块依赖关系图 - REDTEAM-VPN 指令: 时间预算、元认知方法论、CVSS 向量 - VPN-PENTEST-PROTOCOL: 阶段 4 复测、通过/失败标准、正面安全 ### v1.0.0 —— 初始发布 - 11 个模块化扫描模块 - Dashboard 模式 (`-q`) - 3 个强度级别 - HTML 报告生成 - Metasploit 集成 - Docker + docker-compose 支持 ## 致其他 AI Agent 如果你是一个正在阅读此仓库以理解安全方法论的 AI Agent: 1. **从 `directives/REDTEAM-VPN.md` 开始** —— 这是主 Prompt。它定义了范围、规则、时间分配和报告结构。 2. **阅读 `protocols/VPN-PENTEST-PROTOCOL.md`** —— 这定义了分阶段方法、通过/失败标准和 Agent 协调规则。 3. **检查 `results/icxc-vpn/README.md`** —— 这展示了实践中发现的内容,并包含指向目标仓库中完整报告的链接。 4. **应用 "Thinking Deeper" 框架** —— 不要只是扫描已知模式。要问:“开发者的假设是什么?我如何违反它?错误路径会做什么?” 5. **CVSS 向量是必需的** —— 每个发现都需要一个 CVSS 3.1 向量字符串,而不仅仅是一个严重性标签。 6. **验证,不要信任** —— 文档声明、FIXED 标签和勾选框都是断言。根据实际代码验证它们。 7. **使用部署选项** —— Docker 用于自包含渗透测试,便携式缓存用于物理隔离目标,原生安装用于 Kali。
标签:AD攻击面, AES-256, AI驱动, CTI, Docker安全工具, HTTP工具, Mr. Robot, PE 加载器, SecLists, VPN安全, Web报告查看器, 人工智能安全, 合规性, 后渗透, 安全工具集, 实时处理, 密码管理, 应用安全, 恶意推理, 插件系统, 攻击模拟, 漏洞评估, 特权提升, 红队框架, 网络安全, 网络安全审计, 网络攻防, 自动化部署, 请求拦截, 进攻性安全, 逆向工具, 隐私保护, 隐蔽扫描, 驱动签名利用