@@ -14,29 +14,29 @@ if ($output.count -eq 0) {
1414# Decrypting passwords using DPAPI
1515Add-Type - assembly System.Security
1616$output | ForEach-Object - Process {
17- $EnryptedPWD = [Convert ]::FromBase64String($_.password )
17+ $EncryptedPWD = [Convert ]::FromBase64String($_.password )
1818 $enc = [system.text.encoding ]::Default
1919
2020 try {
2121 # Decrypt password with DPAPI (old Veeam versions)
22- $raw = [System.Security.Cryptography.ProtectedData ]::Unprotect( $EnryptedPWD , $null , [System.Security.Cryptography.DataProtectionScope ]::LocalMachine )
22+ $raw = [System.Security.Cryptography.ProtectedData ]::Unprotect( $EncryptedPWD , $null , [System.Security.Cryptography.DataProtectionScope ]::LocalMachine )
2323 $pw_string = $enc.GetString ($raw ) -replace ' \s' , ' WHITESPACE_ERROR'
2424 } catch {
2525 try {
2626 # Decrypt password with salted DPAPI (new Veeam versions)
2727 $salt = [System.Convert ]::FromBase64String($b64Salt )
28- $hex = New-Object - TypeName System.Text.StringBuilder - ArgumentList ($EnryptedPWD .Length * 2 )
29- foreach ($byte in $EnryptedPWD )
28+ $hex = New-Object - TypeName System.Text.StringBuilder - ArgumentList ($EncryptedPWD .Length * 2 )
29+ foreach ($byte in $EncryptedPWD )
3030 {
3131 $hex.AppendFormat (" {0:x2}" , $byte ) > $null
3232 }
3333 $hex = $hex.ToString ().Substring(74 , $hex.Length - 74 )
34- $EnryptedPWD = New-Object - TypeName byte[] - ArgumentList ($hex.Length / 2 )
34+ $EncryptedPWD = New-Object - TypeName byte[] - ArgumentList ($hex.Length / 2 )
3535 for ($i = 0 ; $i -lt $hex.Length ; $i += 2 )
3636 {
37- $EnryptedPWD [$i / 2 ] = [System.Convert ]::ToByte($hex.Substring ($i , 2 ), 16 )
37+ $EncryptedPWD [$i / 2 ] = [System.Convert ]::ToByte($hex.Substring ($i , 2 ), 16 )
3838 }
39- $raw = [System.Security.Cryptography.ProtectedData ]::Unprotect($EnryptedPWD , $salt , [System.Security.Cryptography.DataProtectionScope ]::LocalMachine)
39+ $raw = [System.Security.Cryptography.ProtectedData ]::Unprotect($EncryptedPWD , $salt , [System.Security.Cryptography.DataProtectionScope ]::LocalMachine)
4040 $pw_string = $enc.GetString ($raw ) -replace ' \s' , ' WHITESPACE_ERROR'
4141 }catch {
4242 $pw_string = " COULD_NOT_DECRYPT"
0 commit comments