the_open_door
coffee
ESEN
← Back to index

MachineAccountQuota

ATT&CKT1136.002

ms-DS-MachineAccountQuota is a domain attribute that defaults to 10, meaning any domain user, with no special privilege, can create up to ten computer accounts. It is the missing brick in several chains: on its own it grants no access, but it hands over an attacker controlled identity that the domain treats as legitimate.

Mechanism. A computer account is just another directory principal, with its own password and SPN. Whoever creates it knows that password, so they can request tickets as that account. That is exactly what two very common abuses need: RBCD, which requires a principal with an SPN to delegate to, and sAMAccountName spoofing, which requires a computer account to rename.

First check the value, which is a plain LDAP query:


netexec ldap <dc> -u <user> -p <pass> -M maq
MAQ  10.10.10.20  389  DC01  [*] Getting the MachineAccountQuota
MAQ  10.10.10.20  389  DC01  MachineAccountQuota: 10

If it is greater than zero, create the account:


impacket-addcomputer <domain>/<user>:<pass> -computer-name 'EVIL$' -computer-pass '<pass>' -dc-ip <dc>

Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount EVIL -Password (ConvertTo-SecureString '<pass>' -AsPlainText -Force)

Requirements. Valid credentials for any domain user and a MachineAccountQuota greater than zero. Local administrator rights are not needed anywhere.

How to detect it. Event 4741 (A computer account was created) with a Subject that is neither an administrative account nor the deployment service is the direct signal, and it is cheap to watch because in a normal domain computer accounts are created rarely and predictably. It is also worth alerting on computer names that do not follow the organisation's convention and on several creations by the same user in a short window.

Defence. Set ms-DS-MachineAccountQuota to 0 and delegate computer creation to a specific group through permissions on the relevant organisational unit. It is a single attribute change that removes the stepping stone in front of RBCD and sAMAccountName spoofing.