Last active
June 5, 2020 17:44
-
-
Save bmkaiser/bfe2a04fe7f7e47d50698ecda827d68d to your computer and use it in GitHub Desktop.
How to Decrypt Password Files that Have Been Encrypted with a Key
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
$keyPath = 'path.key' | |
$passPath = 'path.txt' | |
$account = 'username' | |
$key = Get-Content -Path $keyPath | |
$pass = Get-Content -Path $passPath | ConvertTo-SecureString -Key $key | |
# POWERSHELL 5.1, 6 | |
$credentials = New-Object -TypeName System.Management.Automation.PSCredential($account,$pass) | |
$clearPass = $credentials.GetNetworkCredential().Password | |
# POWERSHELL 7 | |
$clearPass = ConvertFrom-SecureString -SecureString $pass -AsPlainText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
Examples on how to derive a cleartext password from an encrypted string when you have access to the key that was used to encrypt it.
Resources & Documentation