Directory Services Restore Mode (DSRM)
Last updated
Last updated
In every domain there is a Domain Admin named 'Administrator'. However, on every Domain Controller there is also a local Administrator. These two users are different.
How can we tell?
If you have Domain Admin privileges, dump both the SAM and the NTDS and you will get two different hashes for 'Administrator'.
The differences can also be seen using these Mimikatz commands respectively as well:
The Administrator hash from the SAM dump belongs to the local Administrator and the NTDS hash to the Domain Administrator.
The local Administrator on the DC is also known as the DSRM account.
What does this mean?
In general, the local Administrator account is hardly used on a running DC. However, to configure a Domain Controller, we are prompted to enter a DSRM password for the local Administrator. This provides a backup method for the Domain Admins to access the DC and the database.
This means that obtaining the local DC Administrator hash and then passing it provides another long-term method of persistence. It can be quite effective because the DSRM password is rarely changed.
As the local Admin is usually not able to logon to the DC, we must first make sure that we will be able to logon by changing the "DsrmAdminLogonBehavior" registry key. This will be a significant downgrade to the security of the Domain Controller. Therefore, if you are on a live engagement, make sure to check with your client that this is allowable.
Once we have the hash we can either use that hash and pass it to access the DC or we can follow up with a DCSync attack and pull up the passwords for any account you wish, including the krbtgt.
Method 1: From Powershell - Use Mimikatz
Method 2: Copy the SAM and system hives, download them, then run secretsdump.py from impacket to extract the hash
Method 3: From Linux - use crackmapexec or secretsdump.py to extract the hash remotely
From the DC...
From another machine, attempt to logon to the DC
Change the DSRM password regularly
Check regularly for events with ID 4657 or 4794
Make sure DSRM passwords are unqiue for each DC