Skip to content

Instantly share code, notes, and snippets.

@idiom
Created April 24, 2017 18:15
Show Gist options
  • Save idiom/a1940bc1c7496e3e431c023ce0728608 to your computer and use it in GitHub Desktop.
Save idiom/a1940bc1c7496e3e431c023ce0728608 to your computer and use it in GitHub Desktop.
Script to decode a Base64 Encoded and Compressed PowerShell script
#
# Decode a base64 and compressed Powershell script.
#
#
#
#
$input = Read-Host -Prompt 'Base64 Text'
$decoded = $(New-Object IO.StreamReader ($(New-Object IO.Compression.DeflateStream($(New-Object IO.MemoryStream(,$([Convert]::FromBase64String($input)))), [IO.Compression.CompressionMode]::Decompress)), [Text.Encoding]::ASCII)).ReadToEnd();
Write-Host "----- Decoded -----"
Write-Host $decoded
Write-Host "----- Decoded End -----"
@EatMoreChicken
Copy link

Nice and easy script. I am going to taking inspiration form this to implement into a project. Thank you!

@sp00ks-git
Copy link

Exception calling "ReadToEnd" with "0" argument(s): "Unknown block type. Stream might be corrupted."

@oflavioc
Copy link

Got the same error as sp00ks-git mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment