G4MEOVER18/subdomain-takeover-scanner
GitHub: G4MEOVER18/subdomain-takeover-scanner
一款纯 Python 编写的子域名接管漏洞扫描器,通过 CNAME 链分析和 35+ 服务商指纹检测帮助企业发现悬空 DNS 记录带来的接管风险。
Stars: 0 | Forks: 0
# subdomain-takeover-scanner
一个全面且并行化的 **Subdomain Takeover 扫描器**,使用纯 Python 3 编写 — 无需任何外部依赖。
检测超过 35 个服务提供商的特征指纹,识别失效的 CNAME,并按严重程度对发现结果进行分类评估。
## 什么是 Subdomain Takeover?
**Subdomain Takeover** 发生在一个 DNS 记录(通常是 CNAME)指向第三方服务(例如 GitHub Pages、Heroku、AWS S3),但该账户或资源已被删除或从未存在时 —— 子域名因此处于“悬空”状态。攻击者可以注册该资源,并通过受影响的子域名提供任意内容。
### 潜在影响
| 场景 | 风险 |
|---|---|
| 对 `shop.victim.com` 的完全控制 | 钓鱼攻击、凭证收集 |
| Cookie 作用域劫持 | 会话窃取(具有 `*.victim.com` 作用域的 Cookie) |
| 绕过 CSP / SRI | 从受信任的子域名加载攻击者的 JS |
| 电子邮件欺骗 | 从受信任的域名发送邮件 |
| 名誉受损 | 网页篡改、恶意软件托管 |
### 延伸阅读
- [EdOverflow — can-i-take-over-xyz](https://github.com/EdOverflow/can-i-take-over-xyz) — 服务提供商特征指纹的参考列表
- [HackerOne — Subdomain Takeover](https://www.hackerone.com/blog/Guide-Subdomain-Takeovers)
- [OWASP Testing Guide — Subdomain Takeover](https://owasp.org/www-project-web-security-testing-guide/)
## 功能
- **35+ 服务提供商特征指纹** (AWS S3, GitHub Pages, Heroku, Netlify, Azure, Vercel, …)
- **NXDOMAIN 检测** — 失效的 CNAME + NXDOMAIN = CRITICAL
- **并行扫描** — ThreadPoolExecutor,可配置的 Worker 数量(默认:20)
- **严重程度分类** — CRITICAL / HIGH / MEDIUM / INFO / SAFE
- **带有进度条的彩色终端输出**
- **JSON 和 CSV 导出**
- **仅使用 stdlib** — 无外部依赖
- 可选 `dnspython` 以实现更可靠的 CNAME 解析(自动检测)
## 支持的服务提供商特征指纹
| # | 服务提供商 | CNAME 特征 | HTTP 指纹 |
|---|---|---|---|
| 1 | AWS S3 | `s3.amazonaws.com`, `s3-website` | `NoSuchBucket` |
| 2 | GitHub Pages | `github.io`, `github.com` | `There isn't a GitHub Pages site here` |
| 3 | Heroku | `herokuapp.com`, `herokussl.com` | `No such app` |
| 4 | Netlify | `netlify.app`, `netlify.com` | `Not Found` |
| 5 | Shopify | `myshopify.com` | `Sorry, this shop is currently unavailable` |
| 6 | Tumblr | `tumblr.com` | `There's nothing here` |
| 7 | Fastly | `fastly.net` | `Fastly error: unknown domain` |
| 8 | Azure Web Apps | `azurewebsites.net` | `404 Web Site not found` |
| 9 | Azure Traffic Manager | `trafficmanager.net` | `404 Not Found` |
| 10 | Azure Cloud Services | `cloudapp.net`, `cloudapp.azure.com` | `404 - Web app not found` |
| 11 | Zendesk | `zendesk.com` | `Help Center Closed` |
| 12 | Acquia | `acquia-sites.com` | `Web Site Not Configured` |
| 13 | Campaign Monitor | `createsend.com`, `cmail1.com` | `Double check the URL` |
| 14 | Ghost | `ghost.io` | `The thing you were looking for is no longer here` |
| 15 | Pantheon | `pantheonsite.io`, `panth.io` | `The gods are wise, but do not know of the site` |
| 16 | ReadMe.io | `readme.io`, `readmessl.com` | `Project doesnt exist` |
| 17 | SmugMug | `smugmug.com` | `Page Not Found` |
| 18 | Squarespace | `squarespace.com` | `No Such Account` |
| 19 | StatusPage | `statuspage.io` | `page not found` |
| 20 | Surge.sh | `surge.sh` | `project not found` |
| 21 | WordPress.com | `wordpress.com`, `wp.com` | `Do you want to register` |
| 22 | Unbounce | `unbounce.com` | `The requested URL was not found` |
| 23 | Desk.com / Salesforce | `desk.com` | `Sorry, we couldn't find your desk.com site` |
| 24 | UserVoice | `uservoice.com` | `This UserVoice subdomain is currently available` |
| 25 | Intercom | `intercom.help` | `This page doesn't exist` |
| 26 | Webflow | `webflow.io` | `The page you are looking for doesn't exist` |
| 27 | Strikingly | `strikingly.com` | `But if you're looking to build your own website` |
| 28 | Tilda | `tilda.ws` | `Please renew your subscription` |
| 29 | HubSpot | `hs-sites.com`, `hubspotpagebuilder.com` | `Domain not configured` |
| 30 | JetBrains Space | `jetbrains.space` | `Page Not Found` |
| 31 | Vercel | `vercel.app`, `now.sh` | `The deployment could not be found` |
| 32 | Render | `onrender.com` | `Service Not Found` |
| 33 | Fly.io | `fly.dev`, `fly.io` | `404: Not Found` |
| 34 | Cargo Collective | `cargocollective.com` | `404 Not Found` |
| 35 | Agile CRM | `agilecrm.com` | `Sorry, this page is no longer available` |
## 安装
```
git clone https://github.com/G4MEOVER18/subdomain-takeover-scanner.git
cd subdomain-takeover-scanner
# 无需外部依赖(仅使用 stdlib)。
# 可选:安装 dnspython 以获得更好的 CNAME 解析:
pip install dnspython
```
## 用法
### 从字典文件枚举子域名
```
python takeover.py --domain example.com --wordlist wordlist.txt
```
### 扫描已有的主机名列表
```
python takeover.py --list subdomains.txt
```
### 导出结果
```
python takeover.py --domain example.com --wordlist wordlist.txt \
--json results.json \
--csv results.csv
```
### 仅显示严重/高危发现(CI 模式)
```
python takeover.py --list targets.txt --only-vulnerable
```
### 提高并发数
```
python takeover.py --domain bigcorp.com --wordlist wordlist.txt --workers 50
```
### 列出所有内置的服务提供商特征指纹
```
python takeover.py --providers
```
### 所有选项
```
usage: takeover.py [-h] [--domain DOMAIN] [--wordlist FILE] [--list FILE]
[--workers N] [--json FILE] [--csv FILE] [--no-color]
[--only-vulnerable] [--timeout SEC] [--providers]
--domain, -d Basis-Domain (kombiniert mit --wordlist für Enumeration)
--wordlist, -w Wordlist-Datei (ein Prefix pro Zeile)
--list, -l Datei mit vollständigen Hostnamen (ein pro Zeile)
--workers, -t Parallele Threads (Standard: 20)
--json JSON-Report in FILE schreiben
--csv CSV-Report in FILE schreiben
--no-color ANSI-Farbausgabe deaktivieren
--only-vulnerable Nur CRITICAL- und HIGH-Befunde ausgeben
--timeout HTTP-Timeout in Sekunden (Standard: 8)
--providers Provider-Fingerprint-Tabelle ausgeben und beenden
```
## 严重程度
| 严重程度 | 含义 | 建议操作 |
|---|---|---|
| **CRITICAL** | 失效的 CNAME + NXDOMAIN — 该子域名极有可能被立即接管。 | 立即注册资源或删除 DNS 记录。 |
| **HIGH** | 检测到 HTTP 指纹 — 服务对未声明的槽位响应“未找到”消息。 | 接管可能性大。注册或删除。 |
| **MEDIUM** | CNAME 指向已知提供商,但指纹未确认(可能受保护或暂时离线)。 | 建议进行手动检查。 |
| **INFO** | DNS 解析失败、无 CNAME 或无失效 CNAME 的 NXDOMAIN。 | 风险较低。 |
| **SAFE** | 解析为 IP,未检测到已知提供商。 | 无需操作。 |
## 退出码
| 代码 | 含义 |
|---|---|
| `0` | 扫描完成,未发现 CRITICAL 或 HIGH 结果 |
| `1` | 发现至少一个 CRITICAL 或 HIGH 结果 |
| `2` | 使用错误或未找到文件 |
## CI/CD 集成
```
# .github/workflows/takeover-check.yml
name: Subdomain Takeover Check
on:
schedule:
- cron: "0 6 * * 1" # Jeden Montag um 06:00 UTC
push:
branches: [main]
jobs:
takeover:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Python einrichten
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Scanner ausführen
run: |
python takeover.py \
--domain ${{ vars.TARGET_DOMAIN }} \
--wordlist wordlist.txt \
--only-vulnerable \
--json results.json
# Exit-Code 1 → CI schlägt fehl, wenn CRITICAL/HIGH gefunden
- name: Ergebnisse hochladen
if: always()
uses: actions/upload-artifact@v4
with:
name: takeover-results
path: results.json
```
## 许可证
MIT License — Copyright (c) 2026 G4MEOVER18
完整条款:[LICENSE](LICENSE)
## 预览

标签:DNS安全, DOM分析, LNA, Python, 子域名接管, 无后门, 配置审计