CTFroom: Kenobi — Samba Share Enumeration, ProFTPd RCE & SUID Path Hijacking
Enumerating anonymous Samba shares, leveraging a ProFTPd mod_copy vulnerability (CVE-2015-3306) to copy private SSH keys via an accessible NFS share, and escalating to root via SUID environment PATH manipulation.
Challenge Overview
Kenobi explores multiple network services running in tandem: enumerating SMB shares, exploiting an unauthenticated file copying vulnerability in ProFTPd (mod_copy), mounting network file systems (NFS), and abusing relative binary paths in custom SUID applications.
Phase 1: Service Enumeration
Open ports discovered:
We enumerate SMB shares using Nmap scripts:
Three shares are identified:
IPC$print$anonymous (Read access permitted)Phase 2: Inspecting Anonymous Share & NFS
Connecting to the anonymous SMB share:
Reading log.txt, we uncover two critical pieces of intelligence:
/home/kenobi/.ssh/id_rsa).Next, we inspect NFS export shares using showmount:
The entire /var directory is exported and mountable by any remote host!
Phase 3: Exploiting ProFTPd (mod_copy / CVE-2015-3306)
ProFTPd version 1.3.5 includes the mod_copy module by default, which implements SITE CPFR (copy from) and SITE CPTO (copy to) commands. Crucially, these commands do not require authentication.
We can instruct ProFTPd to copy Kenobi's private SSH key directly into the mountable /var/tmp directory:
Phase 4: Mounting NFS & SSH Access
We mount the remote /var NFS share locally to retrieve the copied SSH key:
We connect as user kenobi:
User flag recovered from /home/kenobi/user.txt.
Phase 5: SUID Path Hijacking to Root
We search for SUID binaries owned by root:
We spot a custom binary: /usr/bin/menu.
Running /usr/bin/menu presents three options:
We run strings /usr/bin/menu to analyze how it executes system commands:
Notice that the binary calls curl without specifying an absolute path (e.g., /usr/bin/curl). Because it runs as root (via SUID), we can hijack the curl command by manipulating our user's PATH environment variable:
Now we run /usr/bin/menu and select option 1 ("Status Check"):
The binary executed our malicious /tmp/curl with root privileges. Root flag recovered at /root/root.txt.
Defense Remediation
/var with wildcards (*). Restrict exports to authorized IP addresses./usr/bin/curl rather than relative curl in system calls.