目标信息搜集
yc Lv1

目标信息搜集

目标信息搜集是渗透测试和安全评估的第一阶段,目的是尽可能多地收集目标组织、人员、系统和资产的信息。

搜集阶段分类

1. 被动搜集

不直接与目标系统交互,通过公开渠道获取信息。

2. 主动搜集

与目标系统直接交互,获取更详细的信息。

企业信息搜集

公司基本信息

在线查询平台

工商信息内容

1
2
3
4
5
- 公司名称、法人代表
- 注册资本、成立时间
- 股东信息、高管信息
- 经营范围、注册地址
- 变更记录、行政处罚

技术资产发现

1. IP 地址和域名

1
2
3
4
5
6
7
8
9
10
# Whois 查询
whois example.com

# 使用 IPinfo
curl https://ipinfo.io/8.8.8.8

# 批量查询
for ip in $(cat ips.txt); do
whois $ip | grep -E "Organization|Country|NetRange"
done

2. 网络资产

1
2
3
4
5
6
7
8
9
10
11
# 使用 fofa 搜索
# 语法:domain="example.com"
# URL: https://fofa.info/

# 使用 Hunter 搜索
# 语法:domain.example.com
# URL: https://hunter.qianxin.com/

# 使用 quake 搜索
# 语法:domain:"example.com"
# URL: https://quake.360.cn/

人员信息搜集

社交媒体侦察

LinkedIn

  • 查找公司员工
  • 了解技术栈和职位
  • 识别关键人员

微信/公众号

  • 搜索公司名称
  • 查找技术文章和招聘信息

邮箱搜集

1
2
3
4
5
6
7
8
9
10
# theHarvester 工具
git clone https://github.com/laramies/theHarvester.git
cd theHarvester
python3 theHarvester.py -d example.com -b google -l 500

# 使用多个搜索引擎
python3 theHarvester.py -d example.com -b google,bing,linkedin,github

# 保存结果
python3 theHarvester.py -d example.com -b google -f results.html

邮箱格式猜测

1
2
3
4
5
6
常见格式:
- firstname.lastname@domain.com
- firstinitiallastname@domain.com
- lastname@domain.com
- firstname@domain.com
- flastname@domain.com

网络资产测绘

Shodan

1
2
3
4
5
6
7
8
9
10
# 搜索目标组织的资产
# 语法:org:"Organization Name"

# API 使用
curl -X GET "https://api.shodan.io/shodan/host/search?query=org:Example&key=YOUR_API_KEY"

# Python SDK
import shodan
api = shodan.Shodan('YOUR_API_KEY')
results = api.search('org:"Example Company"')

Fofa

1
2
3
4
# 搜索语法
domain="example.com"
cert="example.com"
icon_hash="-123456789"

Hunter

1
2
3
4
# 搜索语法
domain.example.com
web.body="example.com"
web.title="管理后台"

Censys

1
2
3
4
5
# 搜索证书
curl -s "https://search.censys.io/api/v2/certificates/search?q=names: example.com&api_key=YOUR_API_KEY"

# 搜索主机
curl -s "https://search.censys.io/api/v2/hosts/search?q=services.tls.certificate.parsed.names: example.com"

GitHub 情报搜集

敏感信息搜索

1
2
3
4
5
6
7
8
9
10
# 使用 GitHub API
# 搜索特定组织的仓库
curl "https://api.github.com/orgs/example-org/repos"

# 搜索代码中的敏感信息
# 语法:org:example-org password OR api_key OR secret

# 使用 gitdorker 工具
git clone https://github.com/UncleJ4ck/gitdorker.git
python3 gitdorker.py -i domains.txt -s dorks.txt -o output/

常用 GitHub Dorks

1
2
3
4
5
6
7
8
9
10
11
# API 密钥
org:target filename:.env API_KEY
org:target filename:config.ini api_key

# 数据库连接
org:target extension:sql mysql_password
org:target extension:env DB_PASSWORD

# 凭证文件
org:target filename:credentials
org:target filename:.aws credentials

开源情报 (OSINT) 工具集成

Maltego

可视化情报收集工具,支持多种转换。

常用转换:

  • DNS 枚举
  • Whois 查询
  • 社交媒体搜索
  • 域名关联

SpiderFoot

自动化 OSINT 收集工具。

1
2
3
4
5
6
7
8
# 安装
git clone https://github.com/smicallef/spiderfoot.git
cd spiderfoot
pip3 install -r requirements.txt
python3 sf.py -l 127.0.0.1:5001

# 扫描目标
python3 sf.py -m auto_scan -t example.com

端口和服务扫描

Nmap 基础扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# TCP 扫描
nmap -sS -p- target.com

# UDP 扫描
nmap -sU -p- target.com

# 服务版本检测
nmap -sV -sC target.com

# 操作系统检测
nmap -O target.com

# 脚本扫描
nmap --script vuln -p- target.com

Masscan 快速扫描

1
2
3
4
5
6
7
8
# 快速端口扫描
masscan -p1-65535 target.com --rate=10000

# 指定端口范围
masscan -p80,443,8080,8443 target.com --rate=1000

# 输出到文件
masscan -p1-65535 target.com -oL results.txt --rate=10000

Web 应用发现

httpx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 安装
go install -v github.com/projectdiscovery/httpx@latest

# 探测活跃主机
httpx -l hosts.txt -o alive.txt

# 获取标题和技术栈
httpx -l hosts.txt -title -tech-detect -o details.txt

# 状态码探测
httpx -l hosts.txt -status-code -o status.txt

# 跟随重定向
httpx -l hosts.txt -follow-redirects -o results.txt

nuclei

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 安装
go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest

# 基础扫描
nuclei -l hosts.txt

# 使用特定模板
nuclei -l hosts.txt -t /path/to/templates/

# 更新模板
nuclei -update-templates

# 严重漏洞扫描
nuclei -l hosts.txt -severity critical,high

网站指纹识别

Wappalyzer

1
2
3
4
# API 使用
curl -X POST "https://api.wappalyzer.com/v2/analyze" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "apiKey": "YOUR_API_KEY"}'

WhatWeb

1
2
3
4
5
6
7
8
9
10
11
# 基本扫描
whatweb example.com

# 详细输出
whatweb -v example.com

# 批量扫描
whatweb -a 3 -i urls.txt -o output.txt

# 输出 JSON
whatweb --log-json=results.json example.com

搜集框架

收集清单

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## 目标信息搜集清单

### 组织信息
- [ ] 公司名称、法人、注册资本
- [ ] 业务范围、主要产品
- [ ] 分支机构、关联公司
- [ ] 招聘信息(技术栈)
- [ ] 新闻动态

### 网络资产
- [ ] 主域名和子域名
- [ ] IP 地址段
- [ ] CDN 使用情况
- [ ] 云服务使用情况
- [ ] 开放端口和服务

### 人员信息
- [ ] 员工邮箱
- [ ] 社交媒体账号
- [ ] 技术人员信息
- [ ] GitHub 账号

### 技术信息
- [ ] Web 应用框架
- [ ] 前端技术栈
- [ ] CMS 类型
- [ ] WAF 检测
- [ ] API 端点

### 安全状况
- [ ] 历史漏洞
- [ ] 安全事件
- [ ] 安全防护措施
- [ ] 合规认证

信息整理和分析

建立资产清单

1
2
3
4
5
6
7
8
9
10
11
12
13
# 合并去重
cat *.txt | sort -u > assets.txt

# 分类整理
# - 域名列表
# - IP 列表
# - 邮箱列表
# - URL 列表

# 关联分析
# - IP 与域名关联
# - 人员与资产关联
# - 技术栈与应用关联

攻击面映射

使用工具绘制攻击面图谱:

1
2
3
4
5
6
# 使用 Attack Surface Mapper
git clone https://github.com/six2dez/AttackSurfaceMapper.git
python3 attack-surface-mapper.py example.com

# 生成可视化报告
python3 attack-surface-mapper.py -o report.html example.com

最佳实践

  1. 系统化搜集

    • 按照清单逐项完成
    • 记录数据来源和时间
    • 保持信息的时效性
  2. 多源验证

    • 交叉验证不同渠道的信息
    • 确认信息的准确性
  3. 隐私保护

    • 遵守法律法规
    • 不搜集个人敏感信息
    • 仅用于合法授权测试
  4. 持续更新

    • 信息定期更新
    • 关注目标变化
    • 维护资产清单

防御建议

减少信息泄露

  1. 限制公开信息

    • 最小化 Whois 信息暴露
    • 审查公开文档中的敏感信息
  2. 监控暴露情况

    • 定期搜索敏感信息
    • 使用 Google Alerts
    • 监控 GitHub 泄露
  3. 加强资产管理

    • 建立资产清单
    • 及时下线废弃资产
    • 规范域名管理
  4. 人员安全意识

    • 社交媒体使用规范
    • 邮箱使用规范
    • 代码发布规范
由 Hexo 驱动 & 主题 Keep