红队技巧14:端口复用

windows

frsocks在9999端口开启socks5代理

frsocks.exe -sockstype fsocks -listen 9999


protoplex监听4444端口,进行端口分流,如果是http的话发送给80端口,如果是socks5的话发送给9999端口

protoplex.exe --socks5 192.168.30.138:9999 --http 192.168.30.138:80 -b 192.168.30.138:4444




将80端口的流量重定向到4444端口(需要管理员权限)

netsh advfirewall set currentprofile state off
netsh interface portproxy add v4tov4 listenport=80 listenaddress=192.168.30.138 connectport=4444 connectaddress=192.168.30.138 protocol=tcp
netsh interface portproxy show all

如果想要删除这条规则

netsh interface portproxy delete v4tov4 listenport=80 listenaddress=192.168.30.138

如果想删除所有的规则

netsh interface portproxy reset

现在80端口也可以进行socks5代理,实现端口复用

linux

./frsocks -sockstype fsocks -listen 9999

./protoplex --socks5 192.168.30.131:9999 --http 192.168.30.131:80 -b 192.168.30.131:4444


将80端口的流量重定向到4444端口(需要特权)

sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 9999

如果想删除这项规则

sudo iptables -t nat -D PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 9999

参考文章

https://blog.csdn.net/qq_41874930/article/details/122128700
https://blog.csdn.net/weixin_39717029/article/details/111266559

posted @ 2023-12-28 14:46  BattleofZhongDinghe  阅读(87)  评论(0编辑  收藏  举报