Computeraccount Takeover
If you have GenericAll or GenericWrite rights to a computer object you can write to the attribute msds-AllowedToActOnBehalfOfOtherIdentity and the abuse the delegation to take over the system
Configuring
Prerequisite
OwnsConfiguring
Nothing need to be configured to abuse this since we set the GenericAll permissions during the "Owns" section. If you would like to configure this it can be configured the same way as we configured "Write Owner".
Attacking
How it works
If you have GenericAll or GenericWrite rights to a computer object you can write to the attribute msds-AllowedToActOnBehalfOfOtherIdentity
. If you control this attribute you can impersonate and authenticate as any domain user to the computer. Resulting in getting access to the computer as long as you can impersonate a user that has access too it. Users with the flag "This account is senstitive and cannot be delegated" or members of the "Protected Users Group" can't be impersonated.
Tools
Executing the attack
Prereqesuite
An account with a SPN associated (or able to add new machines accounts (default value this quota is 10))
A user with write privileges over the target computer which doesn't have msds-AllowedToActOnBehalfOfOtherIdentity
Executing the attack
It is expected that the GenericAll permissions during the ACL abuses "Write Owner" and "Owns" are set for the
sa_sql
user. This attack will continue from there:
2. First we will check that the target doesn't have the msds-AllowedToActOnBehalfOfOtherIdentity
attribute set.
The attribute haven't been set yet.
3. Add the following to the /etc/hosts
file on Kali otherwise the Crackmapexec command will fail:
4. Check if we can add computers to the domain since its a requirement for the attack. We can get the machine account qouta from the domain with Crackmapexec:
The machine account qouta is 10, meaning we (all authenticated users) can create our own computerobject in the domain.
5. Create a machine account with the name FAKE01
and password 123456
with PowerMad:
6. Get the SID of the computerobject we created:
7. Now we need to create the raw security descriptor which we then will write to the attribute:
Make sure you changed the SID since it can differ in your lab.
8. Now we can write as sa_sql
to the msds-allowedtoactonbehalfofotheridentity
attribute of the computerobject DATA01
:
9. Seems like it worked, now we can check the value of the msds-AllowedToActOnBehalfOfOtherIdentity
attribute by saving it in a variable and doing some powershell confu to decrypt it:
10. FAKE01
can impersonate any user now to DATA01
. To do this we first need to calculate the NTLM hash for the FAKE01
password, we can do this with Rubeus.
Temporarily disable Windows Defender if it gets flagged by it.
11. The next step is to run Rubeus to impersonate the Administrator
user using the FAKE01
Computeraccount. Abusing Resource Based Constrained Delegation. We will request a CIFS ticket so we can list the C disk.
12. We got a CIFS ticket as Administrator
for data01.secure.local
, now we can try to list the C disk.
Cleanup
Login to
DC03
asAdministrator
with the passwordWelcome01!
.Execute the following command to remove the
msDS-AllowedToActOnBehalfOfOtherIdentity
attribute fromDATA01
.
3. Execute the following command to remove the FAKE01
computer we created:
Defending
Recommendations
Change who can add computers to the domain.
Add privileged users to the protected users group.
Add the flag "Account is sensitive and cannot be delegated".
Detection
References
Last updated