Last active
April 13, 2017 20:53
-
-
Save Darkbat91/907d089788122089541f804402583f96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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