tunaaksut/phantom
GitHub: tunaaksut/phantom
一款异步多源子域名枚举工具,通过聚合被动数据源与主动 DNS 爆破,帮助安全人员全面发现目标资产攻击面。
Stars: 2 | Forks: 0
# PHANTOM
PHANTOM 是一款异步子域名发现工具,它聚合来自 **31 个被动源** 的结果,执行带有通配符检测和过滤的主动 DNS 爆破,并可选择验证存活主机 — 所有这些都可通过单一的 `config.yaml` 文件或 CLI 参数进行配置。
## 功能
| 功能 | 详情 |
|---|---|
| **子域名接管** | 在 DNS 解析期间自动检测 55+ 云服务商(AWS、Azure、GitHub 等)的悬空 CNAME |
| **排列引擎** | 生成并解析已发现子域名的变体(例如 `api-dev`、`test-api`)以发现隐藏目标 |
| **递归爆破**| 通过对已找到的有效子域名进行递归爆破,发现深层子域名(例如 `dev.api.target.com`) |
| **超快异步 DNS** | 由 `aiodns` 和 `uvloop`(Linux/Mac)驱动,实现零线程开销的大规模解析(1000+ 并发) |
| **17 个免费源** | crt.sh, AlienVault, Anubis, Columbus, CommonCrawl, DNSRepo, HackerTarget, LeakIX, Merklemap, RapidDNS, Recon.dev, Robtex, ShrewdEye, Subdomain.center, ThreatMiner, URLScan, Web Archive |
| **14 个 API 密钥源** | BeVigil, BinaryEdge, Censys, Certspotter, Chaos, FullHunt, GitHub, IntelX, Netlas, SecurityTrails, Shodan, VirusTotal, WhoisXMLAPI, ZoomEye |
| **DNS 爆破** | 内置字典 + 自定义字典合并,**通配符 DNS 检测和过滤** |
| **区域传送** | 针对所有域名服务器尝试 AXFR(需要 dnspython) |
| **DNS 解析** | 验证哪些子域名存活,在公共解析器之间进行轮询 |
| **输出格式** | `json` / `txt` / `csv` |
| **批量模式** | 从文件扫描多个域名 |
| **静默模式** | 适合管道操作:仅打印子域名 |
| **源过滤** | 通过 CLI 或配置启用/禁用任何源 |
| **配置文件** | `config.yaml` 用于持久化设置和 API 密钥 |
| **速率限制处理** | 每个源的独立超时、指数退避、自动重试 |
## 安装
```
# 1. Clone
git clone https://github.com/tunaaksut/phantom
cd phantom
# 2. Install dependencies
pip install -r requirements.txt
# 3. Set up your config (copy the example, then add your API keys)
cp config.example.yaml config.yaml
```
**requirements.txt:**
```
aiohttp>=3.9.0
dnspython>=2.4.0
pyyaml>=6.0.1
aiodns>=3.1.1
uvloop>=0.19.0; sys_platform != 'win32'
```
## 快速开始
```
# 基础扫描
python phantom.py -d example.com
# 静默模式 — 仅打印子域名 (适合 pipe)
python phantom.py -d example.com --silent
# 保存为 TXT
python phantom.py -d example.com -f txt
# 保存到特定目录
python phantom.py -d example.com -f json -o results/
# 从文件 batch 扫描
python phantom.py -l targets.txt -f csv -o results/
```
## CLI 参考
```
usage: phantom [-h] (-d DOMAIN | -l FILE) [-c FILE]
[-o PATH] [-f FMT] [--silent] [--no-color]
[-w FILE] [--no-bruteforce] [--no-zt] [--resolve]
[-t N] [-r N] [--concurrency N]
[--sources LIST] [-v]
```
### 目标
| 参数 | 描述 |
|---|---|
| `-d`, `--domain DOMAIN` | 单个目标域名 |
| `-l`, `--list FILE` | 每行一个域名的文件 |
### 输出
| 参数 | 描述 |
|---|---|
| `-o`, `--output PATH` | 输出文件或目录 |
| `-f`, `--format FMT` | `json`(默认)/ `txt` / `csv` |
| `--silent` | 仅打印子域名(适合管道操作) |
| `--detailed` | 启用高级输出(HTTP 探测、分类、置信度) |
| `--no-color` | 禁用 ANSI 颜色(用于日志文件 / CI) |
### 扫描
| 参数 | 描述 |
|---|---|
| `-w`, `--wordlist FILE` | 自定义字典(与内置字典合并) |
| `--no-bruteforce` | 禁用 DNS 爆破 |
| `--no-zt` | 禁用区域传送(AXFR) |
| `--resolve` | 解析所有结果并标记存活主机 |
| `-t`, `--timeout N` | HTTP/DNS 超时时间,以秒为单位(默认:10) |
| `-r`, `--retries N` | 出错时的重试次数(默认:3) |
| `--concurrency N` | 最大并行工作者数(默认:200) |
### 源
| 参数 | 描述 |
|---|---|
| `--sources LIST` | 仅启用特定源,以逗号分隔 |
| `-c`, `--config FILE` | `config.yaml` 的路径(默认自动检测) |
**免费源(无需密钥):**
`alienvault`, `anubis`, `columbus`, `commoncrawl`, `crtsh`, `dnsrepo`, `hackertarget`, `leakix`, `merklemap`, `rapiddns`, `recondev`, `robtex`, `shrewdeye`, `subdomain_center`, `threatminer`, `urlscan`, `webarchive`
**API 密钥源:**
`bevigil`, `binaryedge`, `censys`, `certspotter`, `chaos`, `fullhunt`, `github`, `intelx`, `netlas`, `securitytrails`, `shodan`, `virustotal`, `whoisxmlapi`, `zoomeye`
## 配置 — `config.yaml`
PHANTOM 会自动在与脚本相同的目录中查找 `config.yaml`。你也可以使用 `-c` 指定自定义路径。
**优先级:** `CLI 参数 > config.yaml > 内置默认值`
从提供的模板开始:
```
cp config.example.yaml config.yaml
```
然后编辑 `config.yaml` 以添加你的 API 密钥并调整设置:
```
# ── 全局设置 ─────────────────────────────────────
timeout: 10
concurrency: 200
bruteforce: true
zone_transfer: true
resolve: false
wordlist: "" # path to extra wordlist, or leave empty
format: json # json | txt | csv
output_dir: "."
silent: false
detailed: false
no_color: false
retries: 3
# ── 高级 Engine 功能 ────────────────────────────
permutation: true # Generate variations (api-dev, test-api)
recursive_bruteforce: false # Brute-force deeper levels
recursive_depth: 1 # Depth for recursive brute-force
# ── 来源 ──────────────────────────────────────
# 格式:source_name: [] → enabled,无 key
# source_name: ["KEY"] → enabled,带 API key
# source_name: false → disabled
# 免费来源 — 保持为 [] 即可
crtsh: []
alienvault: []
# ... (完整列表请参见 config.example.yaml)
# API key 来源 — 在列表内添加你的 key
virustotal: [] # ["YOUR_VT_KEY"]
securitytrails: [] # ["YOUR_ST_KEY"]
github: [] # ["YOUR_GH_TOKEN"]
# ...
```
### API 密钥
| 源 | 所需密钥 | 获取密钥 |
|---|---|---|
| VirusTotal | 可选(结果更多) | https://www.virustotal.com/gui/my-apikey |
| SecurityTrails | 可选 | https://securitytrails.com/app/account/credentials |
| Certspotter | 可选(更高速率限制) | https://sslmate.com/certspotter/api |
| Shodan | 可选 | https://account.shodan.io/ |
| Censys | 可选 | https://search.censys.io/account/api |
| BinaryEdge | 可选 | https://app.binaryedge.io/account/api |
| BeVigil | 可选 | https://osint.bevigil.com/ |
| Chaos (ProjectDiscovery) | 可选 | https://chaos.projectdiscovery.io/ |
| FullHunt | 可选 | https://fullhunt.io/ |
| GitHub | 可选 | https://github.com/settings/tokens |
| IntelX | 可选 | https://intelx.io/account?tab=developer |
| Netlas | 可选 | https://app.netlas.io/profile/ |
| WhoisXMLAPI | 可选 | https://www.whoisxmlapi.com/ |
| ZoomEye | 可选 | https://www.zoomeye.org/profile |
| 所有其他源 | **免费 / 无需密钥** | — |
## 使用示例
```
# 仅使用 passive 来源,无 brute-force
python phantom.py -d target.com --no-bruteforce
# 仅 crt.sh 和 AlienVault
python phantom.py -d target.com --sources crtsh,alienvault
# Batch + CSV + resolve live hosts
python phantom.py -l companies.txt -f csv -o results/ --resolve
# 最大覆盖范围 — 开启所有功能
python phantom.py -d target.com --resolve -w big_wordlist.txt --concurrency 300
# 静默模式 — pipe 到其他工具
python phantom.py -d target.com --silent | httprobe | tee live_hosts.txt
python phantom.py -d target.com --silent | sort -u > unique_subs.txt
# 使用自定义 config 文件
python phantom.py -d target.com -c /etc/phantom/config.yaml
# 禁用日志文件的颜色
python phantom.py -d target.com --no-color 2>&1 | tee scan.log
```
## 输出格式
### JSON (`-f json`)
```
{
"domain": "example.com",
"subdomains": ["api.example.com", "mail.example.com"],
"total_found": 2,
"sources_used": 7,
"source_breakdown": {
"crtsh": 45,
"alienvault": 12,
"bruteforce": 3
},
"subdomains_detail": [
{
"subdomain": "api.example.com",
"resolved": true
}
],
"takeover_candidates": {
"old.example.com": {
"cname": "example.github.io",
"service": "GitHub Pages",
"status": "NXDOMAIN"
}
}
}
```
### TXT (`-f txt`)
```
api.example.com
mail.example.com
www.example.com
```
### CSV (`-f csv`)
```
domain,subdomain,resolved
example.com,api.example.com,yes
example.com,old.example.com,no
```
## 项目结构
```
phantom/
├── phantom.py ← CLI entry point
├── subdomain.py ← Core async discovery engine
├── config.example.yaml ← Config template (copy → config.yaml)
├── requirements.txt ← Python dependencies
├── setup.sh ← Linux/WSL one-shot installer
├── custom_wordlist.txt ← (optional) extra wordlist, auto-loaded if present
└── README.md ← This file
```
## 许可证
MIT — 随意使用,无需署名。
标签:GitHub, Linux安全, SYN扫描, 域名解析, 子域名枚举, 异步编程, 恶意代码分类, 系统安全, 逆向工具