CTF Arsenal
Boot2Root/Other B2R Topics

FTP Exploitation & Enumeration

Concept

FTP (port 21) is checked for anonymous access and version-specific vulnerabilities. Anonymous FTP often exposes files directly useful for a foothold (credentials, source code, or a writable directory for upload-based access).

When to Use

  • Port 21 open during nmap scan.

Workflow

  1. 1
    Test anonymous login

    Username anonymous, any password/blank.

  2. 2
    List and download all accessible files

    Recursively if directories exist.

  3. 3
    Check for a writable directory

    Potential upload path if FTP root overlaps a web root.

  4. 4
    Check banner/version for known CVEs

    e.g. vsftpd 2.3.4 backdoor.

Commands

ftp TARGET_IP
ftp 10.10.11.25

Connects interactively; try 'anonymous' as username with any/blank password.

When to use: First manual test against any open FTP port.

Expected output:

230 Login successful.

Look for: Successful login as anonymous.

Next step: ls to list files, get FILE_PATH to download, put FILE_PATH to test write access.

wget -r ftp://anonymous:anonymous@TARGET_IP/
wget -r ftp://anonymous:anonymous@10.10.11.25/

Recursively mirrors the entire accessible FTP tree to your local machine for offline review.

  • -r — Recursive download.

When to use: Once anonymous access is confirmed and there's more than a couple of files to review.

Expected output:

Downloaded files into a directory named after the target IP.

Look for: Any config, script, or document files among the mirrored content.

Next step: grep -r 'password' on the mirrored directory.

Tools

nmap (ftp-anon script)

Automated anonymous-login check.

When to use: As part of the initial service scan.

nmap --script ftp-anon -p 21 TARGET_IP

Example workflow: Run alongside the main nmap scan to confirm anonymous access without a manual connection.

Findings & Interpretation

Interesting

  • Credentials or SSH keys left in an FTP-accessible directory
  • Writable directory reachable also via HTTP (web root overlap)

False Positives

  • Anonymous login succeeding with zero listable files is a dead end, not a vulnerability by itself

How to Validate

  • Confirm write access actually persists a file (upload then re-list) before relying on it for a foothold

Next Step

  • If writable and web-exposed, upload a webshell/payload for RCE.

Troubleshooting

Connection refused on port 21.

Likely cause: Service only listens on a specific interface, or firewall rules restrict access.

Verify: Re-confirm with nmap -p21 -sV TARGET_IP that the port is genuinely open from your current network path.

Fix: Re-check VPN connectivity; some FTP services use passive mode which can be blocked separately from the control port.

Recovery: Try ftp in passive mode explicitly, or use lftp as an alternative client.

Avoid repeating: Confirm port state with a fresh scan before troubleshooting the client.