elementalsouls/SubdomainX

GitHub: elementalsouls/SubdomainX

一款基于Python的异步子域名枚举工具,整合多源被动查询、暴力破解、排列扫描与HTTP探测,解决一次性发现大量子域的问题。

Stars: 14 | Forks: 6

``` ___ _ _ _ __ __ / __\_ _| |__ | |__ ___ _ __ ___ (_)_ __ \ \/ / /__\// | | | '_ \ | '_ \ / _ \| '_ ` _ \ | | '_ \ \ / / \/ \ |_| | |_) | | | | | (_) | | | | | || | | | |/ \ \_____/\__,_|_.__/ |_| |_|\___/|_| |_| |_|/ |_| |_/_/\_\ |__/ ``` # SubdomainX ### 专为深度侦察打造的一站式子域名枚举工具 **26 个免费 OSINT 来源** · **9 个需 API key 的来源** · **11 万词表暴力破解** · **200+ 排列组合模式** · **子域名接管检测** · **HTTP 探测与技术指纹识别** ![Python](https://img.shields.io/badge/Python-3.8%2B-blue?logo=python&logoColor=white) ![Version](https://img.shields.io/badge/version-2.0.0-green) ![License](https://img.shields.io/badge/license-MIT-orange) ![Sources](https://img.shields.io/badge/passive%20sources-35-purple) ![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey)
## 为什么选择 SubdomainX? 大多数侦察工作流需要将 4-5 个工具串联使用:`subfinder → amass → puredns → httpx → nuclei`。**SubdomainX 仅需一条命令即可替代整个工作流。** ``` python -m subdomainx target.com --deep -o results.json ``` 单一工具,零配置。涵盖被动 OSINT、暴力破解、排列组合、递归枚举、HTTP 探测、技术检测以及子域名接管检测——所有功能开箱即用。 ## 功能 ### 🔍 被动枚举 — 26 个免费来源 全部并发查询,无需任何 API key: | 类别 | 来源 | |----------|---------| | **证书透明度 (Certificate Transparency)** | crt.sh, crt.sh (identity/dedup), CertSpotter, Myssl, Racent | | **DNS 聚合器** | HackerTarget, RapidDNS, DNSRepo, BufferOver, BufferOver-TLS | | **威胁情报** | AlienVault OTX, ThreatMiner, AnubisDB, URLScan | | **网络档案馆** | Wayback Machine, CommonCrawl | | **证书数据库** | Digitorus, Riddler, FullHunt | | **子域名数据库** | SubdomainCenter, Columbus, InternetDB (Shodan 免费), SiteDossier | | **泄露与安全** | Leakix, Shrewdeye, Netlas | ### 🔑 API-Key 来源 — 9 个可选项 通过 API key 解锁更多覆盖范围(均为可选): | 来源 | 环境变量 | |--------|-------------| | VirusTotal | `VIRUSTOTAL_API_KEY` | | SecurityTrails | `SECURITYTRAILS_API_KEY` | | Shodan | `SHODAN_API_KEY` | | Censys | `CENSYS_API_KEY` (格式: `id:secret`) | | BinaryEdge | `BINARYEDGE_API_KEY` | | ProjectDiscovery Chaos | `CHAOS_API_KEY` | | Bevigil | `BEVIGIL_API_KEY` | | WhoisXML API | `WHOISXMLAPI_KEY` | | ZoomEye | `ZOOMEYE_API_KEY` | ### 💥 DNS 暴力破解 - **内置 110,000 词的词表**,涵盖常见名、基础设施、云服务、开发以及区域性模式 - **8 个 DNS resolver 池**(Google、Cloudflare、Quad9、OpenDNS、Verisign、CleanBrowsing、Alternate DNS、AdGuard),采用随机轮换以规避速率限制 - **A + AAAA + CNAME 解析** — 能够捕捉其他工具遗漏的纯 IPv6 和纯 CNAME 子域名 - **自动泛解析检测** — 查询 5 个随机的 16 字符子域名,以识别并过滤泛解析 DNS - 超时时自动重试并轮换 resolver ### 🔀 排列组合扫描 — 200+ 模式 利用 **8 个词缀类别**,从已发现的子域名生成智能组合: | 类别 | 示例 | |----------|---------| | 环境 | `dev`, `staging`, `canary`, `pentest`, `sandbox` | | 基础设施 | `api`, `redis`, `kafka`, `grafana`, `jenkins`, `k8s` | | 云服务 | `aws`, `s3`, `lambda`, `eks`, `cloudfront`, `azure` | | 地理位置 | `us-east`, `eu-west`, `fra`, `sin`, `tok` | | 访问权限 | `internal`, `partner`, `jira`, `confluence`, `wiki` | | 状态 | `backup`, `failover`, `replica`, `deprecated` | | 数据库 | `mysql`, `postgres`, `mongo`, `clickhouse`, `airflow` | | 数字 | `1`-`10`, `01`-`09`, `001`-`003` | **生成策略:** `affix-word`、`word-affix`、`affix.word`、拼接、连字符分割交换、数字后缀,以及对已发现部分的交叉组合。 ### 🔄 递归枚举 自动发现子域名的子域名(例如,从 `api.target.com` 发现 `staging.api.target.com`)。支持配置递归深度(默认:2,深度模式:3)。基于各基域名的泛解析检测,有效防止每次递归层级中出现误报。 ### 🌐 HTTP 探测与技术指纹识别 - 同时探测 **HTTP 和 HTTPS**,并跟随重定向 - 提取**网页标题**、**server headers**、**状态码** - 基于 headers 进行**技术检测**:Nginx、Apache、Cloudflare、IIS、LiteSpeed、PHP、ASP.NET、Express.js、Next.js、WordPress、Drupal、Shopify、Varnish ### ⚠️ 子域名接管检测 将发现的子域名与 **27 个已知服务指纹**进行比对: **两阶段检测:** 1. 针对已知脆弱服务的 CNAME 模式匹配 2. HTTP 响应正文指纹确认 ## 安装 ``` git clone https://github.com/elementalsouls/SubdomainX.git cd SubdomainX pip install -r requirements.txt ``` ### 前置条件 - Python 3.8+ - 依赖项:`aiohttp`, `aiodns`, `dnspython`, `requests`, `beautifulsoup4`, `rich`, `tqdm` ## 用法 ### 快速开始 ``` # 基础扫描 — passive sources + brute force python -m subdomainx target.com # 仅 passive(快速,无 brute force) python -m subdomainx target.com --no-bruteforce # 使用所有技术的 Full scan python -m subdomainx target.com --all -o results.json # 最大覆盖 — deep mode python -m subdomainx target.com --deep -o results.json ``` ### 输出格式 ``` python -m subdomainx target.com -o results.txt # Plain text (one per line) python -m subdomainx target.com -o results.json # JSON with full metadata python -m subdomainx target.com -o results.csv # CSV for spreadsheets ``` ### 进阶示例 ``` # 自定义 wordlist + 高 concurrency python -m subdomainx target.com -w /path/to/wordlist.txt -t 1000 # Passive + HTTP probing(无 brute force,快速 recon) python -m subdomainx target.com --no-bruteforce --probe # 仅 Permutations(在 passive + brute force 之上) python -m subdomainx target.com --permutations # 带自定义深度的 Recursive python -m subdomainx target.com --recursive --recursive-depth 3 # 启用 probe 的所有功能 python -m subdomainx target.com --probe --permutations --recursive -o results.json ``` ## CLI 选项 | 标志 | 默认值 | 描述 | |------|---------|-------------| | `domain` | *必填* | 指定要枚举的目标域名 | | `-o, --output` | — | 输出文件路径(`.txt`、`.json` 或 `.csv`) | | `-w, --wordlist` | 内置 11 万词 | 用于暴力破解的自定义词表 | | `-t, --concurrency` | `500` | 并发 DNS 查询数 | | `--no-bruteforce` | — | 跳过 DNS 暴力破解(仅限被动模式) | | `--permutations` | — | 启用排列组合/变体扫描 | | `--recursive` | — | 启用递归子域名枚举 | | `--recursive-depth` | `2` | 最大递归深度 | | `--probe` | — | 探测 HTTP/HTTPS + 解析 DNS + 接管检测 | | `--all` | — | 启用所有技术(排列组合 + 递归 + 探测) | | `--deep` | — | 深度模式:`--all` + 并发 1000 + 递归深度 3 | | `-v, --version` | — | 显示版本号 | ## 扫描模式 | 模式 | 命令 | 功能说明 | |------|---------|-------------| | **仅被动模式** | `--no-bruteforce` | 26 个 OSINT 来源,无 DNS 请求噪音 | | **标准模式** | *(默认)* | 被动 + 暴力破解(11 万词) | | **完整模式** | `--all` | 被动 + 暴力破解 + 排列组合 + 递归 + 探测 | | **深度模式** | `--deep` | 以最高设置执行所有操作(并发 1000,深度 3) | ## 6 阶段 pipeline ``` ┌─────────────────────────────────────────────────────────┐ │ Phase 1: Passive OSINT (26 free + 9 API sources) │ Always │ Phase 2: DNS Zone Transfer (AXFR) │ Always │ Phase 3: DNS Brute Force (110K wordlist) │ Default (skip: --no-bruteforce) │ Phase 4: Permutation Scanning (200+ patterns) │ --permutations │ Phase 5: Recursive Enumeration (depth 2-3) │ --recursive │ Phase 6: DNS Resolution + HTTP Probe + Takeover Check │ --probe └─────────────────────────────────────────────────────────┘ ``` 每个阶段都会将发现的子域名汇入一个共享集合中——后续阶段可以利用此前的发现。排列组合会基于被动和暴力破解阶段的结果生成。递归枚举则会对所有累积的子域名进行处理。 ## API Key 配置 API key 是**可选的**——该工具开箱即用,支持 26 个免费来源。提供 API key 可解锁另外 9 个高级来源。 ### 方式 1:环境变量 ``` # Linux/macOS export VIRUSTOTAL_API_KEY=your_key export SECURITYTRAILS_API_KEY=your_key export SHODAN_API_KEY=your_key export CENSYS_API_KEY=id:secret export BINARYEDGE_API_KEY=your_key export CHAOS_API_KEY=your_key export BEVIGIL_API_KEY=your_key export WHOISXMLAPI_KEY=your_key export ZOOMEYE_API_KEY=your_key ``` ``` # Windows PowerShell $env:VIRUSTOTAL_API_KEY = "your_key" $env:SECURITYTRAILS_API_KEY = "your_key" ``` ### 方式 2:配置文件 创建 `~/.subdomainx/config.json`: ``` { "api_keys": { "virustotal": "your_key", "securitytrails": "your_key", "shodan": "your_key", "censys": "id:secret", "binaryedge": "your_key", "chaos": "your_key", "bevigil": "your_key", "whoisxmlapi": "your_key", "zoomeye": "your_key" } } ``` ## 输出格式详情 ### JSON 输出 ``` { "domain": "target.com", "total": 142, "subdomains": ["api.target.com", "mail.target.com", "..."], "sources": {"crt.sh": 45, "RapidDNS": 38, "...": "..."}, "resolved": { "api.target.com": { "ips": ["1.2.3.4"], "ipv6s": [], "cnames": [], "http_status": 200, "https_status": 200, "title": "API Documentation", "server": "nginx/1.24.0", "technologies": ["Nginx", "Cloudflare"], "takeover_vulnerable": false, "takeover_service": null, "alive": true } } } ``` ### CSV 输出 ``` Subdomain,IPs,IPv6s,CNAMEs,HTTP,HTTPS,Title,Server,Technologies,Takeover,TakeoverService,Alive api.target.com,1.2.3.4,,, 200,200,API Docs,nginx,Nginx|Cloudflare,False,,True ``` ## 架构 ``` SubdomainX/ ├── subdomainx/ │ ├── __init__.py # Package version │ ├── __main__.py # CLI entry point + 6-phase orchestrator │ ├── passive.py # 35 passive OSINT source classes (26 free + 9 API) │ ├── active.py # Brute force, zone transfer, permutations, recursive │ └── resolver.py # DNS resolution, HTTP probing, tech detection, takeover checks ├── wordlists/ │ └── subdomains.txt # Built-in wordlist (~110K entries) ├── requirements.txt └── README.md ``` ## 工具对比 | 功能 | Subfinder | Amass | SubdomainX | |---|---|---|---| | 免费被动来源 | ~15 | ~20 | **26** | | API 来源 | ~25 | ~30 | 9 | | DNS 暴力破解 | ✗ (需使用 puredns) | ✓ | **✓ + 泛解析过滤 + AAAA/CNAME** | | 排列组合扫描 | ✗ (需使用 altdns) | 基础 | **200+ 模式,8 个类别** | | 递归枚举 | ✗ | ✓ | **✓ 带有基于基域名的泛解析检测** | | HTTP 探测 | ✗ (需使用 httpx) | ✗ (需使用 httpx) | **✓ 内置** | | 技术指纹识别 | ✗ (需使用 httpx) | ✗ | **✓ 内置** | | 子域名接管 | ✗ (需使用 nuclei) | ✗ | **✓ 27 个服务指纹** | | 单一命令 | ✗ | 部分 | **✓** | | 零配置需求 | ✗ | ✗ | **✓** | | 编程语言 | Go | Go | Python | **Go 工具的优势:** 在对成千上万个目标进行千万级(10M+)词表暴力破解时的原生吞吐量。对于绝大多数单目标测试任务而言,性能差异微乎其微。 **SubdomainX 的优势:** 单一工具即可替代 4-5 个工具的 pipeline。开箱即用。易于通过 Python 进行扩展。内置接管检测和技术指纹识别。 ## 免责声明 本工具仅供**授权的安全测试和漏洞赏金计划**使用。在对任何目标进行子域名枚举之前,请务必确保您已获得明确的许可。未经授权的侦察可能会触犯相关法律。 ## 许可证 MIT
**为侦察而生。由 Python 驱动。**
标签:GitHub, Python, 信息收集, 子域名枚举, 安全工具, 实时处理, 密码管理, 无后门, 渗透测试, 系统安全