May 24, 2018

PowerShell :: Convert Base64 to a binary file

PowerShell ISE logo
(Last Updated On: 14th September 2016)

Hi,

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.

Previous «
Next »

Simon is a sysadmin for Local Government in North Yorkshire with a real passion for security and coding.

1 Comment

  1. Pingback: PowerShell :: Convert a binary file to Base64 – Synack

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: