渗透测试&红队之信息收集
字数 4291 2025-08-22 12:22:42

渗透测试与红队信息收集技术详解

前言

信息收集是渗透测试和红队行动中至关重要的初始环节。通过全面收集目标资产信息,可以扩大攻击面,增加发现突破口的机会。本文将系统性地介绍各种信息收集技术和方法,涵盖企业产权收集、子域名查询、端口扫描、目录扫描、CMS识别、源码泄露检测等多个方面。

企业产权信息收集

在线平台工具

  1. 企业信息查询平台

    • 天眼查(https://www.tianyancha.com/)
    • 企查查(https://www.qcc.com/)
    • 小蓝本(https://sou.xiaolanben.com/pc)
    • 爱企查(https://aiqicha.baidu.com/)
  2. 备案信息查询

    • 工信部备案查询(https://beian.miit.gov.cn/)
    • ICP备案查询(https://www.beianx.cn/)
    • Kali Whois查询:whois xxx.com

网络空间搜索引擎

  • FOFA(https://fofa.info/)
  • 钟馗之眼(https://www.zoomeye.org/)
  • 零零信安(https://0.zone/)
  • Shodan(https://www.shodan.io/)
  • Censys(https://censys.com/)
  • 鹰图(https://hunter.qianxin.com/)
  • 360Quake(https://quake.360.net/)

自动化资产收集工具

ARL(Asset Reconnaissance Lighthouse)

  • 下载地址:https://github.com/ki9mu/ARL-plus-docker
  • 文档:https://tophanttechnology.github.io/ARL-doc/
  • 功能:快速侦察与目标关联的互联网资产,构建基础资产信息库

移动资产收集

APP应用收集

  • 七麦APP搜索(https://www.qimai.cn/)
  • 各大应用商店搜索

公众号信息

  • 微信搜一搜功能
  • 搜狗微信搜索(https://weixin.sogou.com/)

小程序资产

  • 通过支付宝/微信平台搜索
  • 关注公司运营人员获取
  • 社工方式获取

单一目标信息收集

操作系统识别

  1. TTL值判断

    • WINDOWS NT/2000 TTL:128
    • WINDOWS 95/98 TTL:32
    • UNIX TTL:255
    • LINUX TTL:64
    • WIN7 TTL:64
  2. Nmap识别

    nmap -O xxx.xxx.xxx.xxx
    
  3. 大小写敏感测试

    • Windows服务器对目录大小写不敏感
    • Linux服务器对目录大小写敏感

IP反查工具

  • ip138反查(https://site.ip138.com/)
  • 微步在线(https://x.threatbook.cn/)
  • 爱站反查域名(https://dns.aizhan.com/)

子域名查询技术

DNS解析工具

  • ip138(https://site.ip138.com/)
  • DnsDumpster(https://dnsdumpster.com/)
  • hackertarget(https://hackertarget.com/find-dns-host-records/)

爆破工具

Gobuster

apt-get install gobuster
gobuster dns -d xxxx.com -t 50 -w '/root/Documents/domains.txt'

网络空间搜索引擎语法

通常使用 domain="xxxx.com" 形式搜索子域名信息

在线子域名收集平台

  • dnsdumpster(https://dnsdumpster.com/)
  • bugscanner(http://tools.bugscaner.com/subdomain/)

子域名收集工具

  1. OneForAll

    • 下载地址:https://github.com/shmilylty/OneForAll
    • 功能特点:
      • 支持子域爆破、验证、爬取、置换、接管
      • 处理功能强大,支持多种导出格式
      • 速度极快,使用多线程和异步处理
    • 使用命令:
      python oneforall.py --target http://xxx.com run
      
  2. Layer子域名挖掘机

    • 下载地址:https://github.com/euphrat1ca/LayerDomainFinder/releases
    • 特点:操作简便,支持多种导出模式
  3. Subfinder

    • 安装:
      sudo apt-get install subfinder
      
    • 使用:
      subfinder -d xxxx.com
      
    • 特点:
      • 多源搜集(Google、Shodan、Censys等)
      • 快速并发
      • 支持DNS数据源和API集成
      • 支持结果导出和自定义字典

证书查询

利用证书透明度查询子域:

  • crtsh(https://crt.sh/)
  • censys(https://censys.io/certificates)
  • spyse(https://spyse.com/search/certificate)
  • certspotter(https://sslmate.com/certspotter/api/)

威胁情报平台

  • 微步(https://x.threatbook.cn/)
  • 绿盟科技威胁情报云(https://ti.nsfocus.com/)
  • 华为安全中心平台(https://isecurity.huawei.com/sec)

爬虫收集

通过定制爬虫提取JS信息、源码信息、目录信息中的域名信息

信息去重脚本

import urllib.parse

def normalize_url(url):
    if not url.startswith("http://") and not url.startswith("https://"):
        url = "http://" + url
    parsed_url = urllib.parse.urlparse(url)
    return urllib.parse.urlunparse(parsed_url._replace(path='/', params='', query='', fragment=''))

def process_domains_file(file_path):
    seen_urls = set()
    result = []
    with open(file_path, 'r', encoding='utf-8') as file:
        for line in file:
            url = line.strip()
            normalized_url = normalize_url(url)
            if normalized_url not in seen_urls:
                seen_urls.add(normalized_url)
                result.append(normalized_url)
    
    with open('domains_new.txt', 'w', encoding='utf-8') as new_file:
        for url in result:
            new_file.write(url + '\n')
    return result

file_path = "domains.txt"
final_urls = process_domains_file(file_path)
for url in final_urls:
    print(url)

端口扫描技术

在线端口扫描平台

  • ToolLine(https://toolonline.net/port-scan)
  • Ip33(http://www.ip33.com/port_scan.html)
  • coolad(http://coolaf.com/tool/port)

Nmap扫描

  • 下载地址:https://nmap.org/
  • 中文手册:https://www.cnblogs.com/HOsystem/p/16538678.html
  • 常用命令:
    nmap -sU --top-ports 20 xxx.com  # 扫描UDP top20端口
    nmap -T4 -O -sV -p- kali.wiki    # 扫描全端口,识别操作系统和服务
    

Masscan扫描

  • 下载地址:https://github.com/robertdavidgraham/masscan
  • 使用命令:
    masscan -p 0-5000 xxx.xxx.xxx.xxx --rate=3000
    
  • 特点:号称世界上最快的扫描软件,可在几分钟内扫描整个互联网端口

网络测绘空间

通过测绘空间搜索单个IP地址,探测目标主机开放过的端口服务

目录扫描技术

字典资源

  • Web-Dict:https://github.com/arrdres/Web-Dict

扫描工具

  1. 御剑目录扫描

    • 下载地址:https://github.com/foryujian/yjdirscan
    • 特点:支持爬虫、fuzz、自定义字典、UA修改等功能
  2. 7KbScan

    • 下载地址:https://github.com/7kbstorm/7kbscan-WebPathBrute
    • 功能:Web路径暴力探测工具
  3. dirsearch

    • 下载地址:https://github.com/maurosoria/dirsearch
    • 特点:基于Python的命令行工具,用于暴力扫描页面结构
  4. Gobuster

    • 常用命令:
      gobuster dir -u http://xxx.com/ -w directory-list.txt
      
    • 参数说明:
      • -C/--cookie:请求中使用的cookie
      • -x/--extensions:指定枚举的扩展名
      • -H/--headers:指定请求头
      • -k/--no-tls-validation:跳过TLS证书验证
      • -n/--no-status:不打印状态码
      • -s/--status-codes:肯定的状态码
      • -b/--status-codes-blacklist:负面的状态码
      • -U/--username:Basic验证用户名
      • -P/--password:Basic验证密码

CMS识别技术

在线识别平台

  • 云悉指纹识别(http://finger.tidesec.com/)
  • 数字观星(https://fp.shuziguanxing.com/)

识别工具

  1. TideFinger

    • 下载地址:https://github.com/TideSec/TideFinger
    • 使用:
      TideFinger_Win.exe -u http://xxxx.com
      
  2. WhatWeb

    • 使用命令:
      whatweb xxxx.com
      
  3. Wappalyzer

    • 浏览器扩展,可在各浏览器插件商城下载
    • 功能:识别网站使用的Web服务器、CMS、编程语言等技术栈

经验判断与AI辅助

当工具无法准确识别时,可通过以下方式判断:

  • 分析网站目录结构
  • 检查JS信息
  • 查看版权信息
  • 将收集信息提交AI分析

源码泄露检测

网站备份文件检测

常见备份文件后缀:

  • .rar, .zip, .7z, .tar.gz
  • .bak, .txt, .old, .temp
  • .phps, .sql

Git源码泄露

  1. 检测方法:

    • 访问/.git/目录,若存在或显示403则可能存在泄露
  2. GitHack工具

    • 下载地址:https://github.com/lijiejie/GitHack
    • 使用:
      python3 GitHack.py http://xxxx.com/
      

SVN源码泄露

  1. 检测方法:

    • 检查.svn隐藏文件夹是否存在
  2. SvnHack工具

    • 下载地址:https://github.com/callmefeifei/SvnHack
    • 使用(Python 2.7):
      python2 SvnHack.py -u http://xxxx.com/
      

GitHub源码泄露

搜索语法示例:

  • in:name target:仓库标题搜索
  • language:java target:在Java代码中搜索
  • in:descripton target:仓库描述搜索
  • in:readme target:Readme文件搜索
  • user:target:通过用户名搜索
  • license:apache-3.0 target:按LICENSE搜索
  • user:target in:name target:组合搜索

API与JS信息收集

Packer-Fuzzer

  • 下载地址:https://github.com/rtcatc/Packer-Fuzzer
  • 功能:针对Webpack等前端打包工具构建的网站进行安全检测
  • 常用命令:
    python3 PackerFuzzer.py -u http://xxxx.com -t adv -p http://127.0.0.1:8080 -f 1 -r html
    python3 PackerFuzzer.py -u http://xxxx.com -j http://xxxx.com/js/index.js,http://xxxx.com/static/js/cookieAlert.js
    python3 PackerFuzzer.py -u http://xxxx.com -b v1
    

URLFinder

  • 下载地址:https://github.com/pingc0y/URLFinder
  • 功能:快速提取页面中的js与url,查找敏感信息或未授权API接口
  • 使用:
    URLFinder.exe -u http://xxxx.com -s 200,403 -m 3
    

JSFinder

  • 下载地址:https://github.com/Threezh1/JSFinder
  • 功能:快速从js文件中提取URL和子域名

总结

本文全面介绍了渗透测试和红队行动中的信息收集技术,从企业产权信息到具体目标的深入侦察,涵盖了多种工具和方法。在实际操作中,应根据目标特点和自身需求选择合适的工具组合,同时注意遵守法律法规和道德准则。信息收集的质量直接影响后续渗透测试的成功率,因此需要耐心细致地进行全面收集和分析。

渗透测试与红队信息收集技术详解 前言 信息收集是渗透测试和红队行动中至关重要的初始环节。通过全面收集目标资产信息,可以扩大攻击面,增加发现突破口的机会。本文将系统性地介绍各种信息收集技术和方法,涵盖企业产权收集、子域名查询、端口扫描、目录扫描、CMS识别、源码泄露检测等多个方面。 企业产权信息收集 在线平台工具 企业信息查询平台 : 天眼查(https://www.tianyancha.com/) 企查查(https://www.qcc.com/) 小蓝本(https://sou.xiaolanben.com/pc) 爱企查(https://aiqicha.baidu.com/) 备案信息查询 : 工信部备案查询(https://beian.miit.gov.cn/) ICP备案查询(https://www.beianx.cn/) Kali Whois查询: whois xxx.com 网络空间搜索引擎 FOFA(https://fofa.info/) 钟馗之眼(https://www.zoomeye.org/) 零零信安(https://0.zone/) Shodan(https://www.shodan.io/) Censys(https://censys.com/) 鹰图(https://hunter.qianxin.com/) 360Quake(https://quake.360.net/) 自动化资产收集工具 ARL(Asset Reconnaissance Lighthouse) : 下载地址:https://github.com/ki9mu/ARL-plus-docker 文档:https://tophanttechnology.github.io/ARL-doc/ 功能:快速侦察与目标关联的互联网资产,构建基础资产信息库 移动资产收集 APP应用收集 七麦APP搜索(https://www.qimai.cn/) 各大应用商店搜索 公众号信息 微信搜一搜功能 搜狗微信搜索(https://weixin.sogou.com/) 小程序资产 通过支付宝/微信平台搜索 关注公司运营人员获取 社工方式获取 单一目标信息收集 操作系统识别 TTL值判断 : WINDOWS NT/2000 TTL:128 WINDOWS 95/98 TTL:32 UNIX TTL:255 LINUX TTL:64 WIN7 TTL:64 Nmap识别 : 大小写敏感测试 : Windows服务器对目录大小写不敏感 Linux服务器对目录大小写敏感 IP反查工具 ip138反查(https://site.ip138.com/) 微步在线(https://x.threatbook.cn/) 爱站反查域名(https://dns.aizhan.com/) 子域名查询技术 DNS解析工具 ip138(https://site.ip138.com/) DnsDumpster(https://dnsdumpster.com/) hackertarget(https://hackertarget.com/find-dns-host-records/) 爆破工具 Gobuster : 网络空间搜索引擎语法 通常使用 domain="xxxx.com" 形式搜索子域名信息 在线子域名收集平台 dnsdumpster(https://dnsdumpster.com/) bugscanner(http://tools.bugscaner.com/subdomain/) 子域名收集工具 OneForAll : 下载地址:https://github.com/shmilylty/OneForAll 功能特点: 支持子域爆破、验证、爬取、置换、接管 处理功能强大,支持多种导出格式 速度极快,使用多线程和异步处理 使用命令: Layer子域名挖掘机 : 下载地址:https://github.com/euphrat1ca/LayerDomainFinder/releases 特点:操作简便,支持多种导出模式 Subfinder : 安装: 使用: 特点: 多源搜集(Google、Shodan、Censys等) 快速并发 支持DNS数据源和API集成 支持结果导出和自定义字典 证书查询 利用证书透明度查询子域: crtsh(https://crt.sh/) censys(https://censys.io/certificates) spyse(https://spyse.com/search/certificate) certspotter(https://sslmate.com/certspotter/api/) 威胁情报平台 微步(https://x.threatbook.cn/) 绿盟科技威胁情报云(https://ti.nsfocus.com/) 华为安全中心平台(https://isecurity.huawei.com/sec) 爬虫收集 通过定制爬虫提取JS信息、源码信息、目录信息中的域名信息 信息去重脚本 端口扫描技术 在线端口扫描平台 ToolLine(https://toolonline.net/port-scan) Ip33(http://www.ip33.com/port_ scan.html) coolad(http://coolaf.com/tool/port) Nmap扫描 下载地址:https://nmap.org/ 中文手册:https://www.cnblogs.com/HOsystem/p/16538678.html 常用命令: Masscan扫描 下载地址:https://github.com/robertdavidgraham/masscan 使用命令: 特点:号称世界上最快的扫描软件,可在几分钟内扫描整个互联网端口 网络测绘空间 通过测绘空间搜索单个IP地址,探测目标主机开放过的端口服务 目录扫描技术 字典资源 Web-Dict:https://github.com/arrdres/Web-Dict 扫描工具 御剑目录扫描 : 下载地址:https://github.com/foryujian/yjdirscan 特点:支持爬虫、fuzz、自定义字典、UA修改等功能 7KbScan : 下载地址:https://github.com/7kbstorm/7kbscan-WebPathBrute 功能:Web路径暴力探测工具 dirsearch : 下载地址:https://github.com/maurosoria/dirsearch 特点:基于Python的命令行工具,用于暴力扫描页面结构 Gobuster : 常用命令: 参数说明: -C/--cookie :请求中使用的cookie -x/--extensions :指定枚举的扩展名 -H/--headers :指定请求头 -k/--no-tls-validation :跳过TLS证书验证 -n/--no-status :不打印状态码 -s/--status-codes :肯定的状态码 -b/--status-codes-blacklist :负面的状态码 -U/--username :Basic验证用户名 -P/--password :Basic验证密码 CMS识别技术 在线识别平台 云悉指纹识别(http://finger.tidesec.com/) 数字观星(https://fp.shuziguanxing.com/) 识别工具 TideFinger : 下载地址:https://github.com/TideSec/TideFinger 使用: WhatWeb : 使用命令: Wappalyzer : 浏览器扩展,可在各浏览器插件商城下载 功能:识别网站使用的Web服务器、CMS、编程语言等技术栈 经验判断与AI辅助 当工具无法准确识别时,可通过以下方式判断: 分析网站目录结构 检查JS信息 查看版权信息 将收集信息提交AI分析 源码泄露检测 网站备份文件检测 常见备份文件后缀: .rar, .zip, .7z, .tar.gz .bak, .txt, .old, .temp .phps, .sql Git源码泄露 检测方法: 访问 /.git/ 目录,若存在或显示403则可能存在泄露 GitHack工具 : 下载地址:https://github.com/lijiejie/GitHack 使用: SVN源码泄露 检测方法: 检查 .svn 隐藏文件夹是否存在 SvnHack工具 : 下载地址:https://github.com/callmefeifei/SvnHack 使用(Python 2.7): GitHub源码泄露 搜索语法示例: in:name target :仓库标题搜索 language:java target :在Java代码中搜索 in:descripton target :仓库描述搜索 in:readme target :Readme文件搜索 user:target :通过用户名搜索 license:apache-3.0 target :按LICENSE搜索 user:target in:name target :组合搜索 API与JS信息收集 Packer-Fuzzer 下载地址:https://github.com/rtcatc/Packer-Fuzzer 功能:针对Webpack等前端打包工具构建的网站进行安全检测 常用命令: URLFinder 下载地址:https://github.com/pingc0y/URLFinder 功能:快速提取页面中的js与url,查找敏感信息或未授权API接口 使用: JSFinder 下载地址:https://github.com/Threezh1/JSFinder 功能:快速从js文件中提取URL和子域名 总结 本文全面介绍了渗透测试和红队行动中的信息收集技术,从企业产权信息到具体目标的深入侦察,涵盖了多种工具和方法。在实际操作中,应根据目标特点和自身需求选择合适的工具组合,同时注意遵守法律法规和道德准则。信息收集的质量直接影响后续渗透测试的成功率,因此需要耐心细致地进行全面收集和分析。