February 26, 2020

PowerShell :: Base64 to string

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

Completing the numerous something to Base64 and back again scripts is this little one liner to get a string back from a Base64 encoded string.  This is useful a lot when doing offensive security as it allows you to store a script in Base64 then iex the decoded string.  ieex being an awesome PowerShell command that will execute the returned string.

Here is the code:

[System.Text.Encoding]::UTF8.GetString(([System.Convert]::FromBase64String($Base64) | ? {$_} ))

And as I said, if this was a PowerShell script we could run it with:

iex([System.Text.Encoding]::UTF8.GetString(([System.Convert]::FromBase64String($Base64) | ? {$_} )))

Previous «
Next »

Simon is a sysadmin for a global financial organisation and specialises in Windows, security and automation.

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: