1
0
mirror of https://github.com/mgeeky/Penetration-Testing-Tools.git synced 2024-12-23 09:29:46 +01:00
mgeeky-Penetration-Testing-.../red-teaming/Decode-UnattendPassword.ps1

15 lines
1.1 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function Decode-UnattendedPassword {
param(
[Parameter(Mandatory=$true)]
$Path
)
$data = [io.file]::ReadAllText($Path)
$regex = '(?smi)<AdministratorPassword>[\r\n\s]+<Value>([a-zA-Z0-9/\+=\-]+)</Value>'
$val = $data | Select-String -Pattern $regex -AllMatches |
%{ $_.Matches } | %{$_.Groups[1]} | %{
$o = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($_.Value))
$f = 'AdministratorPassword'
Write-Host $($o.Substring(0, $o.Length-$f.Length))
}
}