FTP Security and Penetration Testing Playbook
FTP (File Transfer Protocol) is a standard network protocol used for transferring files between a client and server on a computer network. This playbook outlines key aspects of FTP security, testing procedures, and best practices.
FTP Basics
- Port Information:
- Control Connection: Port 21
- Data Transfer: Port 20
Security Assessment Tools
Nmap
Nmap is a powerful network scanning and discovery tool. Here are some useful Nmap commands for FTP security assessment:
sudo nmap -sV -p21 -sC -A <target_ip>
This command performs:
- Service/version detection (-sV)
- Scans port 21 (-p21)
- Runs default scripts (-sC)
- Enables OS detection, version scanning, script scanning, and traceroute (-A)
For more detailed output:
sudo nmap -sV -p21 -sC -A <target_ip> --script-trace
Other Useful Tools
- Netcat: For basic connection testing
nc -nv <target_ip> 21
- Telnet: For interactive sessions
telnet <target_ip> 21
- OpenSSL: For testing FTPS (FTP over SSL/TLS)
openssl s_client -connect <target_ip>:21 -starttls ftp
FTP Enumeration and Exploitation
- Anonymous Access:
Test for anonymous FTP access:
ftp <target_ip>
Use “anonymous” as username and password.
- Recursive Download:
If anonymous access is allowed, attempt to download all accessible files:
wget -m --no-passive ftp://anonymous:anonymous@<target_ip>
- File Structure Analysis:
After downloading, analyse the file structure.
tree .
Best Practices
- Restrict FTP Access:
- Regularly review and update /etc/ftpusers file to restrict FTP access for sensitive accounts.
- Use Secure Alternatives:
- Consider using SFTP (SSH File Transfer Protocol) or FTPS (FTP over SSL/TLS) instead of plain FTP.
- Regular Security Audits:
- Perform regular security scans and penetration tests on FTP servers.
- Keep Tools Updated:
- Regularly update security tools. For Nmap:
sudo nmap --script-updatedb
Conclusion
This playbook provides a structured approach to FTP security assessment and best practices. Regular updates and adherence to these guidelines will help maintain a secure FTP environment. Always ensure that penetration testing is conducted ethically and with proper authorisation.