

When you land on a penetration testing engagement—say, auditing a mid-sized financial institution—the clock is ticking. You’ve finished the reconnaissance phase, identified open ports, and spotted an outdated SMB implementation with a public CVE.
Sure, you could write a custom exploit from scratch. But in a professional engagement, efficiency and reliability matter. This is where a structured exploitation framework comes in. This is where you open Metasploit.
Before diving into commands, you need to understand the fundamental triad that drives every attack vector:
An exploit without a payload is useless; a payload without an exploit has no delivery vehicle. Metasploit’s core strength lies in seamlessly pairing the right exploit with the right payload.
The primary interface for the framework is msfconsole. Once launched, your prompt changes from a standard Linux shell (root@kali:~#) to the Metasploit prompt (msf6 >).
Instead of memorizing thousands of module paths, master the built-in search engine using filters:
Plaintext
msf6 > search type:exploit platform:windows smb
Once you find a module, use its index number to inspect it instantly:
Plaintext
msf6 > info 3
One of the most common beginner mistakes is executing commands in the wrong context. Keep these five prompts straight:
root@ip:~# $\rightarrow$ Standard Linux terminal.
msf6 > $\rightarrow$ Global Metasploit console (search, use, setg).
msf6 exploit(...) > $\rightarrow$ Module context (set, show options, exploit).
meterpreter > $\rightarrow$ Active Meterpreter interactive session.
C:\Windows\system32> $\rightarrow$ Target OS shell.
Loading a module is simple: use <module_path> or use <index_number>. Once loaded, always run show options to check required parameters (Required: yes).
If you are testing multiple modules against the same target, save time using setg (global set) instead of repeating set RHOSTS for every single module.
To fire the exploit, run:
Plaintext
msf6 exploit(...) > exploit
Pro Tip: Add the -z flag (exploit -z) to launch the exploit, background the session immediately, and keep working in your console without getting locked into the Meterpreter prompt.
In simple lab exercises, you exploit a target and drop straight into the session. In real-world multi-subnet engagements, session management separates amateurs from professionals.
msf6 > sessions -i 1
Metasploit is much more than a point-and-click hacking tool; it is a structured framework that mirrors the entire penetration testing lifecycle—from information gathering to post-exploitation. Master the console navigation, understand your payloads, and always respect session management.