On this page 21 sections
- What FTP is
- Default ports
- Initial enumeration
- Useful Nmap FTP scripts
- Anonymous login
- Anonymous credentials
- FTP navigation
- Download files
- Upload files
- Check read and write permissions
- Why writable FTP matters
- Metasploit FTP version scanner
- Metasploit anonymous FTP
- Metasploit FTP login
- Hydra FTP authentication testing
- Connection throttling
- Active FTP
- Passive FTP
- FTP vs FTPS vs SFTP
- Enumeration workflow
- Quick reference
What FTP is
FTP, or File Transfer Protocol, is used to transfer files between a client and a server. Traditional FTP does not encrypt credentials or transferred data, so usernames, passwords and files may travel in clear text.
Default ports
FTP normally uses TCP port 21 for the control connection. Traditional active FTP may use TCP port 20 for the server-side data connection. FTPS may use port 21 with explicit TLS or port 990 for implicit FTPS.
Initial enumeration
Start by confirming that the FTP service is reachable and identifying the server implementation and version. Banner and version information may reveal useful details about the software in use.
nmap -sV -p 21 <TARGET>nmap -sC -sV -p 21 <TARGET>nc -nv <TARGET> 21Useful Nmap FTP scripts
Nmap includes NSE scripts that can check anonymous access, retrieve server information and perform additional FTP enumeration.
nmap -p 21 --script ftp-anon <TARGET>nmap -p 21 --script ftp-syst <TARGET>nmap -p 21 --script "ftp-*" <TARGET>ls /usr/share/nmap/scripts/ftp*Anonymous login
One of the first checks against an FTP server is whether anonymous authentication is allowed. Anonymous FTP is not automatically vulnerable; the real impact depends on the files that can be accessed and whether the anonymous account has write permissions.
ftp <TARGET>Anonymous credentials
A common anonymous FTP login uses anonymous as the username. The password may also be anonymous, blank or an email address depending on the server configuration.
anonymousanonymousFTP navigation
Once authenticated, enumerate available directories and files before downloading anything. FTP clients provide commands similar to basic filesystem navigation.
lsdirpwdcd <DIRECTORY>lcd <LOCAL_DIRECTORY>Download files
Interesting FTP content may include configuration files, backups, scripts, source code, documentation or exposed credentials. Download relevant files for offline analysis when authorised.
get <FILE>mget *Upload files
Write access is more significant than read-only access because it allows files to be created or modified. However, FTP write access does not automatically provide code execution; the impact depends on where the writable directory is used.
put <FILE>mput <FILES>Check read and write permissions
Determine whether the current FTP account can read, download, upload, overwrite or delete files. When write testing is authorised, use a harmless test file instead of modifying existing content.
put test.txtdelete test.txtWhy writable FTP matters
A writable directory becomes especially interesting when it maps to another service, such as a web root, application directory or automated file-processing location. The context determines whether file upload can lead to a greater impact.
Metasploit FTP version scanner
Metasploit contains auxiliary modules for FTP service detection and enumeration.
msfconsolesearch type:auxiliary ftpuse auxiliary/scanner/ftp/ftp_versionset RHOSTS <TARGET>runMetasploit anonymous FTP
The anonymous FTP scanner checks whether the server permits anonymous authentication.
use auxiliary/scanner/ftp/anonymousset RHOSTS <TARGET>runMetasploit FTP login
The FTP login scanner can validate username and password combinations during an authorised credential audit.
use auxiliary/scanner/ftp/ftp_loginset RHOSTS <TARGET>set USER_FILE <USERLIST>set PASS_FILE <PASSWORDLIST>runHydra FTP authentication testing
Hydra can validate FTP credentials against a target. Aggressive login attempts may trigger rate limiting, account lockouts, temporary blocking or connection throttling.
hydra -l <USERNAME> -P <PASSWORDLIST> ftp://<TARGET>hydra -L <USERLIST> -P <PASSWORDLIST> ftp://<TARGET>hydra -V -L <USERLIST> -P <PASSWORDLIST> ftp://<TARGET>Connection throttling
If the FTP server starts closing connections during repeated authentication attempts, this may indicate rate limiting, connection limits or another service-protection mechanism. It should not be treated as universal FTP behaviour.
Active FTP
In active mode, the client creates the control connection to the server, but the server initiates the data connection back toward the client. This can create problems when the client is behind NAT or restrictive firewall rules.
Passive FTP
In passive mode, the client initiates both the control and data connections. This generally works better through NAT and firewalls and is commonly used in modern environments.
FTP vs FTPS vs SFTP
FTP is the traditional unencrypted protocol. FTPS is FTP protected with TLS. SFTP is the SSH File Transfer Protocol and runs over SSH, normally on TCP port 22. SFTP is not the same thing as FTP over SSH.
Enumeration workflow
Confirm the FTP service, identify the version, capture the banner, test anonymous access, enumerate files and directories, determine read and write permissions, analyse interesting files and then validate credentials if authorised. Correlate any writable directory with other exposed services.
nmap -sC -sV -p 21 <TARGET>nmap -p 21 --script ftp-anon <TARGET>ftp <TARGET>Quick reference
These are the FTP commands worth remembering during service enumeration.
nmap -sV -p 21 <TARGET>nmap -sC -sV -p 21 <TARGET>nmap -p 21 --script ftp-anon <TARGET>ftp <TARGET>nc -nv <TARGET> 21hydra -L <USERLIST> -P <PASSWORDLIST> ftp://<TARGET>use auxiliary/scanner/ftp/ftp_versionuse auxiliary/scanner/ftp/anonymoususe auxiliary/scanner/ftp/ftp_login