Sublist3r使用教程#
软件介绍#
Sublist3r是一款快速的多线程子域名枚举工具,专为渗透测试人员和安全研究人员设计。它能够通过多种方式枚举目标域名的子域名,包括使用搜索引擎、暴力破解和字典攻击等,是域名信息收集和子域名发现的重要工具之一。
主要功能#
- 多搜索引擎子域名枚举
- 快速多线程扫描
- 支持自定义字典
- 支持通配符子域名检测
- 支持端口扫描
- 支持结果保存
- 支持API集成
- 支持DNS解析验证
- 支持子域名去重
- 支持批量域名扫描
适用场景#
- 子域名枚举和发现
- 域名安全评估
- 渗透测试前的信息收集
- 域名资产管理
- 品牌保护监控
- 网络安全研究
入门级使用#
安装Sublist3r#
Sublist3r是一个Python工具,可以通过以下步骤安装:
# 克隆仓库
git clone https://github.com/aboul3la/Sublist3r.git
# 进入目录
cd Sublist3r
# 安装依赖
pip install -r requirements.txt基本子域名枚举#
使用Sublist3r进行基本的子域名枚举:
# 基本子域名枚举
python sublist3r.py -d example.com
# 使用特定搜索引擎
python sublist3r.py -d example.com -e google
# 使用多个搜索引擎
python sublist3r.py -d example.com -e google,bing,yahoo查看帮助信息#
查看Sublist3r的所有可用选项:
# 查看帮助信息
python sublist3r.py -h初级使用#
使用多个搜索引擎#
使用多个搜索引擎进行子域名枚举,提高发现率:
# 使用多个搜索引擎
python sublist3r.py -d example.com -e google,bing,yahoo,duckduckgo
# 使用所有支持的搜索引擎
python sublist3r.py -d example.com -e all保存结果#
将枚举结果保存到文件:
# 保存结果到文件
python sublist3r.py -d example.com -o subdomains.txt
# 保存结果到指定路径
python sublist3r.py -d example.com -o /path/to/subdomains.txt设置线程数量#
设置线程数量以提高枚举速度:
# 设置线程数量为10
python sublist3r.py -d example.com -t 10
# 设置线程数量为20
python sublist3r.py -d example.com -t 20中级使用#
使用自定义字典#
使用自定义字典进行子域名暴力破解:
# 使用自定义字典
python sublist3r.py -d example.com -b custom_wordlist.txt
# 使用内置字典
python sublist3r.py -d example.com -bDNS解析验证#
对发现的子域名进行DNS解析验证:
# 启用DNS解析验证
python sublist3r.py -d example.com -v
# 查看解析结果
python sublist3r.py -d example.com -v -o subdomains.txt通配符子域名检测#
检测目标域名是否使用通配符子域名:
# 检测通配符子域名
python sublist3r.py -d example.com -w
# 如果存在通配符,Sublist3r会提示中上级使用#
端口扫描#
对发现的子域名进行端口扫描:
# 对子域名进行端口扫描
python sublist3r.py -d example.com -p 80,443,22
# 扫描常用端口
python sublist3r.py -d example.com -p 80,443,8080,8443
# 扫描指定端口范围
python sublist3r.py -d example.com -p 1-1000批量域名扫描#
批量扫描多个域名的子域名:
# 创建域名列表文件
# domains.txt内容:
# example.com
# test.com
# demo.com
# 批量扫描
python sublist3r.py -d domains.txt -o results.txtAPI集成#
集成第三方API进行子域名枚举:
# 使用VirusTotal API
python sublist3r.py -d example.com -a virustotal
# 使用SecurityTrails API
python sublist3r.py -d example.com -a securitytrails
# 使用多个API
python sublist3r.py -d example.com -a virustotal,securitytrails高级使用#
自定义搜索引擎#
添加自定义搜索引擎进行子域名枚举:
# 修改Sublist3r源代码添加自定义搜索引擎
# 在engines.py中添加新的搜索引擎类
class CustomSearchEngine:
def __init__(self):
self.name = "CustomEngine"
self.base_url = "https://custom.engine.com/search?q="
def search(self, domain):
query = f"site:{domain}"
url = self.base_url + query
# 实现搜索逻辑
return subdomains结果去重和分析#
对枚举结果进行去重和深度分析:
# 枚举子域名
python sublist3r.py -d example.com -o subdomains.txt
# 去重
sort subdomains.txt | uniq > unique_subdomains.txt
# 分析子域名模式
cat unique_subdomains.txt | grep -E "^[a-z]+\." | sort | uniq -c自动化脚本集成#
将Sublist3r集成到自动化脚本中:
# 自动化脚本示例
import subprocess
import json
def enumerate_subdomains(domain):
# 运行Sublist3r
result = subprocess.run(
['python', 'sublist3r.py', '-d', domain, '-o', f'{domain}.txt', '-j'],
capture_output=True,
text=True
)
# 读取结果
with open(f'{domain}.txt', 'r') as f:
subdomains = f.read().splitlines()
return subdomains
# 使用示例
domains = ['example.com', 'test.com']
for domain in domains:
subdomains = enumerate_subdomains(domain)
print(f"Found {len(subdomains)} subdomains for {domain}")大师级使用#
大规模子域名枚举#
进行大规模子域名枚举,处理大量域名:
# 大规模枚举脚本
import multiprocessing
import subprocess
def enumerate_domain(domain):
result = subprocess.run(
['python', 'sublist3r.py', '-d', domain, '-o', f'results/{domain}.txt'],
capture_output=True,
text=True
)
return domain
# 使用多进程
domains = open('domains.txt').read().splitlines()
with multiprocessing.Pool(processes=10) as pool:
results = pool.map(enumerate_domain, domains)
print(f"Completed enumeration for {len(results)} domains")子域名情报分析#
对发现的子域名进行深度情报分析:
# 子域名情报分析脚本
import dns.resolver
import requests
def analyze_subdomain(subdomain):
info = {
'subdomain': subdomain,
'ip_addresses': [],
'http_status': None,
'server': None,
'technologies': []
}
# DNS解析
try:
answers = dns.resolver.resolve(subdomain, 'A')
for rdata in answers:
info['ip_addresses'].append(rdata.address)
except:
pass
# HTTP请求
try:
response = requests.get(f'http://{subdomain}', timeout=5)
info['http_status'] = response.status_code
info['server'] = response.headers.get('Server', '')
except:
pass
return info
# 使用示例
subdomains = open('subdomains.txt').read().splitlines()
for subdomain in subdomains:
info = analyze_subdomain(subdomain)
print(json.dumps(info, indent=2))企业级子域名监控系统#
构建企业级子域名监控系统:
# 子域名监控系统
import time
import smtplib
from email.mime.text import MIMEText
def monitor_subdomains(domain, known_subdomains):
# 枚举当前子域名
result = subprocess.run(
['python', 'sublist3r.py', '-d', domain, '-o', 'current.txt'],
capture_output=True,
text=True
)
# 读取当前子域名
with open('current.txt', 'r') as f:
current_subdomains = set(f.read().splitlines())
# 比较差异
new_subdomains = current_subdomains - known_subdomains
removed_subdomains = known_subdomains - current_subdomains
# 发送告警
if new_subdomains or removed_subdomains:
send_alert(domain, new_subdomains, removed_subdomains)
return current_subdomains
def send_alert(domain, new, removed):
# 发送邮件告警
msg = MIMEText(f"Subdomain changes detected for {domain}\n\nNew: {new}\nRemoved: {removed}")
msg['Subject'] = f"Subdomain Alert: {domain}"
msg['From'] = "monitor@example.com"
msg['To'] = "admin@example.com"
# 发送邮件
# smtplib.SMTP('smtp.example.com').send_message(msg)
pass
# 使用示例
domain = "example.com"
known_subdomains = set()
while True:
known_subdomains = monitor_subdomains(domain, known_subdomains)
time.sleep(3600) # 每小时检查一次实战案例#
案例一:企业子域名枚举#
场景:安全团队需要对某企业的域名进行全面子域名枚举,发现所有相关的子域名。
解决方案:使用Sublist3r进行全面子域名枚举。
实施步骤:
子域名枚举:
# 使用所有搜索引擎 python sublist3r.py -d example.com -e all -o subdomains.txt # 使用暴力破解 python sublist3r.py -d example.com -b -o brute_subdomains.txt # 合并结果 cat subdomains.txt brute_subdomains.txt | sort | uniq > all_subdomains.txt结果分析:
- 分析子域名模式
- 识别潜在的敏感子域名
- 评估子域名安全风险
安全评估:
- 对发现的子域名进行安全扫描
- 检查子域名的安全配置
- 识别潜在的安全漏洞
结果:
- 发现了150多个子域名
- 识别出10个潜在的敏感子域名
- 发现了3个配置不当的子域名
- 提供了详细的子域名安全加固建议
案例二:品牌子域名监控#
场景:企业需要监控品牌相关的子域名,及时发现潜在的侵权行为。
解决方案:使用Sublist3r设置自动化子域名监控。
实施步骤:
监控设置:
# 创建监控脚本 # 定期运行Sublist3r # 比较结果差异 # 发送告警通知侵权检测:
- 监控新注册的相似子域名
- 分析子域名使用情况
- 识别潜在的侵权行为
保护措施:
- 生成侵权子域名报告
- 提供法律保护建议
- 制定品牌保护策略
结果:
- 监控了品牌相关的50多个域名
- 发现了20个潜在的侵权子域名
- 成功处理了10个侵权子域名
- 建立了完善的品牌子域名保护机制
案例三:渗透测试子域名发现#
场景:渗透测试团队需要在测试前发现目标的所有子域名,为后续测试做准备。
解决方案:使用Sublist3r进行全面的子域名枚举和分析。
实施步骤:
子域名发现:
# 全面枚举 python sublist3r.py -d target.com -e all -b -v -o all_subdomains.txt # DNS解析验证 python sublist3r.py -d target.com -v -o verified_subdomains.txt # 端口扫描 python sublist3r.py -d target.com -p 80,443,8080,8443 -o subdomains_with_ports.txt深度分析:
- 分析子域名技术栈
- 识别潜在攻击面
- 评估子域名安全状况
测试准备:
- 生成子域名清单
- 制定测试计划
- 准备测试工具
结果:
- 发现了200多个子域名
- 识别出30个可访问的子域名
- 发现了15个潜在的安全问题
- 为渗透测试提供了全面的子域名信息
总结#
Sublist3r是一款功能强大的子域名枚举工具,通过本教程的学习,您已经掌握了从入门到大师级的使用方法。
主要功能回顾#
- 多搜索引擎:使用多个搜索引擎进行子域名枚举
- 暴力破解:使用字典进行子域名暴力破解
- DNS验证:对发现的子域名进行DNS解析验证
- 端口扫描:对子域名进行端口扫描
- 批量扫描:批量扫描多个域名的子域名
- API集成:集成第三方API进行子域名枚举
- 结果保存:将枚举结果保存到文件
- 多线程:使用多线程提高枚举速度
最佳实践#
- 多源枚举:结合搜索引擎和暴力破解,提高子域名发现率
- 结果验证:对发现的子域名进行DNS解析验证,确保有效性
- 定期枚举:定期进行子域名枚举,及时发现新的子域名
- 结果分析:对枚举结果进行深度分析,识别潜在的安全风险
- 自动化监控:建立自动化监控机制,持续监控子域名变化
- 合规使用:确保在法律和授权范围内使用Sublist3r
注意事项#
- 搜索引擎限制:频繁使用搜索引擎可能会被限制访问,建议使用代理
- 网络影响:大规模子域名枚举可能会对网络造成一定影响
- 数据准确性:搜索引擎结果可能存在误报,需要进行验证
- API限制:第三方API可能有使用限制,需要注意配额
- 法律合规:使用Sublist3r进行子域名枚举时,需要遵守相关法律法规
- 道德考量:确保获得目标域名的授权后再进行子域名枚举
通过合理使用Sublist3r,您可以有效地发现和分析目标域名的子域名,为安全评估、渗透测试和品牌保护提供有价值的信息。同时,务必在法律和伦理允许的范围内使用该工具,确保子域名枚举的合法性和负责任性。