# 🌐 FTP Downloads

***

## 🌐 FTP Downloads — Old-School but Still Useful!

**FTP (File Transfer Protocol)** runs on **TCP ports 21 & 20** and is another handy method for moving files around a network. 🎯

You can use:

* 📦 The built-in **Windows FTP client**
* 💻 PowerShell’s **`Net.WebClient`** class

***

### 🐍 Step 1: Set Up Your Own FTP Server (Pwnbox Side)

Use **Python3** and the module **`pyftpdlib`** to quickly spin up an FTP server:

```bash
sudo pip3 install pyftpdlib
```

Then launch the server on **port 21** (default is 2121):

```bash
sudo python3 -m pyftpdlib --port 21
```

✅ This will allow anonymous logins by default (no username or password required).

***

### 🪄 Step 2: Download Files Using PowerShell

Here’s a simple one-liner to pull a file from your FTP server:

```powershell
(New-Object Net.WebClient).DownloadFile('ftp://192.168.49.128/file.txt', 'C:\Users\Public\ftp-file.txt')
```

📁 This saves `file.txt` from the FTP server into the `Public` directory.

***

### 🧰 Bonus: Using FTP with a Script (Non-Interactive Shell)

If you're working with a **limited shell (interactive shell)**, here's how to automate FTP with a command file:

```cmd
echo open 192.168.49.128 > ftpcommand.txt
echo USER anonymous >> ftpcommand.txt
echo binary >> ftpcommand.txt
echo GET file.txt >> ftpcommand.txt
echo bye >> ftpcommand.txt
ftp -v -n -s:ftpcommand.txt
```

💡 This runs all the FTP steps automatically.

Example output:

```txt
ftp> open 192.168.49.128
ftp> USER anonymous
ftp> GET file.txt
ftp> bye
```

Then check your file with:

```cmd
more file.txt
```

📄 Output:

```
This is a test file
```

***

#### 🚨 Quick Tips

* 🛡️ FTP is unencrypted! Avoid using it on sensitive or public networks.
* 🔒 If needed, add authentication to your server.
* 💾 `binary` mode ensures file integrity when transferring non-text files.
