03 - 互联网侦察与目标测绘

核心理念:侦察占红队工作的 60% 以上。你攻击的目标不是凭空出现的 IP,而是有域名、有子域、有员工邮箱、有云服务、有第三方依赖的真实组织。测绘得越细,攻击面越大。

本章目标:给定一个真实域名 tesla.com(也可以换成任何你授权的靶场域名),从零开始完成被动+主动侦察,建立完整目标档案。

环境确认

# 确认已装工具
which nmap gobuster ffuf nikto whatweb amass subfinder rustscan feroxbuster theHarvester whois dig
# 如果某个命令 not found,用 pacman -S 或 yay -S 装

实战1:WHOIS 信息收集

WHOIS 是域名注册信息数据库。注册域名时必须提供注册人、注册商、DNS 服务器等信息。GDPR 后很多信息被隐藏,但仍有大量可利用的数据。

whois tesla.com

预期输出(精简关键部分)

Domain Name: TESLA.COM
Registry Domain ID: 219734_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.comlaude.com
Registrar: Nom-iq Ltd. dba COM LAUDE
Updated Date: 2025-01-15T10:30:00Z
Creation Date: 1992-11-05T05:00:00Z
Registry Expiry Date: 2026-11-06T05:00:00Z
Registrar Abuse Contact Email: abuse@comlaude.com
Name Server: NS1.TESLA.COM
Name Server: NS2.TESLA.COM
Name Server: NS3.TESLA.COM
DNSSEC: unsigned

关键信息提取

字段含义攻击价值
Creation Date1992 年注册老域名,信誉分高,不会被安全网关轻易拦截
Expiry Date2026-11-06距离过期还有多久?快过期的域名可能被接管
RegistrarCOM LAUDE注册商是谁?有些注册商安全性差,可社工
Name Serverns1.tesla.com自建 DNS,说明有内部基础设施
DNSSECunsigned未启用 DNSSEC,DNS 欺骗风险存在

实战技巧:域名过期接管(Expired Domain Takeover)

# 批量检查一批域名的过期时间
for domain in $(cat targets.txt); do
    expiry=$(whois $domain | grep -i "Registry Expiry Date" | awk '{print $NF}')
    echo "$domain expires: $expiry"
done
 
# 用 whois 的 JSON 输出来程序化解析(部分注册商支持)
whois tesla.com | grep -E "Creation|Expir|Registrar|Name Server"

反向 WHOIS 查询:如果你想找同一个注册人注册的所有域名(用于关联攻击面):

# 用 whoxy.com 或 viewdns.info 的 API(浏览器操作)
# CLI 替代方案:
curl -s "https://api.viewdns.info/reversewhois/?q=tesla@example.com&apikey=YOURKEY"

实战3:子域名枚举

子域名是攻击面扩展的核心。一个组织可能只有 1 个主域名,但有 500+ 子域名,每个子域名对应不同的服务、不同的漏洞。

3.1 Subfinder(被动收集)

Subfinder 通过查询几十个被动数据源(证书透明度日志、搜索引擎缓存、DNSDB 等)来收集子域名,完全不碰目标服务器。

subfinder -d tesla.com -o /tmp/tesla_subs_subfinder.txt -v

-v 会显示每个子域名来自哪个数据源。

预期输出

[INF] Enumerating subdomains for tesla.com
[crtsh] www.tesla.com
[crtsh] shop.tesla.com
[crtsh] api.tesla.com
[crtsh] auth.tesla.com
[crtsh] m.tesla.com
[crtsh] energy.tesla.com
[abuseipdb] staging.tesla.com
[alienvault] vpn.tesla.com
[riddler] dev.tesla.com
[Source: crtsh] mail.tesla.com
...
[INF] Found 247 subdomains for tesla.com

查看数据源统计

subfinder -d tesla.com -sources
  • crtsh = 证书透明度日志(最丰富的数据源,免费)
  • abuseipdb = 滥用 IP 数据库
  • alienvault = AlienVault OTX
  • riddler = Riddler.io

只使用特定数据源

subfinder -d tesla.com -sources crtsh,alienvault -o subs.txt

3.2 Amass(深度被动+主动)

Amass 比 Subfinder 更强大,除了被动收集还支持主动探测。

# 纯被动模式(不碰目标)
amass enum -passive -d tesla.com -o /tmp/tesla_subs_amass.txt

预期输出

OWASP Amass v4.2.0
[Passive] www.tesla.com
[Passive] shop.tesla.com
[Passive] api.tesla.com
[Passive] auth.tesla.com
...
# 带主动探测的模式(会发 DNS 解析——算碰目标但很轻)
amass enum -active -d tesla.com -o /tmp/tesla_active.txt
 
# 使用字典爆破子域名
amass enum -d tesla.com -brute -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -o /tmp/tesla_brute.txt
 
# alt 模式:基于已知子域名进行排列组合变异
amass enum -d tesla.com -alt 10 -o /tmp/tesla_alt.txt

-alt 10 会根据已有子域名生成变体,比如已知 dev.tesla.com,会尝试 dev1.tesla.comdev-admin.tesla.comdev.api.tesla.com 等。

Amass 的输出文件是数据库格式,可以随时查询

# 查看数据库中收集到的所有域名
amass db -names -d tesla.com
 
# 查看所有 IP 地址
amass db -ips -d tesla.com
 
# 导出可视化网络拓扑图
amass viz -d tesla.com -o /tmp/tesla_viz
# 会生成 DOT 文件,用 dot 转成 PNG
dot -Tpng /tmp/tesla_viz.dot -o /tmp/tesla_network.png

3.3 合并与去重

# 合并所有子域名来源
cat /tmp/tesla_subs_subfinder.txt /tmp/tesla_subs_amass.txt | sort -u > /tmp/tesla_all_subs.txt
 
# 统计数量
wc -l /tmp/tesla_all_subs.txt

预期输出

487 /tmp/tesla_all_subs.txt

3.4 解析子域名并检查存活

收集到几百个子域名后,你需要知道哪些实际在线、开放了哪些端口。

# 用 dnsx 快速批量解析(比手动 dig 快 100 倍)
dnsx -l /tmp/tesla_all_subs.txt -silent -a -only-valid -o /tmp/tesla_resolved.txt
 
# 如果没有 dnsx,用 dig 循环(较慢但可用)
while read sub; do
    ip=$(dig $sub A +short 2>/dev/null)
    if [ -n "$ip" ]; then
        echo "$sub -> $ip"
    fi
done < /tmp/tesla_all_subs.txt > /tmp/tesla_resolved.txt
 
# 提取纯 IP 列表去重
awk '{print $NF}' /tmp/tesla_resolved.txt | sort -u | grep -v "^$" > /tmp/tesla_ips.txt

预期输出

shop.tesla.com -> 23.45.67.89
api.tesla.com -> 23.45.67.90
auth.tesla.com -> 23.45.67.91
staging.tesla.com -> 104.16.123.45
dev.tesla.com -> 104.16.123.46

3.5 快速 HTTP 存活检测

# 用 httpx 批量检测哪些子域名有 Web 服务
httpx -l /tmp/tesla_all_subs.txt -silent -title -status-code -tech-detect -o /tmp/tesla_web.txt
 
# 如果没有 httpx,用 curl 批量检测
while read sub; do
    status=$(curl -s -o /dev/null -w "%{http_code}" -m 5 "https://$sub" 2>/dev/null)
    if [ "$status" != "000" ]; then
        echo "$sub -> HTTPS $status"
    fi
    status=$(curl -s -o /dev/null -w "%{http_code}" -m 5 "http://$sub" 2>/dev/null)
    if [ "$status" != "000" ]; then
        echo "$sub -> HTTP $status"
    fi
done < /tmp/tesla_all_subs.txt > /tmp/tesla_http_check.txt

Part 2: 主动扫描(直接与目标交互)

警告:主动扫描会产生网络流量,目标会记录你的 IP。以下所有操作假设你已在授权范围内或有合法渗透测试授权。

实战6:Nmap 深度扫描

Nmap 不是只用来 nmap -sV target 就完事的。真正实战中要利用 Nmap 的整个能力栈。

6.1 主机发现(先确定谁活着)

# ICMP + TCP ACK + TCP SYN Ping 组合探测
sudo nmap -sn -PE -PA21,22,80,443 -PS21,22,80,443 -oA /tmp/host_discovery 192.168.56.0/24
  • -PE:ICMP Echo
  • -PA:TCP ACK Ping(常用端口)
  • -PS:TCP SYN Ping
  • 三个组合能绕过大多数防火墙

预期输出

Starting Nmap 7.94 ...
Nmap scan report for 192.168.56.1
Host is up (0.00042s latency).
Nmap scan report for 192.168.56.102
Host is up (0.00089s latency).
Nmap scan report for 192.168.56.103
Host is up (0.0012s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 15.23 seconds
# 从输出提取存活 IP
grep "Nmap scan report" /tmp/host_discovery.nmap | awk '{print $NF}' | tr -d '()' > /tmp/alive_hosts.txt

6.2 全端口 SYN 扫描(Stealth Scan)

SYN 扫描不完成三次握手,只发 SYN 包,收到 SYN-ACK 就发 RST 断开——目标应用层日志通常不记录。

# 需要 root 权限
sudo nmap -sS -p- -T4 --min-rate 1000 -oA /tmp/full_syn_scan 192.168.56.102

参数解释:

  • -sS:SYN 扫描(半开扫描,最常用的隐蔽扫描)
  • -p-:全端口 1-65535
  • -T4:时间模板 4(激进但不疯狂),比默认 T3 快 4-5 倍
  • --min-rate 1000:每秒最少发 1000 个包,保证扫描速度
  • -oA:三种格式同时输出(.nmap .gnmap .xml)

预期输出

Nmap scan report for 192.168.56.102
Not shown: 65528 filtered ports
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
443/tcp   open  https
3306/tcp  open  mysql
8080/tcp  open  http-proxy
8443/tcp  open  https-alt
27017/tcp open  mongod

Nmap done: 1 IP address scanned in 34.21 seconds
  • filtered 端口 = 被防火墙挡住,无法判断开没开
  • closed 端口 = 确实关闭,可访问但没人监听
  • open 端口 = 这就是你的攻击面

6.3 提取开放端口列表

# 从 gnmap 格式提取(最方便解析)
grep "Ports:" /tmp/full_syn_scan.gnmap | grep "open" | sed 's/.*Ports: //' | tr ',' '\n' | grep "open" | awk -F '/' '{print $1}' | sort -n
 
# 保存为逗号分隔列表(用于下一步扫描)
PORTS=$(grep "Ports:" /tmp/full_syn_scan.gnmap | grep -oP '\d+(?=/open/)' | sort -n | paste -sd,)
echo $PORTS
# 输出: 22,80,443,3306,8080,8443,27017

6.4 服务版本深度探测

# 针对开放端口做深度识别
sudo nmap -sV --version-intensity 9 -sC -p $PORTS -oA /tmp/service_deep 192.168.56.102
  • --version-intensity 9:最大探测强度(0-9),发更多探测包,识别更准但更吵
  • -sC:运行默认 NSE 脚本集

6.5 OS 指纹识别

# OS 检测
sudo nmap -O --osscan-guess -p $PORTS --max-os-tries 5 -oA /tmp/os_detect 192.168.56.102

预期输出

Device type: general purpose
Running: Linux 5.X|6.X
OS CPE: cpe:/o:linux:linux_kernel:5 cpe:/o:linux:linux_kernel:6
OS details: Linux 5.15 - 6.5
Uptime guess: 12.345 days (since Mon Jan 01 10:00:00 2024)

Uptime 的攻击价值:如果 uptime 是 300 天 → 没打过补丁,内核提权 CVE 可能还在。

6.6 NSE 脚本引擎——这才是 Nmap 的灵魂

# 列出所有脚本分类
ls /usr/share/nmap/scripts/ | cut -d- -f1 | sort -u

输出

afp
ajp
bacnet
broadcast
brute
clamav
dhcp
dns
drda
...
# 查看每个分类有多少个脚本
ls /usr/share/nmap/scripts/ | cut -d- -f1 | sort | uniq -c | sort -rn
# 漏洞扫描——用 vuln 类别(包含几十个 CVE 检测脚本)
sudo nmap --script vuln -p $PORTS -oA /tmp/nmap_vuln 192.168.56.102

预期输出(关键部分)

Host script results:
| smb-vuln-ms17-010:
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers
|     State: VULNERABLE
|     IDs: CVE:CVE-2017-0143
|     Risk factor: HIGH
|_     Description: ...

| http-slowloris-check:
|   VULNERABLE:
|   Slowloris DOS attack
|     State: LIKELY VULNERABLE
|     IDs: CVE:CVE-2007-6750
|_    Description: ...
# HTTP 全套脚本——针对Web服务的所有检测
sudo nmap --script "http-*" -p 80,443,8080,8443 -oA /tmp/nmap_http 192.168.56.102

可能的发现:http-enum 找到隐藏目录、http-title 获取页面标题、http-robots.txt 获取 robots 文件、http-methods 检测允许的 HTTP 方法。

# SMB 枚举(如果目标开放 445 端口)
sudo nmap --script smb-os-discovery,smb-enum-shares,smb-enum-users,smb-vuln-ms17-010 -p 445 -oA /tmp/nmap_smb 192.168.56.102
# SSH 检测算法和认证方式
sudo nmap --script ssh2-enum-algos,ssh-auth-methods -p 22 -oA /tmp/nmap_ssh 192.168.56.102

预期输出

22/tcp open  ssh
| ssh2-enum-algos:
|   kex_algorithms: (8)
|       curve25519-sha256
|       ecdh-sha2-nistp256
|       diffie-hellman-group14-sha256
|   server_host_key_algorithms: (5)
|       ssh-ed25519
|       rsa-sha2-512
|   encryption_algorithms: (6)
|       chacha20-poly1305@openssh.com
|       aes256-gcm@openssh.com
|   mac_algorithms: (5)
|       hmac-sha2-256
...
  • 老旧的算法(如 diffie-hellman-group1-sha1)说明服务器版本老
  • 弱算法可能允许降级攻击
# 数据库探测
sudo nmap --script mysql-*,mongodb-* -p 3306,27017 192.168.56.102
# DNS 相关(如果 53 端口开放)
sudo nmap --script dns-* -p 53 -oA /tmp/nmap_dns 192.168.56.102

6.7 Nmap 防火墙/IDS 规避技术

当你扫一个被 IDS/WAF 保护的目标时,基础扫描可能被拦截。以下技术逐步升级对抗程度:

# 方法1:分片(Fragment)——把探测包打碎,部分防火墙不会重组
sudo nmap -f -p 80,443 192.168.56.102
 
# 更小分片(-ff = 16字节,-f = 8字节)
sudo nmap -ff -p 80,443 192.168.56.102
 
# 自定义 MTU(最小粒度控制)
sudo nmap --mtu 24 -p 80,443 192.168.56.102
# 方法2:设延迟,不触发速率限制
sudo nmap -T2 --scan-delay 5s -p- 192.168.56.102
 
# 方法3:诱饵扫描——目标看到的日志里N个IP中只有1个是真的
sudo nmap -D RND:10 -p 80,443 192.168.56.102            # 随机10个诱饵
sudo nmap -D 8.8.8.8,1.1.1.1,ME -p 80,443 192.168.56.102 # 指定诱饵,ME是你
# 方法4:伪装源端口——防火墙常放行 53(DNS)、80(HTTP) 源端口
sudo nmap --source-port 53 -p- 192.168.56.102
 
# 方法5:随机化扫描顺序 + MAC 欺骗(同一网段内)
sudo nmap -sS -p- --randomize-hosts --spoof-mac 0 -T4 192.168.56.0/24
 
# 方法6:用 decoy 发包时附加错误校验和,让防御设备迷惑
sudo nmap --badsum -p 80 192.168.56.102
# 注意:--badsum 只是用来测试防火墙/IDS是否在校验包
# 方法7:数据包长度定制(某些 IDS 只监控特定长度)
sudo nmap --data-length 80 -p 80,443 192.168.56.102
# 给每个包附加80字节随机数据,改变包的特征签名

6.8 Nmap 输出处理与报告生成

# 从 XML 输出生成 HTML 报告
xsltproc /tmp/full_syn_scan.xml -o /tmp/report.html
 
# 用 grep 快速提取所有开放端口和对应服务
grep -E "^[0-9]+/tcp.*open" /tmp/service_deep.nmap | awk '{print $1, $3, $4}'

预期输出

22/tcp open  ssh
80/tcp open  http
443/tcp open  https
3306/tcp open  mysql
8080/tcp open  http-proxy
8443/tcp open  ssl/http
27017/tcp open  mongod
# 批量对 IP 列表跑 Nmap
for ip in $(cat /tmp/alive_hosts.txt); do
    sudo nmap -sS -p- -T4 --min-rate 1000 -oA /tmp/nmap_$ip $ip &
done
wait  # 等所有后台任务完成

实战8:Web 应用指纹识别

知道目标用的什么技术栈,你的攻击才能对症下药。

8.1 WhatWeb——技术栈检测

WhatWeb 有 1800+ 个插件,能识别 CMS、框架、JavaScript 库、服务器、CDN、分析工具等等。

# 攻击性级别 3(最详细,发最多请求)
whatweb http://192.168.56.102 -a 3 --color=never

预期输出

http://192.168.56.102 [200 OK]
  Apache[2.4.54], Bootstrap[4.1.3],
  Cookies[PHPSESSID],
  Country[UNITED STATES][US],
  HTML5,
  HTTPServer[Ubuntu Linux][Apache/2.4.54 (Ubuntu)],
  HttpOnly[PHPSESSID],
  IP[192.168.56.102],
  JQuery[3.6.0],
  Meta-Author[admin],
  MetaGenerator[WordPress 6.2.2],
  Open-Graph-Protocol,
  PHP[7.4.33],
  PoweredBy[WordPress],
  Script[application/ld+json],
  Strict-Transport-Security[max-age=31536000],
  Title[My WordPress Site],
  UncommonHeaders[x-content-security-policy],
  WordPress[6.2.2],
  X-Frame-Options[SAMEORIGIN],
  X-Powered-By[PHP/7.4.33]

从这一个命令你知道了:

  • CMS:WordPress 6.2.2(版本号精确到补丁级别)
  • Web 服务器:Apache 2.4.54 on Ubuntu
  • 语言:PHP 7.4.33
  • 前端:Bootstrap 4.1.3, jQuery 3.6.0
  • 安全头:HSTS 开启,X-Frame-Options 有,但缺少 CSP

-a 等级说明

  • -a 1:只做被动分析(不发额外请求)
  • -a 3:主动分析——发探测请求,请求特定路径(如 /wp-admin/)来判断 CMS
  • -a 4:最激进——发可能有害的请求(如包含 SQLi 的 payload)
# 批量检测子域名
while read url; do
    whatweb $url -a 3 --no-errors 2>/dev/null
done < /tmp/tesla_web.txt > /tmp/whatweb_results.txt

8.2 手动 HTTP 响应头分析

curl -I http://192.168.56.102

预期输出

HTTP/1.1 200 OK
Date: Sun, 20 Apr 2025 12:00:00 GMT
Server: Apache/2.4.54 (Ubuntu)
X-Powered-By: PHP/7.4.33
Set-Cookie: PHPSESSID=abc123; path=/; HttpOnly
Content-Type: text/html; charset=UTF-8
Strict-Transport-Security: max-age=31536000
X-Frame-Options: SAMEORIGIN

响应头攻击价值表

响应头信息
ServerApache/2.4.54 (Ubuntu)精确版本,查 CVE
X-Powered-ByPHP/7.4.33PHP 版本(7.4.33 在 2025 年已 EOL,多个已知 CVE)
X-AspNet-Version4.0.30319ASP.NET 版本
Set-CookiePHPSESSIDPHP 应用,可能用 Laravel/Symfony/WordPress
缺少 Content-Security-Policy未设置 CSP,XSS 攻击更容易
缺少 X-Content-Type-Options可能 MIME 嗅探攻击
X-Debug-Token存在Symfony 调试模式开启!可获取完整请求信息
# 查看完整响应(非 HEAD,HEAD 某些情况下会被服务器特殊处理)
curl -v http://192.168.56.102 2>&1 | grep -E "^[<>]"

8.3 页面内容指纹

# 从 HTML 中提取技术栈特征
curl -s http://192.168.56.102 | grep -iE "wordpress|joomla|drupal|generator|wp-content|powered.by|magento|shopify|laravel"

预期输出

<meta name="generator" content="WordPress 6.2.2" />
<link rel='stylesheet' id='wp-block-library-css'  href='/wp-includes/css/dist/block-library/style.min.css' />
<script type='text/javascript' src='/wp-content/plugins/contact-form-7/includes/js/scripts.js'>
<!-- powered by Joomla! - Copyright (C) ... -->
# 查看 JS 文件列表(暴露框架和插件)
curl -s http://192.168.56.102 | grep -oP 'src="[^"]+\.js[^"]*"' | sort -u

预期输出

src="/wp-content/themes/twentytwentythree/assets/js/index.js"
src="/wp-content/plugins/elementor/assets/js/frontend.min.js"
src="https://cdn.jsdelivr.net/npm/vue@3.2.47"

现在你知道它用了 Elementor(WP 插件,历史上多个 XSS 和权限绕过漏洞)和 Vue 3.2.47。

# 查看 CSS 文件列表
curl -s http://192.168.56.102 | grep -oP 'href="[^"]+\.css[^"]*"' | sort -u

8.4 SSL/TLS 证书信息收集

# 获取证书详情
openssl s_client -connect 192.168.56.102:443 -servername 192.168.56.102 2>/dev/null | openssl x509 -noout -text

关键字段

Subject: CN = *.tesla.com           # 通配符证书
Issuer: CN = DigiCert SHA2 Extended Validation Server CA
Not Before: Jan 15 00:00:00 2025 GMT
Not After : Jan 14 23:59:59 2026 GMT
Subject Alternative Name:
    DNS:tesla.com
    DNS:*.tesla.com
    DNS:shop.tesla.com              # 额外子域名泄露!
    DNS:api.tesla.com
    DNS:staging.tesla.com

证书透明度(Certificate Transparency)——所有公开 TLS 证书都会被记录:

# crt.sh 查询(浏览器打开)
# https://crt.sh/?q=%.tesla.com
 
# CLI 方式
curl -s "https://crt.sh/?q=%.tesla.com&output=json" | jq -r '.[].name_value' | sed 's/\n/\n/g' | sort -u

这会返回数百个子域名——所有在证书里出现过 tesla.com 的子域名。这是 Subfinder 的数据源之一。

实战10:CMS 特定扫描

通用扫描器是瑞士军刀,CMS 专用扫描器是手术刀。

10.1 WordPress 扫描——WPScan

WPScan 是 WordPress 安全扫描的行业标准,维护了庞大的漏洞数据库。

# 基础枚举
wpscan --url http://192.168.56.102 --enumerate p,t,u
  • p:插件(Plugins)
  • t:主题(Themes)
  • u:用户(Users)

预期输出

_______________________________________________________________
         __          _______   _____
         \ \        / /  __ \ / ____|
          \ \  /\  / /| |__) | (___   ___  __ _ _ __
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
            \  /\  /  | |     ____) | (__| (_| | | | |
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|

         WordPress Security Scanner by the WPScan Team
                         Version 3.8.24
       Sponsored by Automattic - https://automatic.com/
_______________________________________________________________

[+] URL: http://192.168.56.102/ [192.168.56.102]
[+] Started: Sun Apr 20 12:00:00 2025

Interesting Finding(s):

[+] Headers
 | Interesting Entry: Server: Apache/2.4.54 (Ubuntu)
 | Found By: Headers (Passive Detection)
 | Confidence: 100%

[+] robots.txt found: http://192.168.56.102/robots.txt
 | Interesting Entries:
 |  - /wp-admin/
 |  - /wp-admin/admin-ajax.php
 | Found By: Robots Txt (Aggressive Detection)
 | Confidence: 100%

[+] XML-RPC seems to be enabled: http://192.168.56.102/xmlrpc.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%
 | References:
 |  - http://codex.wordpress.org/XML-RPC_Pingback_API
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access

[+] WordPress version 6.2.2 identified (Insecure, released on 2023-05-20).
 | Found By: Meta Generator (Passive Detection)
 |  - http://192.168.56.102/, Match: 'WordPress 6.2.2'
 |
 | [!] 1 vulnerability identified:
 |
 | [!] Title: WordPress < 6.2.3 - Unauthenticated Directory Traversal
 |     Fixed in: 6.2.3
 |     References:
 |      - https://wpscan.com/vulnerability/abc123
 |      - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-2745

[+] Enumerating Themes...
 | Found 2 themes:
 | twentytwentythree (v1.1) - latest
 | my-custom-theme (v1.0) - outdated
 |
 | [!] 1 vulnerability identified in my-custom-theme v1.0:
 | [!] Title: My Custom Theme < 2.0 - Arbitrary File Upload
 |     Fixed in: 2.0

[+] Enumerating Plugins...
 | Found 5 plugins:
 | akismet (v5.1) - latest
 | contact-form-7 (v5.7.6) - outdated
 | elementor (v3.13.4) - outdated
 | wordpress-seo (v20.8) - latest (yoast-seo)
 | wp-file-manager (v6.9) - outdated
 |
 | [!] 1 vulnerability identified in contact-form-7 v5.7.6:
 | [!] Title: Contact Form 7 < 5.8 - Stored XSS
 |     Fixed in: 5.8
 |
 | [!] 1 vulnerability identified in elementor v3.13.4:
 | [!] Title: Elementor < 3.14 - Authenticated RCE via Template Import
 |     Fixed in: 3.14
 |
 | [!] 1 vulnerability identified in wp-file-manager v6.9:
 | [!] Title: WP File Manager < 7.0 - Unauthenticated Arbitrary File Upload (RCE)
 |     Fixed in: 7.0
 |     References:
 |      - https://wpscan.com/vulnerability/wpfm-rce
 |      - https://www.exploit-db.com/exploits/51234

[+] Enumerating Users...
 | Found 4 users:
 | admin (ID: 1)
 | editor (ID: 2)
 | author (ID: 3)
 | subscriber (ID: 4)

关键发现优先级

  1. WP File Manager 6.9:未经认证的文件上传 RCE——这是直接拿 shell 的漏洞!
  2. XML-RPC 开启:可以用于暴力破解(xmlrpc.php 允许一个请求尝试多个密码)、SSRF、pingback DoS
  3. 用户名列表:可以用 admin、editor 等用户名做暴力破解
  4. WordPress 6.2.2:目录穿越漏洞
# 只扫漏洞(不扫用户/插件/主题)
wpscan --url http://192.168.56.102 --enumerate vp,vt
 
# 暴力破解用户密码
wpscan --url http://192.168.56.102 --passwords /usr/share/wordlists/rockyou.txt.gz --usernames admin,editor
 
# XML-RPC 暴力破解(速度更快,一个请求试多个密码)
wpscan --url http://192.168.56.102 --passwords /usr/share/wordlists/rockyou.txt.gz --usernames admin --wp-content-dir wp-content --method xmlrpc --multicall-max-attempts 500

10.2 Joomla 扫描——JoomScan

joomscan --url http://192.168.56.102

预期输出

    ____  _____  _____  __  __  ___   ___    __    _  _
   (_  _)(  _  )(  _  )(  \/  )/ __) / __)  /__\  ( \( )
  .-_)(   )(_)(  )(_)(  )    ( \__ \( (__  /(__)\  )  (
  \____) (_____)(_____)(_/\/\_) (___/ \___)(__)(__)(_)\_)
                        (1337.today)

    --=[OWASP JoomScan
    +---++---==[Version : 0.0.7
    +---++---==[Update Date : [2021/10/03]
    +---++---==[Auth : A.R.P
    ++---++---=[Infos at: https://github.com/OWASP/joomscan.git

[+] Target: http://192.168.56.102
[+] Starting: 2025-04-20 12:00:00

[++] Joomla Version : 4.3.2
 |  - Release date : 2023-06-13
 |  - Vulnerability : Multiple vulnerabilities found
 |    -> https://developer.joomla.org/security-centre/1234-20230701-core-xss-vulnerability.html

[++] Core Joomla Vulnerability
[++] Target Joomla core is not the latest version

[++] Checking Directory Listing
[++] /administrator/ : Directory listing is disabled
[++] /components/ : Directory listing is enabled!
[++] /modules/ : Directory listing is enabled!

[++] Checking robots.txt
[++] robots.txt found: http://192.168.56.102/robots.txt
    Interesting entries:
    -> /administrator/
    -> /cache/
    -> /components/
    -> /images/
    -> /modules/
    -> /plugins/
    -> /templates/

[++] Finding administrative backend
[++] Admin path : /administrator  ->  http://192.168.56.102/administrator

[++] Checking sensitive config files
[++] configuration.php is found on the server (403 Forbidden)
[++] configuration.php-dist is found on the server (200 OK)    <-- 高危!

Joomla 特有发现

  • /components/ 目录列表开启 → 可以枚举所有已安装组件和对应版本
  • /configuration.php-dist 可访问 → 这是 Joomla 的默认配置示例文件,可能泄露数据库结构
  • /administrator 路径确认 → 管理员登录入口
# 枚举 Joomla 组件(在开启了目录列表的情况下)
curl http://192.168.56.102/components/ | grep "href" | grep -v "Parent Directory"
 
# 常见 Joomla 攻击路径
# 1. com_users 注册功能 → 注册后提权
# 2. com_media 文件管理 → 上传 shell
# 3. com_finder 智能搜索 → SQL 注入(历史 CVE)
# 4. com_fields → SQL 注入(CVE-2017-8917)

10.3 Drupal 扫描——Droopescan

droopescan scan drupal -u http://192.168.56.102

预期输出

[+] No themes found.

[+] Possible interesting urls found:
    Default changelog file - https://www.drupal.org/node/19791
    Default admin - http://192.168.56.102/user/login
    Default readme file - https://www.drupal.org/node/19791

[+] Possible version(s):
    9.5.9

[+] Plugins found:
    php saml_sp SAML Authentication 8.x-3.2
        http://192.168.56.102/modules/contrib/saml_sp/LICENSE.txt
    ctools Chaos Tools 8.x-3.11
        http://192.168.56.102/modules/contrib/ctools/LICENSE.txt
    token Token 8.x-1.11
        http://192.168.56.102/modules/contrib/token/LICENSE.txt

[+] Scan finished (0:00:34.234567 elapsed)

Drupal 重点

  • /user/login → 默认登录路径
  • /user/register → 如果开放注册,注册一个账号后尝试提权
  • Drupal 历史上最出名的漏洞:Drupalgeddon(CVE-2018-7600)——未认证 RCE
# 如果 Drupal 版本 < 7.58 / 8.5.1,直接用 Drupalgeddon 打
# 在 Metasploit 中:
# use exploit/unix/webapp/drupal_drupalgeddon2

10.4 通用 CMS 检测(不知道是什么 CMS 时)

# 用 CMSeeK 自动检测并扫描(支持 200+ CMS)
cmseek -u http://192.168.56.102
 
# 手动常见路径探测
curl -s http://192.168.56.102/wp-login.php | head -5     # WordPress 登录页
curl -s http://192.168.56.102/administrator | head -5     # Joomla 后台
curl -s http://192.168.56.102/user/login | head -5        # Drupal 登录
curl -s http://192.168.56.102/admin | head -5             # 通用后台
curl -s http://192.168.56.102/manager/html | head -5      # Tomcat Manager

ADMIN Disk Default share
IPC$ IPC Remote IPC
www Disk Web files
backup Disk Backup files


- `www` 共享 → 直接映射到网站根目录,如果可以写入 → 直接写 webshell
- `backup` 共享 → 可能有数据库备份、源码备份

```bash
# 列出共享
smbclient -L //192.168.56.102 -N

# 尝试匿名连接
smbclient //192.168.56.102/www -N

# 如果连接成功
smb: \> ls
smb: \> get config.php
smb: \> put shell.php  # 如果有写权限
# Nmap SMB 脚本组合
nmap --script smb-os-discovery,smb-enum-shares,smb-enum-users,smb-protocols -p 445 -oA /tmp/smb_enum 192.168.56.102

11.2 SNMP 枚举

SNMP(简单网络管理协议)如果配置了弱 community string(如 publicprivate),会泄露大量系统信息。

# 快速 SNMP 检查
snmp-check 192.168.56.102
 
# 遍历 OID 树
snmpwalk -v2c -c public 192.168.56.102

SNMP 可能泄露的信息

  • 系统进程列表(snmpwalk -v2c -c public 192.168.56.102 1.3.6.1.2.1.25.4.2.1.2
  • 已安装软件列表(1.3.6.1.2.1.25.6.3.1.2
  • 网络接口和 IP(1.3.6.1.2.1.4.20.1
  • 运行的服务(1.3.6.1.2.1.25.4.2.1
  • 用户账户(1.3.6.1.4.1.77.1.2.25
# 常见 community string 字典爆破
onesixtyone -c /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt 192.168.56.102

预期输出

Scanning 1 hosts, 122 communities
192.168.56.102 [public] Linux ubuntu 5.15.0-72-generic #81-Ubuntu SMP ...
192.168.56.102 [private] Linux ubuntu 5.15.0-72-generic #81-Ubuntu SMP ...

11.3 FTP 匿名登录

# 测试匿名 FTP
ftp -n 192.168.56.102 << EOF
user anonymous anonymous
ls
bye
EOF

如果连接成功,FTP 根目录往往就是网站根目录——直接传 webshell。

# 用 Nmap 检测 FTP 匿名登录
nmap --script ftp-anon -p 21 192.168.56.102

预期输出

PORT   STATE SERVICE
21/tcp open  ftp
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r--   1 ftp      ftp          1234 Apr 20 12:00 README.txt
| drwxr-xr-x   2 ftp      ftp          4096 Apr 19 10:00 upload
|_-rw-r--r--   1 ftp      ftp           890 Apr 18 15:30 backup.sql
  • upload 目录可写 → 传 webshell
  • backup.sql → 数据库备份,拖下来分析

11.4 数据库服务识别

# MySQL 基础信息获取
nmap --script mysql-info -p 3306 192.168.56.102
 
# MySQL 空密码测试
nmap --script mysql-empty-password -p 3306 192.168.56.102

预期输出

PORT     STATE SERVICE
3306/tcp open  mysql
| mysql-info:
|   Protocol: 10
|   Version: 5.7.39-0ubuntu0.18.04.1
|   Thread ID: 42
|   Capabilities flags: 65535
|   Some Capabilities: LongPassword, Speaks41ProtocolNew, Support41Auth...
|   Status: Autocommit
|_  Salt: abc123def456
  • mysql-empty-password 检测 root 是否空密码
  • MySQL 5.7.39 存在已知的提权漏洞(CVE-2023-21980)
# MongoDB 检测
nmap --script mongodb-info -p 27017 192.168.56.102
nmap --script mongodb-databases -p 27017 192.168.56.102

预期输出

PORT      STATE SERVICE
27017/tcp open  mongod
| mongodb-databases:
|   ok = 1.0
|   databases
|     1
|       name = admin
|       sizeOnDisk = 102400
|       empty = false
|     2
|       name = production
|       sizeOnDisk = 52428800
|       empty = false
|_  totalSize = 52531200

如果 MongoDB 未认证(很常见),可以直接列出所有数据库名→ production 数据库说明这是生产环境。

Key Findings ---
Subdomains discovered: 532
Web services alive: 47

[+] Recon complete. All data in /tmp/recon_tesla.com_20250420_120000



## 常见问题与排错

### 扫描被目标 WAF 封 IP

**症状**:扫描一段时间后所有请求返回 403 或连接超时。

**解决方案**:
1. 降低扫描速度:`-t 10`(Gobuster)、`T2`(Nmap)
2. 加延迟:`--scan-delay 10s`(Nmap)、`--delay 2s`(ffuf)
3. 换 User-Agent:Gobuster 用 `-a "Mozilla/5.0 ..."`,ffuf 用 `-H "User-Agent: ..."`
4. 用代理池:`--proxy http://proxy:8080`
5. 换 IP(用 VPN 或云服务器)

### DNS 解析慢

**症状**:批量 dig 子域名很慢,几分钟跑不完。

**解决方案**:
```bash
# 用 dnsx(高速 DNS 解析工具)
dnsx -l /tmp/all_subs.txt -a -aaaa -cname -mx -ns -soa -silent -o /tmp/dns_full.txt

# 或用 massdns
massdns -r /usr/share/seclists/Miscellaneous/dns-resolvers.txt -t A -o S /tmp/all_subs.txt -w /tmp/massdns.txt

RustScan 需要 root 权限

# 加 cap_net_raw 能力避免用 sudo
sudo setcap cap_net_raw+ep /usr/bin/rustscan
 
# 或者直接用 sudo
sudo rustscan -a 192.168.56.102 --range 1-65535 -b 2000

证书错误导致 HTTPS 扫描失败

# curl 跳过证书验证
curl -k https://192.168.56.102
 
# gobuster 跳过证书验证
gobuster dir -u https://192.168.56.102 -w wordlist.txt -k
 
# nikto 跳过证书验证
nikto -h https://192.168.56.102 -ssl -NoCheckCertificate

侦察不是为了侦察而侦察。每一个 IP、每一个端口、每一个子域名、每一个 CMS 版本号——都是在为下一步的漏洞利用铺路。把这一章的所有命令跑熟,形成肌肉记忆,你看到一个域名时大脑里应该自动浮现整个攻击面地图。