Skip to content

Instantly share code, notes, and snippets.

@Darkbat91
Last active April 13, 2017 20:53
Show Gist options
  • Save Darkbat91/907d089788122089541f804402583f96 to your computer and use it in GitHub Desktop.
Save Darkbat91/907d089788122089541f804402583f96 to your computer and use it in GitHub Desktop.
function Get-UnobfuscatedData
{
param($string)
$data = Replacehex -string $string
return [System.Text.Encoding]::UTF8.GetString(([System.Convert]::FromBase64String($data)|?{$_}))
}
function Replacehex {
param($string)
[regex]$regex ='(\%[A-Fa-f0-9]{2})'
$Matches = $regex.Match($data)
if($Matches.Success)
{
foreach($Match in $Matches.Groups)
{
$value = $Match.value
$string = $string.replace($value, (Convertfrom-Hex -key $value))}}
else
{ # No hex characters
}
return $string
}
function Convertfrom-Hex
{
param($key)
return [CHAR]([CONVERT]::toint16($key.replace('%',''),16))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment