0xgh057r3c0n/SubSpider
GitHub: 0xgh057r3c0n/SubSpider
一款递归子域名枚举工具,通过逐层深入扫描子域名的子域名来发现传统工具遗漏的隐藏基础设施。
Stars: 0 | Forks: 0
# 🕷️ SubSpider
## 📖 **什么是 SubSpider?**
SubSpider 是一款**强大的递归子域名枚举工具**,它可以递归地发现子域名的子域名,深度可达 15 层。就像蜘蛛织网一样 🕷️,它会爬取每一个发现的子域名,从而 uncover 传统工具完全遗漏的隐藏基础设施。
### 🎯 **核心差异**
```
🔴 Traditional Tools: example.com → [sub1, sub2, sub3] → STOP ❌
(Misses everything deeper!)
🟢 SubSpider: example.com → [sub1, sub2, sub3]
sub1 → [sub1.dev, sub1.test]
sub1.dev → [api.sub1.dev]
api.sub1.dev → [v2.api.sub1.dev]
... CONTINUES TO DEPTH 15 ✅
```
## ✨ **功能**
| 功能 | 描述 |
|---------|-------------|
| 🔄 **递归扫描** | 扫描子域名的子域名,深度可达 15 层 |
| 🚀 **Subfinder 集成** | 使用强大的 Subfinder 引擎 |
| ✅ **DNS 验证** | 通过 DNS 验证每个子域名 |
| ⚡ **多线程** | 可配置的线程池以提高速度 |
| 💾 **自动保存** | 每 10 秒自动保存一次 |
| 📊 **多种格式** | JSON、文本和格式化输出 |
| 🔁 **重试机制** | 失败时自动重试 |
| 🎨 **精美的输出** | 彩色、有条理的终端输出 |
| 🎯 **速率限制** | 控制请求速度以避免被检测 |
| 🔄 **恢复支持** | 恢复中断的扫描 |
## 🚀 **安装**
### 📦 **前置条件**
```
# Python 3.6+
python3 --version
# Subfinder(必需)
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
# Python DNS library
pip install dnspython
```
### 🔧 **安装 SubSpider**
```
# 克隆 repository
git clone https://github.com/0xgh057r3c0n/SubSpider.git
cd SubSpider
# 设置为可执行
chmod +x subspider.py
# 测试安装
python3 subspider.py --help
```
## 📋 **命令行选项**
### 🎯 **必选参数**
| 标志 | 描述 | 示例 |
|------|-------------|---------|
| `domain` | 🎯 目标域名 | `example.com` |
### 📏 **深度与发现**
| 标志 | 描述 | 默认值 | 示例 |
|------|-------------|---------|---------|
| `--depth, -d` | 📏 最大递归深度 (1-15) | `3` | `--depth 10` |
| `--timeout, -t` | ⏱️ Subfinder 超时时间(秒) | `30` | `--timeout 60` |
| `--dns-timeout` | 🌐 DNS 解析超时时间 | `5` | `--dns-timeout 10` |
| `--no-dns-validate` | ⏩ 跳过 DNS 验证 | `False` | `--no-dns-validate` |
### ⚡ **性能**
| 标志 | 描述 | 默认值 | 示例 |
|------|-------------|---------|---------|
| `--threads` | 🧵 线程数 | `10` | `--threads 30` |
| `--rate-limit` | 🚦 速率限制 (请求/秒) | `0` | `--rate-limit 50` |
### 💾 **输出**
| 标志 | 描述 | 默认值 | 示例 |
|------|-------------|---------|---------|
| `--output, -o` | 💾 输出文件名 | 自动 | `--output results.txt` |
| `--output-json, -j` | 📊 导出为 JSON | 无 | `--output-json data.json` |
| `--output-list, -l` | 📋 导出为简单列表 | 无 | `--output-list subs.txt` |
### 🔁 **可靠性**
| 标志 | 描述 | 默认值 | 示例 |
|------|-------------|---------|---------|
| `--retry` | 🔁 重试次数 | `2` | `--retry 5` |
| `--retry-delay` | ⏳ 重试延迟 | `3` | `--retry-delay 5` |
| `--save-interval` | 💾 自动保存间隔 | `10` | `--save-interval 5` |
### 🎨 **显示**
| 标志 | 描述 | 默认值 | 示例 |
|------|-------------|---------|---------|
| `--verbose, -v` | 🔊 详细输出 | `False` | `--verbose` |
| `--no-color` | 🎨 禁用颜色 | `False` | `--no-color` |
| `--no-banner` | 🚫 隐藏横幅 | `False` | `--no-banner` |
| `--resume` | 🔄 恢复之前的扫描 | `False` | `--resume` |
### 📂 **高级**
| 标志 | 描述 | 示例 |
|------|-------------|---------|
| `--subfinder-path, -s` | 📂 自定义 Subfinder 路径 | `--subfinder-path /usr/bin/subfinder` |
## 📖 **完整帮助**
```
python3 subspider.py -h
```
```
usage: subspider.py [-h] [--depth DEPTH] [--timeout TIMEOUT]
[--dns-timeout DNS_TIMEOUT]
[--subfinder-path SUBFINDER_PATH] [--output OUTPUT]
[--output-json OUTPUT_JSON] [--output-list OUTPUT_LIST]
[--no-dns-validate] [--threads THREADS]
[--rate-limit RATE_LIMIT] [--verbose] [--retry RETRY]
[--retry-delay RETRY_DELAY] [--save-interval SAVE_INTERVAL]
[--no-color] [--no-banner] [--resume]
domain
🕷️ SPIDER - Recursive Subdomain Enumeration Toolkit
positional arguments:
domain 🎯 Target domain (e.g., google.com)
optional arguments:
-h, --help 📖 Show this help message
--depth DEPTH, -d DEPTH
📏 Maximum recursion depth (default: 3)
--timeout TIMEOUT, -t TIMEOUT
⏱️ Subfinder timeout in seconds (default: 30)
--dns-timeout DNS_TIMEOUT
🌐 DNS resolution timeout in seconds (default: 5)
--subfinder-path SUBFINDER_PATH, -s SUBFINDER_PATH
📂 Path to Subfinder binary
--output OUTPUT, -o OUTPUT
💾 Output file for subdomains
--output-json OUTPUT_JSON, -j OUTPUT_JSON
📊 Export results to JSON file
--output-list OUTPUT_LIST, -l OUTPUT_LIST
📋 Export subdomain list (one per line)
--no-dns-validate ⏩ Skip DNS validation (faster)
--threads THREADS 🧵 Number of Subfinder threads (default: 10)
--rate-limit RATE_LIMIT
🚦 Rate limit for Subfinder (default: 0 = unlimited)
--verbose, -v 🔊 Verbose output
--retry RETRY 🔁 Retry attempts on timeout (default: 2)
--retry-delay RETRY_DELAY
⏳ Retry delay in seconds (default: 3)
--save-interval SAVE_INTERVAL
💾 Auto-save interval in seconds (default: 10)
--no-color 🎨 Disable colored output
--no-banner 🚫 Disable banner
--resume 🔄 Resume previous scan from saved file
Example:
python3 subspider.py google.com --output results.txt
```
## 💡 **使用示例**
### 🎯 **基本扫描**
```
# 使用默认设置进行快速扫描(深度 3)
python3 subspider.py example.com
# 浅层扫描(深度 1)- 最快 ⚡
python3 subspider.py example.com --depth 1
# 深度扫描(深度 5)- 彻底 🔍
python3 subspider.py example.com --depth 5
# 最大深度扫描(深度 15)🌊
python3 subspider.py example.com --depth 15
```
### ⚡ **性能优化**
```
# 快速扫描(跳过 DNS 验证)🏃
python3 subspider.py example.com --no-dns-validate --depth 5
# 高性能(更多线程)🚀
python3 subspider.py example.com --threads 30 --timeout 60 --depth 10
# 速率限制(避免检测)🛡️
python3 subspider.py example.com --rate-limit 30 --threads 10 --depth 5
```
### 💾 **输出示例**
```
# 自定义输出文件名 📄
python3 subspider.py example.com --output my_results.txt
# 导出所有格式 📊
python3 subspider.py example.com \
--output results.txt \
--output-json results.json \
--output-list subdomains.txt
# 仅 JSON 输出 📊
python3 subspider.py example.com --output-json scan_results.json
# 仅列表输出 📋
python3 subspider.py example.com --output-list all_subs.txt
```
### 🚀 **高级用法**
```
# 包含所有选项的完整扫描
python3 subspider.py example.com \
--depth 15 \
--threads 25 \
--timeout 60 \
--dns-timeout 10 \
--output results.txt \
--output-json full_scan.json \
--output-list subdomains.txt \
--retry 5 \
--retry-delay 5 \
--save-interval 5 \
--verbose
# 恢复之前的扫描
python3 subspider.py example.com --resume
# 静默模式(无 banner,最少输出)
python3 subspider.py example.com --no-banner --no-color
# 自定义 Subfinder 路径
python3 subspider.py example.com --subfinder-path /custom/path/subfinder
```
## 🔄 **递归发现的工作原理**
### **递归过程**
SubSpider 使用基于队列的递归算法:
```
Level 0: Scan example.com
→ Finds: test.example.com, api.example.com, dev.example.com
Level 1: Scan test.example.com
→ Finds: demo.test.example.com, stage.test.example.com
Level 1: Scan api.example.com
→ Finds: v2.api.example.com, internal.api.example.com
Level 2: Scan demo.test.example.com
→ Finds: login.demo.test.example.com, admin.demo.test.example.com
Level 2: Scan v2.api.example.com
→ Finds: auth.v2.api.example.com
Level 3: Scan login.demo.test.example.com
→ Finds: auth.login.demo.test.example.com
Level 3: Scan auth.v2.api.example.com
→ Finds: sso.auth.v2.api.example.com
Level 4: Scan auth.login.demo.test.example.com
→ Finds: mfa.auth.login.demo.test.example.com
... Continues until depth 15 is reached!
```
### **每个深度能发现什么**
| 深度 | 发现类型 | 示例 |
|-------|---------------|----------|
| 0-1 | 主要基础设施 | `api.example.com`, `dev.example.com` |
| 2-3 | 开发与测试 | `demo.test.example.com`, `v2.api.example.com` |
| 4-6 | 内部服务 | `internal.v2.api.example.com`, `auth.demo.test.example.com` |
| 7-10 | 微服务 | `auth.internal.v2.api.example.com`, `mfa.sso.login.demo.test.example.com` |
| 11-15 | 深层基础设施 | `encrypt.token.auth.internal.dev.example.com` |
## 📊 **输出格式**
### **1. 标准输出**
```
═══════════════════════════════════════════════════════════════════
📊 ENUMERATION RESULTS - example.com
═══════════════════════════════════════════════════════════════════
📁 Depth 1: 45 subdomains
├─ api.example.com
├─ test.example.com
├─ dev.example.com
└─ ... (42 more)
📁 Depth 2: 128 subdomains
├─ demo.test.example.com
├─ v2.api.example.com
├─ app.dev.example.com
└─ ... (125 more)
📊 STATISTICS
├─ Total unique: 47,892
├─ Total scans: 8,901
├─ Successful: 8,456
├─ Failed: 445
└─ Time taken: 14h 23m 45s
```
### **2. JSON 输出**
```
{
"domain": "example.com",
"timestamp": "2024-01-15T14:30:00.000Z",
"max_depth": 15,
"statistics": {
"total_unique_subdomains": 47892,
"total_scanned": 12345,
"total_subfinder_scans": 8901,
"successful_scans": 8456,
"failed_scans": 445
},
"subdomains_by_depth": {
"1": ["api.example.com", "test.example.com"],
"2": ["demo.test.example.com", "v2.api.example.com"]
},
"all_subdomains": ["api.example.com", "test.example.com"]
}
```
### **3. 简单列表输出**
```
# example.com 的子域
# 总计:47,892
api.example.com
test.example.com
demo.test.example.com
v2.api.example.com
...
```
## 🎯 **不同深度的使用场景**
| 深度 | 最适合 | 耗时 | 发现内容 |
|-------|----------|------|-------|
| 1-3 | 快速评估 | 5-30 分钟 | 主要子域名 |
| 4-7 | 安全审计 | 1-8 小时 | 开发、预发布环境 |
| 8-12 | 深度发现 | 8-48 小时 | 微服务、隐藏的 API |
| 13-15 | 最大程度的发现 | 1-7 天 | 所有可能的内容 |
## 🔧 **故障排除**
### **常见问题**
| 问题 | 解决方案 |
|-------|----------|
| ❌ 未找到 Subfinder | `--subfinder-path /path/to/subfinder` |
| ❌ 超时错误 | `--timeout 120` |
| ❌ 被速率限制 | `--rate-limit 20` |
| ❌ 速度太慢 | `--threads 30` |
| ❌ 扫描被中断 | `--resume` |
## 🛡️ **安全与道德**
⚠️ **免责声明**:此工具仅供教育和授权测试使用。
✅ **应该做的**:
- 扫描您拥有或已获得许可的域名
- 用于漏洞赏金计划
- 用于教育目的
❌ **不该做的**:
- 未经许可进行扫描
- 用于恶意目的
- 使目标基础设施过载
## 📝 **许可证**
MIT 许可证 - 查看 [LICENSE](LICENSE) 文件
## 👤 **作者**
**0xgh057r3c0n**
- 🐙 GitHub: [@0xgh057r3c0n](https://github.com/0xgh057r3c0n)
- 🐦 Twitter: [@0xgh057r3c0n](https://twitter.com/0xgh057r3c0n)
## 📞 **支持**
- 💬 问题:[GitHub Issues](https://github.com/0xgh057r3c0n/SubSpider/issues)
- 📧 邮箱:0xgh057r3c0n@protonmail.com
标签:Python, 主机安全, 子域名枚举, 无后门, 系统安全, 资产测绘, 逆向工具