Sublist3r使用教程#

软件介绍#

Sublist3r是一款用Python编写的子域名枚举工具,专注于通过搜索引擎和其他公共资源发现子域名。它结合了多种子域名发现技术,包括搜索引擎爬虫、DNS查询和暴力破解。

入门级使用#

基本子域名枚举#

功能说明:使用默认设置枚举目标域名的子域名

使用示例

# 基本子域名枚举
python sublist3r.py -d example.com

# 枚举多个域名
python sublist3r.py -d example.com -d test.com

# 将结果输出到文件
python sublist3r.py -d example.com -o results.txt

# 从文件中读取域名
python sublist3r.py -l domains.txt -o batch_results.txt

参数说明

  • -d:指定目标域名
  • -l:从文件中读取域名列表
  • -o:指定输出文件

简单的搜索引擎搜索#

功能说明:仅使用搜索引擎搜索子域名

使用示例

# 仅使用搜索引擎
python sublist3r.py -d example.com -e google,bing,baidu

# 使用所有可用的搜索引擎
python sublist3r.py -d example.com -e all

# 禁用搜索引擎,仅使用DNS查询
python sublist3r.py -d example.com -b

# 启用暴力破解
python sublist3r.py -d example.com -br

参数说明

  • -e:指定搜索引擎
  • -b:禁用搜索引擎
  • -br:启用暴力破解

初级使用#

扫描控制#

功能说明:控制扫描的行为和速度

使用示例

# 设置线程数
python sublist3r.py -d example.com -t 50

# 设置超时时间
python sublist3r.py -d example.com -v 10

# 设置最大枚举数量
python sublist3r.py -d example.com -n 100

# 启用详细输出
python sublist3r.py -d example.com -v

# 启用安静模式
python sublist3r.py -d example.com -q

参数说明

  • -t:设置线程数
  • -v:设置超时时间或启用详细输出
  • -n:设置最大枚举数量
  • -q:启用安静模式

结果过滤#

功能说明:过滤和处理扫描结果

使用示例

# 过滤特定模式的子域名
python sublist3r.py -d example.com | grep -E "test|dev|staging"

# 统计子域名数量
python sublist3r.py -d example.com | wc -l

# 按长度排序子域名
python sublist3r.py -d example.com | awk '{print length($0) " " $0}' | sort -n | cut -d' ' -f2-

# 与其他工具结合使用
python sublist3r.py -d example.com -o subdomains.txt
cat subdomains.txt | xargs -I {} nmap -sV {}

# 验证子域名是否可访问
python sublist3r.py -d example.com | xargs -I {} curl -I -m 2 {}

参数说明

  • -o:指定输出文件

中级使用#

高级枚举选项#

功能说明:使用高级选项进行更深入的子域名枚举

使用示例

# 结合暴力破解和搜索引擎
python sublist3r.py -d example.com -br -e google,bing

# 使用自定义词表进行暴力破解
python sublist3r.py -d example.com -br -w custom_wordlist.txt

# 启用递归枚举
python sublist3r.py -d example.com -r

# 结合DNS区域传输
python sublist3r.py -d example.com -a

# 完整的枚举策略
python sublist3r.py -d example.com -br -e all -r -a -o complete_results.txt

参数说明

  • -br:启用暴力破解
  • -e:指定搜索引擎
  • -w:指定自定义词表
  • -r:启用递归枚举
  • -a:尝试DNS区域传输
  • -o:指定输出文件

认证和代理#

功能说明:处理需要认证的网站和使用代理

使用示例

# 使用代理
python sublist3r.py -d example.com -p http://127.0.0.1:8080

# 使用SOCKS代理
python sublist3r.py -d example.com -p socks5://127.0.0.1:1080

# 使用多个代理
python sublist3r.py -d example.com -p http://127.0.0.1:8080,http://127.0.0.1:8081

# 使用基本认证
python sublist3r.py -d example.com --proxy-auth username:password

# 使用cookie
# 需要修改源代码或使用其他工具设置cookie

参数说明

  • -p:指定代理
  • --proxy-auth:设置代理认证凭据

中上级使用#

绕过防护#

功能说明:绕过网站的安全防护措施

使用示例

# 启用随机用户代理
python sublist3r.py -d example.com -u

# 设置请求延迟
python sublist3r.py -d example.com -s 1

# 自定义请求头
# 需要修改源代码添加自定义HTTP头

# 分片请求
# 需要修改源代码实现分片请求

# 结合其他工具绕过防护
python sublist3r.py -d example.com -o subdomains.txt
cat subdomains.txt | proxychains4 xargs -I {} curl -I {}

参数说明

  • -u:启用随机用户代理
  • -s:设置请求延迟(秒)

自定义扫描#

功能说明:创建和使用自定义扫描配置

使用示例

# 使用自定义搜索引擎
# 需要修改源代码添加自定义搜索引擎

# 自定义暴力破解设置
python sublist3r.py -d example.com -br -w custom_wordlist.txt -t 20

# 针对特定环境的扫描
# 开发环境
python sublist3r.py -d example.com -br -w dev_wordlist.txt -o dev_subdomains.txt

# 生产环境
python sublist3r.py -d example.com -e google,bing -o prod_subdomains.txt

# 结合其他工具进行深入分析
python sublist3r.py -d example.com -o subdomains.txt
cat subdomains.txt | xargs -I {} nmap -sV {}

参数说明

  • -br:启用暴力破解
  • -w:指定自定义词表
  • -t:设置线程数
  • -e:指定搜索引擎
  • -o:指定输出文件

高级使用#

大规模扫描#

功能说明:处理大规模的子域名枚举任务

使用示例

# 批量扫描多个网站
python sublist3r.py -l urls.txt -o batch_results.txt

# 分布式扫描(使用多个实例)
# 实例1
python sublist3r.py -l urls1.txt -o results1.txt
# 实例2
python sublist3r.py -l urls2.txt -o results2.txt

# 合并结果
cat results1.txt results2.txt | sort -u > final_results.txt

# 增量扫描
python sublist3r.py -d example.com -o new_results.txt

参数说明

  • -l:从文件中读取域名列表
  • -o:指定输出文件

结果分析#

功能说明:分析和处理扫描结果

使用示例

# 统计发现的子域名数量
python sublist3r.py -d example.com | wc -l

# 过滤特定状态码的结果
python sublist3r.py -d example.com -o results.txt
cat results.txt | xargs -I {} curl -I -m 2 {} | grep -E "HTTP/1\.[01] [23].."

# 提取完整URL
python sublist3r.py -d example.com -o results.txt
cat results.txt | awk '{print "http://" $1}' > urls.txt

# 与其他工具结合使用
python sublist3r.py -d example.com -o subdomains.txt
cat subdomains.txt | xargs -I {} nmap -sV {}

# 验证发现的子域名是否可访问
python sublist3r.py -d example.com | xargs -I {} curl -m 2 {}

参数说明

  • -o:指定输出文件

大师级使用#

自定义插件和脚本#

功能说明:创建和使用自定义插件和脚本

使用示例

# 自定义Sublist3r插件
# 需要修改源代码添加自定义插件

# 批量扫描脚本
#!/bin/bash

while read domain; do
    echo "Scanning: $domain"
    python sublist3r.py -d $domain -o "$domain.txt"
    echo "Completed: $domain"
done < domains.txt

# 结果汇总脚本
#!/bin/bash

for file in *.txt; do
    if [[ $file != "domains.txt" ]]; then
        domain=$(echo $file | sed 's/\.txt$//')
        count=$(wc -l $file | awk '{print $1}')
        echo "$domain: $count subdomains" >> summary.txt
    fi
done

# 高级分析脚本
#!/bin/bash

python sublist3r.py -d $1 -o subdomains.txt

# 统计子域名数量
total=$(wc -l subdomains.txt | awk '{print $1}')
echo "Total subdomains found: $total"

# 检查可访问性
accessible=0
while read subdomain; do
    if curl -s -o /dev/null -m 2 "http://$subdomain"; then
        echo "$subdomain is accessible" >> accessible.txt
        accessible=$((accessible+1))
    fi
done < subdomains.txt

echo "Accessible subdomains: $accessible"

参数说明

  • 使用自定义脚本处理Sublist3r的结果

高级扫描策略#

功能说明:使用高级策略进行更有效的子域名枚举

使用示例

# 多阶段扫描策略
# 第一阶段:快速扫描(仅搜索引擎)
python sublist3r.py -d example.com -e google,bing -o fast_scan.txt

# 第二阶段:深度扫描(搜索引擎+暴力破解)
python sublist3r.py -d example.com -e all -br -w wordlist.txt -o deep_scan.txt

# 第三阶段:定向扫描(针对特定路径)
python sublist3r.py -d example.com -br -w admin_wordlist.txt -o admin_scan.txt

# 智能扫描策略
# 1. 先使用搜索引擎收集基础子域名
python sublist3r.py -d example.com -e google,bing -o search_results.txt

# 2. 基于发现的子域名生成词表
cat search_results.txt | cut -d'.' -f1 | sort -u > custom_wordlist.txt

# 3. 使用生成的词表进行暴力破解
python sublist3r.py -d example.com -br -w custom_wordlist.txt -o brute_results.txt

# 4. 合并结果
cat search_results.txt brute_results.txt | sort -u > final_results.txt

# 持续监控策略
while true; do
    python sublist3r.py -d example.com -o current_results.txt
    if [ -f previous_results.txt ]; then
        diff previous_results.txt current_results.txt > changes.txt
        if [ -s changes.txt ]; then
            echo "New subdomains found:"
            cat changes.txt | grep '>'
        fi
    fi
    mv current_results.txt previous_results.txt
    sleep 86400  # 每天扫描一次
done

参数说明

  • -e:指定搜索引擎
  • -br:启用暴力破解
  • -w:指定自定义词表
  • -o:指定输出文件

实战案例#

案例1:企业资产发现#

任务:发现企业的所有互联网资产

执行步骤

  1. 基本枚举

    python sublist3r.py -d company.com -o initial_results.txt
  2. 深度枚举

    python sublist3r.py -d company.com -e all -br -w wordlist.txt -o deep_results.txt
  3. 验证结果

    cat deep_results.txt | sort -u > final_subdomains.txt
    wc -l final_subdomains.txt
  4. 资产分类

    # 按环境分类
    cat final_subdomains.txt | grep -E "prod|live" > production.txt
    cat final_subdomains.txt | grep -E "test|dev|staging" > non_production.txt
  5. 可访问性检查

    cat final_subdomains.txt | xargs -I {} curl -I -m 2 {}

案例2:安全评估前的攻击面映射#

任务:在安全评估前映射目标的完整攻击面

执行步骤

  1. 多轮枚举

    # 第一轮:使用Sublist3r
    python sublist3r.py -d target.com -e all -o sublist3r_results.txt
    
    # 第二轮:使用其他工具
    subfinder -d target.com -silent -o subfinder_results.txt
    
    # 第三轮:合并结果
    cat sublist3r_results.txt subfinder_results.txt | sort -u > all_subdomains.txt
  2. 服务发现

    cat all_subdomains.txt | xargs -I {} nmap -sV {}
  3. 漏洞扫描

    cat all_subdomains.txt | xargs -I {} nikto -h {}
  4. 报告生成

    # 生成详细报告
    echo "Total subdomains found: $(wc -l all_subdomains.txt | awk '{print $1}')" > report.txt
    echo "\nTop subdomains by frequency:" >> report.txt
    cat all_subdomains.txt | cut -d'.' -f1 | sort | uniq -c | sort -rn | head -10 >> report.txt

总结#

Sublist3r是一款功能强大的子域名枚举工具,专注于通过搜索引擎和其他公共资源发现子域名。通过本教程的学习,您应该能够:

  1. 入门级:掌握基本的子域名枚举和简单的搜索引擎搜索
  2. 初级:了解扫描控制和结果过滤
  3. 中级:使用高级枚举选项和处理认证
  4. 中上级:掌握绕过防护和自定义扫描
  5. 高级:进行大规模扫描和结果分析
  6. 大师级:使用自定义插件和脚本,以及高级扫描策略

Sublist3r的优势在于其结合了多种子域名发现技术,能够从多个来源收集子域名信息。在实际使用中,Sublist3r常常与其他工具结合使用,以获得更全面的子域名枚举结果。