由于软件限制,我们目前在所有机器上都运行 Windows。
然而,在这个过程中,我们需要将进入 IP 和端口的某些数据包重定向到不同的端口(相同的 IP)。我们有软件监听“代理端口”。
这可以通过在 Linux 上使用 IPTables 来实现,方法类似于:
iptables -t nat -I PREROUTING -p udp -d <DSTIP> --dport <DSTPORT> -m u32 --u32 '0>>22&0x3C@8=0xFFFFFFFF && 0>>22&0x3C@12=0x54536F75 && 0>>22&0x3C@16=0x72636520 && 0>>22&0x3C@20=0x456E6769 && 0>>22&0x3C@24=0x6E652051 && 0>>22&0x3C@28=0x75657279' -j REDIRECT --to-port <REDIRECT PORT>
这在 linux 上效果很好,并将某些数据包重定向到我们的代理软件,但是是否有可能在 Windows 上做这样的事情而不必在我们的 Windows 机器前面获得一台专用机器?
我正在考虑用 pcap.net 写一些东西,但我猜这将不得不直接从 NIC 而不是 Windows 读取?
最佳答案
来自 MSDN :
Netsh is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running.
您可以使用以下命令将来自任何端口的连接重定向到另一个本地(或远程)端口:
netsh interface portproxy add v4tov4 listenaddress=localaddress listenport=localport connectaddress=destaddress connectport=destport
此外,如 this SO post 所述, netsh 是 的良好替代品iptabes 在 Windows 上。
关于routing - Windows 上的数据包重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36313417/