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
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.
| Concept | What it means | Why it matters |
|---|---|---|
| Staged payload | Tiny stager (e.g. windows/x64/meterpreter/reverse_tcp) downloads the full metsrv stage at runtime | Small initial footprint fits in constrained exploits; the big stage never hits disk |
| Stageless payload | Entire 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 injection | The stage maps itself into the host process without using the Windows loader or LoadLibrary | No DLL on disk, no standard load event — the core evasion trick |
| In-memory execution | Runs inside the exploited process (or one you migrate to) | Blends with a trusted process; survives only while that process lives |
| Extensions | stdapi, priv, kiwi, python, powershell loaded on demand over the channel | Keeps the base agent small; capabilities arrive just-in-time |
| Transports | reverse_tcp, reverse_https, bind_tcp, named-pipe | HTTPS 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 STARTMeterpreter 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.
| Requirement | Minimum | Recommended | Notes |
|---|---|---|---|
| Attacker OS | Any Linux / macOS min | Kali Linux 2026 rec | Kali ships Metasploit pre-installed and patched |
| RAM (attacker) | 4 GB | 8 GB+ | PostgreSQL + msfconsole are memory-hungry |
| Target (Windows) | Windows 10 VM | AD home lab + Win10/11 | Metasploitable-3 Windows is purpose-built for practice |
| Target (Linux) | Metasploitable-2 | Metasploitable-3 Linux | Classic intentionally vulnerable services |
| Network | Host-only adapter | Isolated internal network | Never expose vulnerable VMs to the internet |
| Ruby | Bundled with Metasploit | Bundled | You do not manage Ruby yourself on packaged installs |
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.
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.
Metasploit uses PostgreSQL to store hosts, services, loot and sessions across runs. Initialise it once; it makes workspaces, hosts and creds work inside msfconsole.
msfconsole --versionprints a 6.x framework versiondb_statusreports "connected to msf"- You can reach the target VM:
ping/nmap -snfinds 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.
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.
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.
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.
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.
- "Meterpreter session N opened" appears with a source→dest tuple
- The prompt changes to
meterpreter > getuidreturns 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.
Payload names follow OS/ARCH/payload/transport. Browse the Meterpreter options so you pick the exact match for your target platform.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
| Command | Group | What it does |
|---|---|---|
| background | core | Return to msfconsole, keep the session alive |
| migrate | core | Move the implant into another process |
| getpid / getuid | stdapi | Current process ID / user context |
| sysinfo | stdapi | OS, architecture, domain, hostname |
| ps / pgrep | stdapi | List / filter running processes |
| shell | stdapi | Open a native system command shell |
| execute | stdapi | Launch a program (optionally hidden) |
| channel | core | Manage active I/O channels |
| exit / quit | core | Terminate the Meterpreter session |
07 — Filesystem & Networking Commands
DATA & LINKSMeterpreter 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.
Recursively find files by pattern across the disk — password vaults, config files, SSH keys, spreadsheets. This is often where the real loot is.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
09 — Persistence & Pivoting
GO WIDEROne 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.
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.
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.
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.
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.
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.
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.
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 UPBeyond 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.
| Extension | Loaded by | What it adds |
|---|---|---|
| stdapi | auto | Filesystem, process, network, UI commands — the core |
| priv | auto / load | getsystem, hashdump, timestomp |
| kiwi | load kiwi | In-memory Mimikatz — credential & ticket theft |
| incognito | load incognito | Windows token enumeration and impersonation |
| python | load python | Run Python in-memory on the target |
| powershell | load powershell | Run PowerShell without spawning powershell.exe |
| espia | load espia | Screen grab and extra surveillance helpers |
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.
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.
For full programmatic control — orchestration, custom tooling, CI-driven detection tests — run the RPC daemon and drive Metasploit from Python with the pymetasploit3 library.
11 — Detection, Hardening & Troubleshooting
BLUE TEAMA 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.
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.
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.
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.
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.
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.
Mapping the techniques above to ATT&CK gives your detections coverage language and tells you which gaps remain.
| Technique | ID | Meterpreter action |
|---|---|---|
| Process Injection | T1055 | migrate, reflective DLL injection |
| Access Token Manipulation | T1134 | incognito, steal_token, getsystem |
| OS Credential Dumping: LSASS | T1003.001 | load kiwi, creds_all, hashdump |
| Application Layer Protocol: Web | T1071.001 | reverse_https C2 transport |
| Ingress Tool Transfer | T1105 | upload, web_delivery stager |
| Create or Modify System Process | T1543.003 | persistence_service (new Windows service) |
| Protocol Tunneling | T1572 | autoroute, portfwd, socks_proxy |
| Use Alternate Auth Material: PtH | T1550.002 | psexec with NT hash |
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.
- 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.
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.
| Symptom | Likely cause | Fix |
|---|---|---|
| Session opens then dies instantly | Payload / handler mismatch | Make handler PAYLOAD, LHOST, LPORT identical to the generated file |
| No callback at all | Wrong LHOST or blocked egress | Set LHOST to the host-only IP (ip a); check firewall/route to attacker |
| "migrate failed" / access denied | Arch mismatch or low privilege | Match x86↔x64; migrate to a process you own, or getsystem first |
| "[-] core_loadlib: Operation failed" | Extension/arch mismatch | Use an x64 payload on an x64 host; re-exploit with the right arch |
| Payload killed by AV on target | Default payload is signatured | Lab: exclude the folder / disable AV on your own VM |
| db_status "no database" | msfdb not initialised | Run sudo msfdb init, then restart msfconsole |
| Pivot nmap returns nothing | SYN scan over SOCKS | Use proxychains nmap -sT -Pn (TCP connect only) |
| Stale session after reboot | No persistence | Install 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
DOCUMENTATIONPrimary 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.
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.
"They can't exploit you if you are the Exploit."