knowledge

Overview

FTP (File Transfer Protocol) is one of the oldest application-layer protocols for transferring files between a client and server over TCP/IP. It uses two separate channels — a control channel on TCP/21 for commands and a data channel on TCP/20 for file transfer. FTP transmits credentials and data in cleartext, making it a high-value target during network penetration tests. Misconfigured FTP servers frequently allow anonymous access and file uploads, which can lead to Local File Inclusion or Remote Code Execution vulnerabilities.


Terminology

TermDefinition
FTPFile Transfer Protocol — application-layer protocol using TCP ports 20 (data) and 21 (control)
FTPSFTP Secure — FTP with TLS/SSL encryption added
SFTPSSH File Transfer Protocol — secure file transfer tunneled over SSH; not related to FTP
TFTPTrivial File Transfer Protocol — simplified, connectionless FTP variant using UDP; no authentication
Active ModeClient opens a random port and tells the server; server connects back to client — blocked by client-side firewalls
Passive ModeServer opens a random port and tells the client; client connects to server — firewall-friendly
vsFTPdVery Secure FTP Daemon — one of the most widely deployed FTP servers on Linux
Anonymous FTPLogin using anonymous as username and any email as password; used for public file distribution
SUIDSet User ID — file permission bit that runs a file with owner’s privileges; relevant to FTP upload exploitation

Core Concepts

Active vs Passive Mode

FTP requires a second channel for actual data transfers. How that channel is opened determines whether a firewall blocks it:

ModeHow It WorksFirewall Behavior
ActiveClient sends PORT command with its IP and port; server initiates data connection back to clientClient-side firewalls block inbound server connection
PassiveClient sends PASV command; server responds with its IP and port; client initiates data connectionClient-initiated — passes through most firewalls

Most modern FTP clients default to passive mode for compatibility.


TFTP (Trivial File Transfer Protocol)

TFTP is a stripped-down FTP variant designed for simple file transfers where authentication is not needed.

  • Uses UDP — connectionless and unreliable; no error correction
  • No user authentication — access controlled only by OS file permissions
  • No directory listing
  • Typically used in local/protected networks for network booting (PXE), router firmware delivery, and device configuration
  • Files accessible to all users globally by default
TFTP CommandDescription
connectSet remote host and optional port
getTransfer file(s) from remote to local
putTransfer file(s) from local to remote
statusShow current transfer mode, connection status, timeout
verboseToggle verbose output
quitExit TFTP

vsFTPd Default Configuration

vsFTPd is configured via /etc/vsftpd.conf. Many settings are not included in the default config file and require the man page for reference. /etc/ftpusers denies specific system users from FTP access even if they have valid OS accounts.

Key configuration options:

SettingDescription
listen=YESRun vsFTPd in standalone mode
anonymous_enable=YESAllow anonymous login — common in internal environments
local_enable=YESAllow local OS user accounts to log in
write_enable=YESAllow write commands (STOR, DELE, RNFR, RNTO, etc.)
local_umask=022File permission mask for uploaded files
dirmessage_enable=YESShow .message file content when entering a directory
use_localtime=YESUse local server time for directory listings
xferlog_enable=YESLog all uploads and downloads
connect_from_port_20=YESUse port 20 for data connections in active mode
chroot_local_user=YESJail local users to their home directory
ssl_enable=YESEnable SSL/TLS support
hide_ids=YESReplace user/group names with “ftp” in listings — obscures real usernames
pasv_min_port / pasv_max_portDefine port range for passive mode data connections

Dangerous Settings

SettingRisk
anonymous_enable=YESAnyone can connect and browse/download without credentials
write_enable=YESCombined with anonymous access allows anonymous file uploads
anon_upload_enable=YESExplicitly allows anonymous uploads
anon_mkdir_write_enable=YESAllows anonymous users to create directories
no_anon_password=YESNo password prompt for anonymous login
hide_ids=YESAttackers see “ftp” owner on all files — harder to identify real accounts, but also hides ownership cues

If write access is enabled, uploaded files can be leveraged for Local File Inclusion (LFI) if the FTP root overlaps with a web root, or for Remote Code Execution via FTP log poisoning.


Footprinting FTP

Scan port 21 and grab the service banner with Nmap (-sV -sC). FTP-specific NSE scripts can probe supported commands, auth methods, and anonymous login status.

Test manual interaction by connecting with Telnet or netcat — the FTP banner reveals the server software and version. For TLS-enabled FTP, use openssl s_client -connect <target>:21 -starttls ftp to inspect the certificate (CN, organization, expiry).

Download all files from an anonymous FTP share at once: wget -m --no-passive ftp://anonymous:anonymous@<target>


  • Service Enumeration

References / Images