PowerShell :: Convert Base64 to a binary file
The script takes an input text file containing a Base64 string and then writes the decoded file back to disk. You can also use the $PEBytes variable with the PowerSploit project to run the executable in memory without writing it to disk.
$inputFilePath = "C:\Base64.txt" $outputFilePath = "C:\output.file" $PEBytes = [System.Convert]::FromBase64String([IO.File]::ReadAllText($InputFilePath)) [System.IO.File]::WriteAllBytes($outputFilePath, $PEBytes);
This script is designed in tandem with PowerShell :: Convert a binary file to Base64.