Skip to content

Instantly share code, notes, and snippets.

@bmkaiser
Last active June 5, 2020 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmkaiser/bfe2a04fe7f7e47d50698ecda827d68d to your computer and use it in GitHub Desktop.
Save bmkaiser/bfe2a04fe7f7e47d50698ecda827d68d to your computer and use it in GitHub Desktop.
How to Decrypt Password Files that Have Been Encrypted with a Key
$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
@bmkaiser
Copy link
Author

bmkaiser commented Jun 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment