# FTP

<table data-header-hidden><thead><tr><th width="178"></th><th></th></tr></thead><tbody><tr><td><strong>Puerto/s</strong></td><td><p>21 (Control)</p><p>20 (Datos - Modo Activo)</p></td></tr><tr><td><strong>Protocolo</strong></td><td>TCP</td></tr><tr><td><strong>Comunicación cifrada</strong></td><td>FTPS, SFTP</td></tr></tbody></table>

El protocolo FTP es un vector clásico para obtener credenciales en texto plano, archivos de configuración sensibles o incluso ejecución remota si los permisos están mal configurados.

## <mark style="color:$primary;">Reconocimiento y enumeración</mark>

La prioridad es identificar el software servidor (banner) y si permite accesos sin autenticación.

```bash
nmap -sV -Pn -p 21 --script="ftp-*" -oA ftp-enum <IP o RED>
```

```bash
nxc ftp scope.txt
```

## <mark style="color:$primary;">Conexión</mark>

```bash
ftp <IP>
ftp ftp://<usuario>:<contraseña>@<IP>
```

## <mark style="color:$primary;">Comandos útiles</mark>

* `binary`: Cambia a modo binario (obligatorio para descargar ejecutables/ZIPs sin corromperlos).
* `passive`: Alterna entre modo activo/pasivo (útil para evadir firewalls).
* `get <archivo>` / `mget *`: Descarga uno o múltiples archivos.
* `put <archivo>`: Sube archivos (si tienes permisos de escritura).

## <mark style="color:$primary;">Vulnerabilidades</mark>

### Configuraciones Inseguras (Low Hanging Fruit)

#### **\[V] Acceso Anónimo (Anonymous Login)**

Configuración por defecto en muchos servidores antiguos o mal mantenidos.

```bash
ftp ftp://anonymous:password@192.168.198.53
```

```bash
nxc ftp <IP O RED> -t 10 -u 'anonymous' -p '' --ls
```

#### **\[V] Permisos de Escritura (File Upload)**

Si puedes subir archivos, busca directorios que sean servidos por una aplicación web (ej. `wwwroot` en IIS) para subir una WebShell.

```bash
put shell.aspx
```

### Ataques de Red y Credenciales

#### **\[A] Sniffing (Texto Plano)**

FTP no cifra las comunicaciones. Si estás en la misma red (o mediante ARP Spoofing), puedes capturar las credenciales con Wireshark o Tcpdump.

```bash
tcpdump -i eth0 -A port 21 | grep -E "USER|PASS"
```

#### **\[A] Fuerza Bruta**

Si el acceso anónimo está desactivado, prueba diccionarios con NetExec.

```bash
nxc ftp <IP> -u users.txt -p passwords.txt
```

### Vulnerabilidades de Software (Exploits)

Servidores específicos tienen vulnerabilidades críticas conocidas:

* ProFTPD 1.3.5: Mod\_copy exploit (permite copiar archivos arbitrarios).
* vsftpd 2.3.4: Puerta trasera (Backdoor) famosa activada por el carácter `:)` en el usuario.

## <mark style="color:$primary;">Referencias</mark>

* <https://hackviser.com/tactics/pentesting/services/ftp>
* <https://www.thehacker.recipes/infra/protocols/ftp>
* <https://medium.com/@1200km/exploiting-ftp-vulnerabilities-for-effective-penetration-testing-a2810df78602>
* <https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-ftp/index.html#hacktricks-automatic-commands>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.xtormin.com/pentesting-en-infraestructuras/servicios/ftp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
