Ivandiaztnd/thor-autorecon

GitHub: Ivandiaztnd/thor-autorecon

一款自主式七阶段攻击面侦察框架,集多源 OSINT、智能规避扫描、CVE 关联与风险评分于一体,自动输出多格式报告。

Stars: 0 | Forks: 0

# THOR-autorecon ``` · ' · . ' · . ' · . ' · . ' · ' - T H O R F R A M E W O R K - ' · ' · . ' · . ' · . ' · . ' · ████████╗██╗ ██╗ ██████╗ ██████╗ ╚══██╔══╝██║ ██║██╔═══██╗██╔══██╗ ██║ ███████║██║ ██║██████╔╝ ██║ ██╔══██║██║ ██║██╔══██╗ ██║ ██║ ██║╚██████╔╝██║ ██║ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ┌─────────────────────┐ │ THREAT HUNTING & │ │ OFFENSIVE RECON │ │ AUTO MODULE v1.0 │ └─────────────────────┘ ``` **THOR-autorecon** 是一个自主的、模块化的 Python 框架,用于被动和主动侦察以及漏洞映射。在其被动阶段,它从不直接接触目标——所有主动扫描均通过可配置的规避策略和分布式虚拟接口执行。 专为需要**免干预、智能侦察流水线**并能适应目标及从先前扫描中学习的安全研究人员、红队成员和渗透测试人员而设计。 ## 实时演示 — 示例报告 **[→ 查看实时 HTML 报告](https://ivandiaztnd.github.io/thor-autorecon/example-report-scanme.nmap.org.html)** — 200 个 CVE · 风险评分 CRÍTICO 3898 分 · 运行耗时 19 分钟 ## 截图 **1 — 启动:ASCII 横幅,工具检测(15 个可用工具),阶段 0 被动侦察 — whois 解析 Akamai/Linode,启动多源 OSINT** ![启动横幅和工具检测](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/c0e963de0d114834.png) **2 — 阶段 0 OSINT:crt.sh、Whois 邮箱提取 (ip-admin@akamai.com, abuse@linode.com)、DNS 暴力破解 → 21 个活动子域名 (www, mail, ftp, ssh, admin...)、解析出 2 个 IP、发现 4 个邮箱** ![OSINT 阶段 0 结果](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/72cd6444af114836.png) **3 — 阶段 1:macvlan 轮换 (thor0/thor1/thor2,独立的 MAC/IP)、RustScan 全端口扫描 → 5 个端口 (21/ftp, 22/ssh, 80/http, 9929, 31337),阶段 2 指纹识别,阶段 3 决策引擎选择 14 个 NSE 脚本,阶段 4a CVE 洪水开始 (CVE-2023-38408 CVSS:9.8)** ![阶段 1 macvlan RustScan 阶段 3 CVEs](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/b66cceeeba114838.png) **4 — 阶段 4a 继续:来自 NSE+vulners 的 CVE 洪水 — 混合了 2024/2023/2022/2021 年份的 CVE,实时显示 CVSS 9.8、9.1、9.0、8.3、8.1、7.5 评分** ![CVE 洪水 高 CVSS 2024 2023](https://raw.githubusercontent.com/Ivandiaztnd/thor-autorecon/main/docs/screenshots/4.png) **5 — 阶段 4b Vulscan(8 个离线数据库:cve, exploitdb, openvas, osvdb, scipvuldb, securityfocus, securitytracker, xforce)→ 113 个 CVE,阶段 5 针对性工具 (WhatWeb, Nikto, Gobuster 10 条路径, Nuclei, FTP 匿名检查),阶段 6 风险评分 CRÍTICO 3898 分,丰富的终端表格:端口 + 服务 + 发现结果** ![阶段 4b vulscan 阶段 5 工具 阶段 6 风险评分 富表格](https://raw.githubusercontent.com/Ivandiaztnd/thor-autorecon/main/docs/screenshots/5.png) **6 — CVE 列表结束(vulscan 离线数据库,带有 NVD 链接的 1999-2001 年 CVE),风险评级面板 CRÍTICO 3898 分 — CVEs:200,发现结果:8,工具:6,阶段 7 报告生成 → MD/TXT/JSON/HTML 输出路径,扫描完成** ![CVE 列表结束 风险评级面板 阶段 7 报告生成](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/5805cb1501114839.png) **7 — 富文本 CVE 表格:红色的 高 CVSS 条目,包含 CVSS 评分和直接的 NVD 链接 (CVE-2021-26691 9.8, CVE-2018-1312 9.8, CVE-2024-40898 9.1, CVE-2025-58098 8.3, CVE-2025-59775 7.5...)** ![富文本 CVE 表格 NVD 链接](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/e9b1ad5a19114841.png) **8 — 完整 OSINT 摘要:DNS-brute + DNS-extended 来源,21 个子域名,2 个 IP,建议端口 [80,443,8080,8443,22,21,25,3389],4 个邮箱,Hallazgos: Sí — 继续扫描** ![完整 OSINT 摘要](https://raw.githubusercontent.com/Ivandiaztnd/thor-autorecon/main/docs/screenshots/8.png) ## 功能特点 - **7 阶段自主流水线** — 从被动 OSINT 到风险评分的 HTML/JSON/Markdown 报告,全自动化 - **自适应记忆系统** — 学习跨扫描中针对每种服务类型最有效的工具和技术 - **多源 OSINT** — crt.sh(无需密钥)、SecurityTrails、Shodan、Censys、DNS 扩展、Whois 邮箱提取 - **11 种规避策略** — SYN、TCP Connect、分片、诱饵、源端口欺骗、TTL 操作、macvlan 接口轮换等 - **智能决策引擎** — 根据发现的服务动态选择 NSE 脚本、Web 审计工具和专用工具 - **CVE 关联** — 将发现结果与 NVD、ExploitDB、VulDB、MITRE、OpenVAS、OSVDB、SecurityFocus 和 SecurityTrails 进行交叉引用 - **丰富的终端仪表板** — 通过 `rich` 实时显示包含端口/服务/CVE 数据的表格 - **多格式报告** — HTML(带有风险评分仪表)、JSON、Markdown 和纯文本 - **自动安装** — 检测缺失的工具,并为 RustScan、Nuclei、WPScan、enum4linux、vulscan NSE 提供 APT 及自定义安装程序 ## 流水线概述 ``` Phase 0 — Passive recon + OSINT └── whois, dig, crt.sh, DNS extended, SecurityTrails, Shodan, Censys └── Extracts: subdomains, IPs, open ports, CVEs, emails, org info, technology stack Phase 1 — Port scanning (adaptive) └── RustScan (if available) → nmap confirmation └── 11 fallback strategies: SYN, TCP Connect, forced ports, stealth/fragmented, source port :53/:80, decoy (RND:5), TTL+padding, UDP, ACK, slow T1 └── macvlan virtual interface rotation for distributed scanning identity Phase 2 — Service fingerprint + OS detection └── nmap -sV -O --version-intensity 7 └── Enriches port data with version strings and OS guesses Phase 3 — Decision engine └── Classifies ports into: web, smb, ssh, ftp, db, ssl, voip, rdp, smtp, telnet, redis, mongodb — per-service NSE script selection └── Integrates OSINT data (known ports, detected tech) to enrich scan plan └── Flags: WordPress → WPScan, SSL certs → ssl-heartbleed/ssl-poodle, old OpenSSH → sshv1, Telnet exposed → CRÍTICO finding Phase 4a — NSE vuln scan └── nmap --script vuln,exploit,vulners + service-specific scripts └── CVEs parsed with CVSS scores, exploit links flagged Phase 4b — Vulscan (offline multi-DB) └── vulscan.nse against: cve.csv, exploitdb.csv, openvas.csv, osvdb.csv, scipvuldb.csv, securityfocus.csv, securitytracker.csv, xforce.csv └── Exploit entries score +30 pts each Phase 4c — Memory fallback └── If Phases 4a/4b yield 0 CVEs, queries ThorMemory for effective recipes from previous scans against same service types Phase 5 — Targeted tool execution └── Web: nikto, gobuster, whatweb, sqlmap, WPScan (WordPress) └── SMB/AD: smbclient, enum4linux └── SSL: sslscan └── Credentials: hydra (recon-only, no destructive actions) └── General: nuclei (template-based) └── Masscan for additional coverage Phase 6 — Risk scoring └── Additive scoring model: Base exposure (critical ports open): +5 pts each CVE found: +10 pts each CVE with public exploit: +30 pts each CVE from OSINT sources: +10 pts each Telnet exposed: +40 pts flat └── Levels: INFORMATIVO (0-9) / BAJO (10-39) / MEDIO (40-79) / ALTO (80-149) / CRÍTICO (150+) Phase 7 — Report generation └── HTML: risk gauge, score breakdown, ports table, CVE list, findings, tech stack pills, tools executed, OSINT section └── JSON: full machine-readable output └── Markdown: structured report for documentation pipelines └── TXT: plain text for logging and grep ``` ## OSINT 来源 | 来源 | 是否需要 Key | 提取数据 | |--------|-------------|----------------| | crt.sh | 否 | 子域名、SSL 证书、颁发者 | | DNS 扩展 | 否 | A、MX、NS、TXT、AAAA 记录 | | Whois | 否 | 邮箱、组织名称、注册人 | | SecurityTrails | 可选(免费层) | 历史 DNS、子域名 | | Shodan | 可选(免费层) | 开放端口、Banners、CVEs、蜜罐标志、ASN | | Censys | 可选(免费层) | 服务、TLS 数据、软件版本 | API 密钥存储在 `/etc/thor/osint_keys.json` (chmod 600)。交互式配置: ``` python3 thor-osint.py --setup-keys ``` 如果没有密钥,THOR 仍然会在主动扫描之前被动运行 crt.sh + DNS + Whois。 ## 规避技术(阶段 1) | 策略 | 方法 | |----------|--------| | RustScan 全范围 | 1-65535,可配置 ulimit | | RustScan 反防火墙 | ulimit 500,超时 4000ms | | 普通 SYN 扫描 | -sS -Pn | | TCP Connect(绕过防火墙) | -sT -Pn | | 强制关键端口 | 30 个硬编码的高价值端口 | | 隐蔽分片 | -f --mtu 24 --data-length 32 | | 源端口 :53 | DNS 端口欺骗 | | 源端口 :80 | HTTP 端口欺骗 | | 诱饵扫描 | -D RND:5 | | TTL + 填充 | --ttl 128 --data-length 48 | | UDP 服务 | DNS, SNMP, NTP, TFTP, NetBIOS | | ACK 扫描 | 防火墙规则映射 | | 慢速 T1 | --scan-delay 2s | | macvlan 轮换 | 具有独立 MAC/IP 的虚拟接口,用于分布式身份 | ## 自适应记忆 THOR 在 `/var/log/thor_intel/.thor_memory.json` 中维护一个持久的 JSON 记忆,用于跟踪: - 已执行的总扫描次数 - 每个服务的工具有效性(命中与未命中) - 每种工具/服务组合的 CVE 产出率 - 用于未来复用的有效命令提示 在每次扫描中,阶段 4c 会查询记忆:如果主动扫描未产生 CVE,它将针对检测到的服务类型重放历史上最有效的命令。 ## 环境要求 ### 系统 - Debian/Ubuntu Linux(推荐 Kali) - Python 3.8+ - Root 或 sudo 权限(原始套接字操作所需) ### Python 依赖 ``` rich ``` ### 工具(首次运行时如果缺失将自动安装) **关键(必需):** - `nmap` - `curl` - `git` - `python3` **可选(交互式安装):** - `rustscan` — 超快速端口扫描器(自定义安装程序,x86_64/arm64/armhf) - `nikto` — Web 漏洞扫描器 - `gobuster` — 目录暴力破解 - `whatweb` — Web 技术指纹识别 - `hydra` — 暴力破解(仅侦察模式) - `sqlmap` — SQL 注入检测 - `smbclient` — SMB 共享枚举 - `enum4linux` — SMB/AD 枚举(Portcullis Labs 安装程序) - `sslscan` — SSL/TLS 审计 - `masscan` — 快速端口扫描器 - `nuclei` — 基于模板的漏洞扫描器 (ProjectDiscovery) - `wpscan` — WordPress 扫描器(gem 安装程序) - `whois`、`dig`、`nbtscan`、`jq` - `vulscan NSE` — 离线多数据库 nmap 脚本(从 GitHub 自动克隆) ## 安装 ``` git clone https://github.com/ivandiaz/thor-autorecon.git cd thor-autorecon pip3 install rich ``` 无需进一步设置。THOR 将在首次运行时检测缺失的工具并提供安装选项。 ## 用法 ``` # 基础扫描 sudo python3 thor-auto.py # 示例 sudo python3 thor-auto.py 45.33.32.156 sudo python3 thor-auto.py scanme.nmap.org sudo python3 thor-auto.py 192.168.1.0/24 # 自定义输出目录 sudo python3 thor-auto.py scanme.nmap.org --output /tmp/myscan # OSINT 模块独立运行 python3 thor-osint.py scanme.nmap.org # 配置 OSINT API 密钥 python3 thor-osint.py --setup-keys # 显示已配置的密钥 python3 thor-osint.py --show-keys ``` ## 输出结构 ``` /var/log/thor_intel/__/ ├── scan.log # Full execution log with timestamps ├── .html # Main HTML report (risk gauge + full findings) ├── .json # Machine-readable full output ├── .md # Markdown report ├── .txt # Plain text report ├── fase0_pasivo/ │ ├── whois.txt │ └── dig.txt ├── fase0_osint/ │ └── osint_result.json # Full OSINT data (subdomains, IPs, CVEs, emails) ├── fase1_ports/ │ ├── ports.txt │ ├── ports.xml │ └── rustscan.txt ├── fase2_services/ │ └── services.txt ├── fase4_nse/ │ ├── vulns.txt │ ├── vulns.xml │ ├── vulscan.txt │ └── vulscan_exploits.txt └── fase5_*/ # Per-tool output directories ``` ## 风险评分模型 ``` Score range Level Description ────────────────────────────────────────────────────── 0 – 9 INFORMATIVO No significant exposure 10 – 39 BAJO Low exposure, limited attack surface 40 – 79 MEDIO Moderate risk, review recommended 80 – 149 ALTO High risk, immediate attention required 150+ CRÍTICO Critical exposure, active exploit risk ────────────────────────────────────────────────────── Scoring contributors: +5 pts Each critical port exposed (22, 25, 80, 139, 443, 445, 3306, 3389…) +10 pts Each CVE found (any source) +30 pts Each CVE with confirmed public exploit (*EXPLOIT*) +10 pts Each CVE from external OSINT sources (Shodan, Censys) +40 pts Telnet exposed (flat penalty) ``` ## 关联的 CVE 来源 - **NVD / vulners** — 通过 nmap NSE `vulners` 脚本获取 - **ExploitDB** — 通过 vulscan + vulners 获取,解析 exploit 标志 - **MITRE CVE** — 通过 vulscan 离线数据库获取 - **VulDB** — 通过 vulscan 离线数据库获取 - **OpenVAS** — 通过 vulscan 离线数据库获取 - **OSVDB** — 通过 vulscan 离线数据库获取 - **SecurityFocus** — 通过 vulscan 离线数据库获取 - **SecurityTracker** — 通过 vulscan 离线数据库获取 - **Shodan** — 通过 OSINT 模块获取(每个主机的 CVEs) - **Censys** — 通过 OSINT 模块获取(软件版本关联) ## 经过验证的测试目标 THOR 已针对公开的合法目标进行了测试: - `scanme.nmap.org` — Nmap 官方测试主机 - 其他公开免费扫描目标 (testphp.vulnweb.com 等) **所有扫描均产出了带有 CVSS 评分和多数据库关联的 CVE 发现结果。** ## 项目结构 ``` thor-autorecon/ ├── thor-auto.py # Entry point — arg parsing, target resolution, orchestration ├── thor_deps.py # Dependency management, tool detection, auto-install logic, │ # color system, utility functions (cmd, status, sanitize) ├── thor_phases.py # ThorMemory + ThorAuto class with all 7 phases, │ # report generation (HTML/JSON/MD/TXT), rich dashboard ├── thor-osint.py # OSINT module — crt.sh, Shodan, Censys, SecurityTrails, │ # DNS extended, Whois — importable or standalone └── requirements.txt # Python dependencies ``` ## 架构说明 **thor-auto.py** 是一个轻量级入口点(约 30 行)。它处理参数解析、目标解析(主机名 → IP),并将所有内容委托给 `ThorAuto`。 **thor_deps.py** 管理完整的依赖生命周期:检测 (`has_tool`)、APT 批量安装,以及为 APT 中不存在的工具(RustScan, Nuclei, WPScan, enum4linux, vulscan NSE)提供自定义安装程序。它还导出所有模块共享的实用工具:`cmd()`、`status()`、`is_local()`、`sanitize_target()`、`sanitize_name()`、颜色类 `C` 和 `print_banner()`。 **thor_phases.py** 包含 `ThorMemory`(自适应扫描历史)和 `ThorAuto`(完整引擎)。每个阶段方法都是独立的,并将其输出写入 `/var/log/thor_intel//` 下的专用子目录中。阶段 3 的决策引擎读取主动扫描结果和 OSINT 数据,以构建组合攻击计划。 **thor-osint.py** 是完全独立的 — 可以独立运行,或通过 `importlib` 由 `ThorAuto.phase0_passive()` 导入。它在 `/etc/thor/osint_keys.json` 中管理 API 密钥,并返回一个供主流水线使用的 `OsintResult` 对象。 ## 作者 **Iván Alberto Díaz** 高级 IT 工程师 | 红队从业者 | LPIC-1 | LPIC-2 阿根廷 布宜诺斯艾利斯 [linkedin.com/in/ivan-alberto-diaz-0b345410](https://linkedin.com/in/ivan-alberto-diaz-0b345410) ## 相关项目 - **THOR Enterprise** — 完整的红队、威胁狩猎与攻击性侦察引擎框架,带有 Web 仪表盘、多层高管报告 (CEO/CFO, SOC/IT, 技术), Flask/AJAX 前端。*(闭源)* - **OSIRIS-AI** — 由本地 LLMs (通过 Ollama 提供 phi3, phi4, dolphin) 驱动的 AI 辅助自主渗透测试框架。零云端依赖,可在任何硬件上运行。*(开发中)* ## 许可证 GNU General Public License v3.0 — 详见 [LICENSE](LICENSE) 本程序为自由软件:您可以依据自由软件基金会发布的 GNU 通用公共许可证条款(许可证的第 3 版,或您选择的任何后续版本)对其进行重新分发和/或修改。
标签:CTI, CVE关联, ESC4, ESC6, GitHub, GPT, OSINT, Python框架, Snort++, Talos规则, TDOA, TGT, 主动扫描, 侦察框架, 反取证, 多源情报, 安全测试, 安全评估, 实时处理, 情报收集, 插件系统, 攻击性安全, 攻防演练, 数据展示, 漏洞研究, 漏洞管理, 红队, 网络安全, 自动化侦察, 自适应侦察, 被动扫描, 资产测绘, 逆向工具, 隐私保护