May 24, 2018

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 Local Government in North Yorkshire with a real passion for security and coding.

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: