Windows File Transfers

Windows File Transfers

Windows systems provide various native and third-party methods for transferring files across networks. Understanding these transfer techniques is crucial for penetration testers, especially when moving tools to and from compromised systems.

Base64 Transfer Technique

For small files, Base64 encoding provides a method to transfer data without requiring direct file transfer protocols.

Encoding and Decoding Files

# Linux: Encode file
cat id_rsa | base64 -w 0
# Windows: Decode file
[IO.File]::WriteAllBytes("C:\Users\Public\id_rsa", [Convert]::FromBase64String("LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNC..."))

# Windows: Encode file
[Convert]::ToBase64String((Get-Content -path "C:\Windows\system32\drivers\etc\hosts" -Encoding byte))

PowerShell Web Transfers

PowerShell offers multiple built-in methods to download files from web servers.

Download Operations

SSL/TLS Errors Bypass

Fileless Execution

SMB File Transfers

Server Message Block (SMB) protocol running on TCP/445 is commonly used in Windows environments for file sharing.

Setting Up SMB Server on Linux

Connecting from Windows

WebDAV for SMB over HTTP

When direct SMB is blocked, WebDAV provides SMB functionality over HTTP:

FTP File Transfers

File Transfer Protocol (FTP) on TCP ports 20/21 provides another option when SMB is unavailable.

Setting Up FTP Server on Linux

PowerShell FTP Download

Non-Interactive FTP Download

Upload Operations

PowerShell Base64 Encoding for Upload

PowerShell Web Upload

FTP Upload

BITS (Background Intelligent Transfer Service)

BITS is a Windows component designed for efficient file transfers with bandwidth throttling.

CertUtil Downloads

CertUtil, a Windows certificate utility, can be repurposed for file downloads.

Common Errors and Mitigations

IE First-Launch Error

SSL/TLS Certificate Error

SMB Access Denied Error

Best Practices

  1. Use HTTPS/SSL when transferring sensitive data

  2. Clean up files after transfer when possible

  3. Consider multi-stage transfers for AV evasion

  4. Validate file integrity using file hashes

  5. Use native tools to avoid introducing new binaries

  6. Test transfers on similar systems before actual use

Last updated