> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/connect-to-machines/ftp.md).

# FTP

## Download files via FTP

### Step 1 - Connect and login

```
kali@kali:~$ ftp 192.168.50.151
Connected to 192.168.50.151.
220 (vsFTPd 3.0.3)
Name (192.168.50.151:kali): anonymous
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
```

### Step 2 - Navigate and locate the files

Use `cd`, `pwd` and `ls` to navigate and locate the files you want to download.

### Step 3 - Download the file(s)

Use `get` to download a single file

```
ftp> get anonymousFTP.txt
local: anonymousFTP.txt remote: anonymousFTP.txt
229 Entering Extended Passive Mode (|||41539|)
150 Opening BINARY mode data connection for anonymousFTP.txt (26 bytes).
100% |***********************|    26       22.13 KiB/s    00:00 ETA
226 Transfer complete.
26 bytes received in 00:00 (0.34 KiB/s)
```

Or `mget` to download all the files that matches your wildcard expression

### Usage information

Use `help` to list available commands and to get more info on commands

```
┌──(kali㉿kali)-[~/Desktop]
└─$ ftp              
ftp> help
Commands may be abbreviated.  Commands are:

!               cdup            epsv4           hash            mdelete         mput            pdir            quote           rmdir           struct          user
$               chmod           epsv6           help            mdir            mreget          pls             rate            rstatus         sunique         verbose
account         close           exit            idle            mget            msend           pmlsd           rcvbuf          runique         system          xferbuf
append          cr              features        image           mkdir           newer           preserve        recv            send            tenex           ?
ascii           debug           fget            lcd             mls             nlist           progress        reget           sendport        throttle
bell            delete          form            less            mlsd            nmap            prompt          remopts         set             trace
binary          dir             ftp             lpage           mlst            ntrans          proxy           rename          site            type
bye             disconnect      gate            lpwd            mode            open            put             reset           size            umask
case            edit            get             ls              modtime         page            pwd             restart         sndbuf          unset
cd              epsv            glob            macdef          more            passive         quit            rhelp           status          usage
ftp> help mput
mput            send multiple files
ftp> exit

```

## Download files via wget

We can also download all files with wget's `-m` or `--mirror` parameter

```bash
wget -m ftp://anonymous:anonymous@10.11.12.13
```

To force an active FTP-connection, add the `--no-passive-ftp` parameter

```
wget -m --no-passive-ftp ftp://anonymous:anonymous@10.11.12.13
```

## Resources

File Transfer Protocol - Wikipedia: <https://en.wikipedia.org/wiki/File_Transfer_Protocol>

RFC 959 - File Transfer Protocol: <https://datatracker.ietf.org/doc/html/rfc959>
