03- Conociendo Metasploit – Parte III – Meterpreter básico

Buenas a todos a este nuevo post de la serie “Conociendo metasploit”. Este post será de introducción a los comandos básicos de meterpreter, el cual como hemos estado viendo en los anteriores post es uno de los payloads más potentes que trae el framework de Metasploit.

En este caso tenemos como objetivo la misma máquina virtual que en los anteriores posts, cuya configuración de red es la siguiente…

portscan_2

 

Ahora tendremos que ejecutar Metasploit y configurarlo para que lance el exploit ms08_067_netapi (Ya vimos en post anteriores que la maquina era vulnerable) junto al payload meterpreter como se muestra en la siguiente imagen (En este caso utilizaremos una conexión inversa para el payload)…

meterpreter_1

 

Una vez tenemos configurado el exploit lo lanzamos y vemos que nos devuelve la shell de meterpreter…meterpreter_2

 

Antes de seguir con la presentación vamos a ver un poco que es el payload meterpreter y los comandos que nos permite ejecutar…

Meterpreter el uno de los payloads por excelencia de Metasploit, el cual nos permite tener un control prácticamente completo de la maquina vulnerada, pudiendo realizar todo tipo de acciones como obtener las cuentas de usuario, realizar todo tipo de comandos en el SO, utilizar un keylogger, activar y tomar fotos de la webcam, activar el escritorio remoto, utilizar un sniffer en la maquina victima para sniffar todo el trafico de su red, saltarnos antivirus, pivoting y una inmensa cantidad de acciones más que veremos parte en este post, y otra gran parte en el siguiente donde nos centraremos en la fase de post explotación mediante scripts para este payload.

La lista de comandos más comunes que trae el payload meterpreter una vez se han listado las diferentes librerías es la siguiente (Comando y descripción):

meterpreter > help
Core Commands
=============
Command Description
 ------- -----------
 ? -> Help menu
 background -> Backgrounds the current session
 bgkill -> Kills a background meterpreter script
 bglist -> Lists running background scripts
 bgrun -> Executes a meterpreter script as a background thread
 channel -> Displays information about active channels
 close -> Closes a channel
 disable_unicode_encoding -> Disables encoding of unicode strings
 enable_unicode_encoding -> Enables encoding of unicode strings
 exit -> Terminate the meterpreter session
 help -> Help menu
 info -> Displays information about a Post module
 interact -> Interacts with a channel
 irb -> Drop into irb scripting mode
 load -> Load one or more meterpreter extensions
 migrate -> Migrate the server to another process
 quit -> Terminate the meterpreter session
 read -> Reads data from a channel
 resource -> Run the commands stored in a file
 run -> Executes a meterpreter script or Post module
 use -> Deprecated alias for 'load'
 write -> Writes data to a channel

Stdapi: File system Commands
============================
Command Description
 ------- -----------
 cat -> Read the contents of a file to the screen
 cd -> Change directory
 download -> Download a file or directory
 edit -> Edit a file
 getlwd -> Print local working directory
 getwd -> Print working directory
 lcd -> Change local working directory
 lpwd -> Print local working directory
 ls -> List files
 mkdir -> Make directory
 mv -> Move source to destination
 pwd -> Print working directory
 rm -> Delete the specified file
 rmdir -> Remove directory
 search -> Search for files
 upload -> Upload a file or directory

Stdapi: Networking Commands
===========================
Command Description
 ------- -----------
 arp -> Display the host ARP cache
 ifconfig -> Display interfaces
 ipconfig -> Display interfaces
 netstat -> Display the network connections
 portfwd -> Forward a local port to a remote service
 route -> View and modify the routing table

Stdapi: System Commands
=======================
Command Description
 ------- -----------
 clearev -> Clear the event log
 drop_token -> Relinquishes any active impersonation token.
 execute -> Execute a command
 getpid -> Get the current process identifier
 getprivs -> Attempt to enable all privileges available to the current process
 getuid -> Get the user that the server is running as
 kill -> Terminate a process
 ps -> List running processes
 reboot -> Reboots the remote computer
 reg -> Modify and interact with the remote registry
 rev2self -> Calls RevertToSelf() on the remote machine
 shell -> Drop into a system command shell
 shutdown -> Shuts down the remote computer
 steal_token -> Attempts to steal an impersonation token from the target process
 suspend -> Suspends or resumes a list of processes
 sysinfo -> Gets information about the remote system, such as OS

Stdapi: User interface Commands
===============================
Command Description
 ------- -----------
 enumdesktops -> List all accessible desktops and window stations
 getdesktop -> Get the current meterpreter desktop
 idletime -> Returns the number of seconds the remote user has been idle
 keyscan_dump -> Dump the keystroke buffer
 keyscan_start -> Start capturing keystrokes
 keyscan_stop -> Stop capturing keystrokes
 screenshot -> Grab a screenshot of the interactive desktop
 setdesktop -> Change the meterpreters current desktop
 uictl -> Control some of the user interface components

Stdapi: Webcam Commands
=======================
Command Description
 ------- -----------
 record_mic -> Record audio from the default microphone for X seconds
 webcam_list -> List webcams
 webcam_snap -> Take a snapshot from the specified webcam

Priv: Elevate Commands
======================
Command Description
 ------- -----------
 getsystem -> Attempt to elevate your privilege to that of local system.

Priv: Password database Commands
================================
Command Description
 ------- -----------
 hashdump -> Dumps the contents of the SAM database

Priv: Timestomp Commands
========================
Command Description
 ------- -----------
 timestomp -> Manipulate file MACE attributes

Espia Commands
==============
Command Description
 ------- -----------
 screengrab -> Attempt to grab screen shot from process's active desktop

Incognito Commands
==================
Command Description
 ------- -----------
 add_group_user -> Attempt to add a user to a global group with all tokens
 add_localgroup_user -> Attempt to add a user to a local group with all tokens
 add_user -> Attempt to add a user with all tokens
 impersonate_token -> Impersonate specified token
 list_tokens -> List tokens available under current user context
 snarf_hashes -> Snarf challenge/response hashes for every token

Mimikatz Commands
=================
Command Description
 ------- -----------
 kerberos -> Attempt to retrieve kerberos creds
 livessp -> Attempt to retrieve livessp creds
 mimikatz_command -> Run a custom commannd
 msv -> Attempt to retrieve msv creds (hashes)
 ssp -> Attempt to retrieve ssp creds
 tspkg -> Attempt to retrieve tspkg creds
 wdigest -> Attempt to retrieve wdigest creds

Sniffer Commands
================
Command Description
 ------- -----------
 sniffer_dump -> Retrieve captured packet data to PCAP file
 sniffer_interfaces -> Enumerate all sniffable network interfaces
 sniffer_release -> Free captured packets on a specific interface instead of downloading them
 sniffer_start -> Start packet capture on a specific interface
 sniffer_stats -> View statistics of an active capture
 sniffer_stop -> Stop packet capture on a specific interface

 

Una vez hemos visto la lista de comando de meterpreter (Tiene muchísimas más acciones gracias a los scripts que veremos más adelante), vamos a ver ahora la ejecución de algunos de los más importantes…

Lo primero podríamos sacar el usuario que somos una vez explotada la vulnerabilidad, sacar algo de información del sistema y listar los procesos (Con el fin de luego poder migrar meterpreter a otro proceso evitando que se cierre la sesión como veremos más adelante)…

meterpreter_3

 

Vamos a ver ahora que con meterpreter podríamos de la misma forma que lo haríamos en un linux cambiar de directorio en la maquina vulnerada, listar dicho directorio, comprobar en que directorio estamos y leer un archivo…

meterpreter_4

 

Por otro lado también podríamos ejecutar ciertas funciones de red como por ejemplo consultar la tabla ARP o mostrar la configuración de red como vemos a continuación…

meterpreter_5

 

Se podrían sacar también las conexiones existentes en la maquina vulnerada, así como su tabla de rutas para IPv4 e IPv6…

meterpreter_6

meterpreter_7

 

Veamos ahora como podríamos listar los privilegios que tenemos así como el usuario actual que somos…

meterpreter_9

 

Vamos a ver ahora un rápido ejemplo de cómo utilizar el Keylogger. Como se ve en las imágenes, se activa el KeyLogger, en la maquina vulnerada escribimos cualquier cosa, después volcamos el buffer del Keylogger que ha ido almacenando y lo detenemos, viendo como nos muestra todo lo que el usuario a escrito…

meterpreter_10

meterpreter_11

 

Por otro lado y como hemos dicho anteriormente, podríamos hacerlo un pantallazo a la maquina vulnerada desde meterpreter utilizando únicamente el comando “screeshot”, esto nos guarda la foto en nuestro PC y nos la habré como vemos a continuación…

meterpreter_12

 

Por ultimo y ya para terminar este post vamos a ver dos formas que tendríamos para listar los usuarios así como sus hashes mediante los comandos “hashdump” y “msv”…

meterpreter_13 meterpreter_14

 

Con esto hemos llegado al final de este post que como habéis visto a sido prácticamente ver un poco los comandos básicos que podemos utilizar con meterpreter. Así que… A partir de ahora los post de esta serie comenzaran a ser de un nivel superior pues lo básico ya está visto.

Espero que os haya gustado!

Un saludo,

Eduardo – eduardo@highsec.es – @_Hykeos

Los comentarios están cerrados.