大家好,继上一期wstunnel的使用,摸索了一下(这个工具类似ssh隧道),分享一下自己的食用方法:
- 中转机设置:
wstunnel server ws://0.0.0.0:port
port:防火墙要开通这个端口
ip:中转机ip
- 远程pc(server)
wstunnel client -R tcp://port2:ip1:port1 ws://ip:port
port2: 要映射到中转机的哪个端口
ip1: server上的本地ip或者回环地址,一般为 localhost
port1: server上的哪个端口要映射
- 其他pc(client):
wstunnel client -L tcp://port1:ip2:port2 ws://ip:port
port1: 本地要映射的端口
ip2: 中转机回环地址即可,一般为 localhost
port2: 要连接到中转机的哪个端口
上述ip、port、ip1、port1、ip2、port2对应即可实现远程桌面rdp连接,比如:
- 中转机
wstunnel server wss://0.0.0.0:8888 --restrict-http-upgrade-path-prefix=helloworld
中转机启动8888端口监听来自任何ip的连接,–restrict-http-upgrade-path-prefix指定连接要配置路由(UUID最好),否则无法连接,官方解释如下:
只有在websocket升级期间使用此特定路径前缀时,服务器才会接受来自的连接。
如果在客户端中指定自定义路径前缀,并且希望服务器只允许使用此前缀,则很有用。
路径前缀充当对客户端进行身份验证的秘密
默认情况下禁用。接受所有路径前缀。可以多次指定
- 远程pc(server)
wstunnel client -R tcp://6666:localhost:3389 wss://${中转机ip}:8888 --http-upgrade-path-prefix=helloworld
远程PC启动反向隧道6666端口(localhost:3389是本地rdp)映射到中转机,即6666端口是中转机上的端口,也就是远程PC:localhost:3389======>通过中转机8888端口隧道承载======>中转机:ip(ip省略):6666,–http-upgrade-path-prefix=helloworld为中转机上指定的路由
- 其他pc(客户机):
wstunnel client -L tcp://1234:localhost:6666 wss://${中转机ip}:8888 --http-upgrade-path-prefix=helloworld
其他pc(客户机)启动本地1234端口监听本地rdp连接,连接中转机6666端口,即:客户机mstsc==>客户机 ip(ip省略):1234端口======>通过中转机8888端口隧道承载======>中转机:localhost:6666
大概是这样的:客户机mstsc ==> 客户机 ip(ip省略):1234端口 ======> 通过中转机8888端口隧道承载 ======> 中转机:localhost:6666 <====== 通过中转机8888端口隧道承载 <====== 远程PC:localhost:3389
- 中转机只需要一个小鸡,启动一个8888端口并开通防火墙,即可接受来自任意的连接
- 反代还在研究中,欢迎各位大佬交流学习心得