Meterpreter
Meterpreter is an advanced, dynamically extensible payload that uses in-memory DLL injection stagers and is extended over the network at runtime.
It communicates over the stager socket and provides a comprehensive client-side Ruby API.
How Meterpreter Works
The target executes the initial stager. This is usually one of bind, reverse, findtag, passivex, etc.
The stager loads the DLL prefixed with Reflective. The Reflective stub handles the loading/injection of the DLL.
The Metepreter core initializes, establishes a TLS/1.0 link over the socket and sends a GET. Metasploit receives this GET and configures the client.
Lastly, Meterpreter loads extensions. It will always load stdapi and will load priv if the module gives administrative rights. All of these extensions are loaded over TLS/1.0 using a TLV protocol.
Meterpreter Design Goals
Stealthy
Meterpreter resides entirely in memory and writes nothing to disk.
No new processes are created as Meterpreter injects itself into the compromised process and can migrate to other running processes easily.
By default, Meterpreter uses encrypted communications.
All of these provide limited forensic evidence and impact on the victim machine.
Powerful
Meterpreter utilizes a channelized communication system.
The TLV protocol has few limitations.
Extensible
New features can be added to Meterpreter without having to rebuild it.
Features can be augmented at runtime by loading extensions over the network.
The client uploads the DLL over the socket.
The server running on the victim loads the DLL in-memory and initializes it.
The new extension registers itself with the server.
The client on the attackers machine loads the local extension API and can now call the extensions functions.
Meterpreter Basic Commands
Help
Background
The background command will send the current Meterpreter session to the background and return you to the ‘msf’ prompt.
Cat
The cat command displays the content of a file.
CD and PWD
The cd and pwd commands are used to change and display current working directory on the target host.
LCD and LPWD
The lcd and lpwd commands are used to change and display the local working directory respectively.
Changing the working directory will give your Meterpreter session access to files located in this folder.
ClearEV
The clearev command will clear the Application, System, and Security logs on a Windows system.
There are no options or arguments.
Download
The download command downloads a file from the remote machine.
Edit
The edit command opens a file located on the target host.
It uses the ‘vim’ so all the editor’s commands are available.
Execute
The execute command runs a command on the target.
GetUID
Running getuid will display the user that the Meterpreter server is running as on the host.
Hashdump
The hashdump post module will dump the contents of the SAM database, where user and group account information stored.
IdleTime
Running idletime will display the number of seconds that the user at the remote machine has been idle.
IPConfig
The ipconfig command displays the network interfaces and addresses on the remote machine.
LS
The ls command will list the files in the current remote directory.
Migrate
Using the migrate post module, you can migrate to another process on the victim.
PS
The ps command displays a list of running processes on the target.
Resource
Run Meterpreter instructions located inside a text file.
By default, the commands will run in the current working directory (on target machine) and resource file in the local working directory (the attacking machine).
Search
The search commands provides a way of searching specific files through the whole system or specific folders on the target host.
Shell
The shell command will present you with a standard shell on the target system.
Upload
The upload command uploads a file to the remote machine.
WebCam_List
The webcam_list command will display currently available web cams on the target host.
WebCam_Snap
The webcam_snap command grabs a picture from a connected web cam on the target system, and saves it to disc as a JPEG image.
By default, the save location is the local current working directory with a randomized filename.
Python Extension
Meterpreter’s python extension gives users the ability to run Python code natively on a target machine, without having the interpreter installed.
References
Last updated