Exploitation - gMS accounts (gMSAs)
Active Directory - group Managed Service Accounts (gMSAs)
Overview
gMSAs enumeration
# Enumerates the gMSA in the domain.
Get-ADServiceAccount -Filter *
Get-ADObject -LDAPFilter "(objectClass=msDS-GroupManagedServiceAccount)" -Properties *
# Retrieves the principals allowed to retrieve gMSAs' password.
Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword
# Retrieves the principals allowed to retrieve gMSAs' password and highlights potentially dangerous rights (simple analysis based on direct principal names matching).
$PrivilegedPrincipalsRegex = [string]::Join('|', @('CN=Domain Admins', 'CN=Enterprise Admins', 'CN=Domain Controllers'))
$UnprivilegedPrincipalsRegex = [string]::Join('|', @('CN=Domain Users', 'Everyone', 'CN=Domain Computers', 'Authenticated Users', 'Anonymous'))
Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword | ForEach-Object {
Write-Host -ForegroundColor DarkGreen -BackgroundColor White $_.SamAccountName
Write-Host $_.DistinguishedName
Write-Host $_.SID
Write-Host "`n"
Write-Host "PrincipalsAllowedToRetrieveManagedPassword:"
foreach ($Principal in $_.PrincipalsAllowedToRetrieveManagedPassword) {
If ($Principal -match $UnprivilegedPrincipalsRegex) {
Write-Host -ForegroundColor Green $Principal
}
ElseIf ($Principal -match $PrivilegedPrincipalsRegex) {
Write-Host -ForegroundColor Red $Principal
}
Else { Write-Host -ForegroundColor Yellow $Principal }
}
Write-Host "`n"
}gMSAs ACL enumeration and msDS-GroupMSAMembership modification
gMSAs password retrieval
Tool
URL
Description
References
Last updated