# 📡 FTP Uploads

## 📡 FTP Uploads — Sending Files the Old-School Way

Just like downloading files via FTP, you can **upload files** using either:

* **PowerShell**
* The classic **Windows FTP client**

Let’s walk through how to set up your FTP server to accept uploads and how to send files from a Windows host! 🧭

***

### 🛠️ Step 1: Start Your FTP Server with Upload Support

Use the `pyftpdlib` Python module. But this time, include the `--write` flag to allow uploads ✍️

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

⚠️ You may see this warning:

```
write permissions assigned to anonymous user
```

That's okay! It just means **anonymous users can upload files**.

***

### 📤 Step 2: Upload a File with PowerShell

Use `UploadFile()` from the `Net.WebClient` class in PowerShell to push a file:

```powershell
PS C:\htb> (New-Object Net.WebClient).UploadFile('ftp://192.168.49.128/ftp-hosts', 'C:\Windows\System32\drivers\etc\hosts')
```

✅ This uploads your Windows `hosts` file to the FTP server and saves it as `ftp-hosts`.

***

### 📝 Step 3: Use Windows FTP Client to Upload

If you can’t use PowerShell or want to stay old-school, you can create a scriptable FTP command file:

```cmd
echo open 192.168.49.128 > ftpcommand.txt
echo USER anonymous >> ftpcommand.txt
echo binary >> ftpcommand.txt
echo PUT c:\windows\system32\drivers\etc\hosts >> ftpcommand.txt
echo bye >> ftpcommand.txt
```

#### Now run the FTP command using that file:

```cmd
ftp -v -n -s:ftpcommand.txt
```

💡 This avoids interactivity and runs everything in one go!

***

### 🔐 Notes & Tips

* `binary` ensures the file isn’t corrupted (important for non-text files!).
* Make sure port **21** is open and accessible.
* Consider enabling authentication if you're worried about security.
