Abusing Active Directory ACLs/ACEs
Last updated
Last updated
This information was copied from https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces because it's just perfect
This lab is to abuse weak permissions of Active Directory Discretionary Access Control Lists (DACLs) and Acccess Control Entries (ACEs) that make up DACLs.
Active Directory objects such as users and groups are securable objects and DACL/ACEs define who can read/modify those objects (i.e change account name, reset password, etc).
An example of ACEs for the "Domain Admins" securable object can be seen here:
Some of the Active Directory object permissions and types that we as attackers are interested in:
GenericAll - full rights to the object (add users to a group or reset user's password)
GenericWrite - update object's attributes (i.e logon script)
WriteOwner - change object owner to attacker controlled user take over the object
WriteDACL - modify object's ACEs and give attacker full control right over the object
AllExtendedRights - ability to add user to a group or reset password
ForceChangePassword - ability to change user's password
Self (Self-Membership) - ability to add yourself to a group
In this lab, we are going to explore and try to exploit most of the above ACEs.
Using powerview, let's check if our attacking user spotless
has GenericAll rights
on the AD object for the user delegate
:
We can see that indeed our user spotless
has the GenericAll
rights, effectively enabling the attacker to take over the account:
We can reset user's delegate
password without knowing the current password:
Let's see if Domain admins
group has any weak permissions. First of, let's get its distinguishedName
:
We can see that our attacking user spotless
has GenericAll
rights once again:
Effectively, this allows us to add ourselves (the user spotless
) to the Domain Admin
group:
Same could be achieved with Active Directory or PowerSploit module:
If you have these privileges on a Computer object, you can pull Kerberos Resource-based Constrained Delegation: Computer Object Take Over off.
If our controlled user has WriteProperty
right on All
objects for Domain Admin
group:
We can again add ourselves to the Domain Admins
group and escalate privileges:
Another privilege that enables the attacker adding themselves to a group:
One more privilege that enables the attacker adding themselves to a group:
If we have ExtendedRight
on User-Force-Change-Password
object type, we can reset the user's password without knowing their current password:
Doing the same with powerview:
Another method that does not require fiddling with password-secure-string conversion:
...or a one liner if no interactive session is not available:
and one last way yo achieve this from linux:
More info:
Note how before the attack the owner of Domain Admins
is Domain Admins
:
After the ACE enumeration, if we find that a user in our control has WriteOwner
rights on ObjectType:All
...we can change the Domain Admins
object's owner to our user, which in our case is spotless
. Note that the SID specified with -Identity
is the SID of the Domain Admins
group:
WriteProperty
on an ObjectType
, which in this particular case is Script-Path
, allows the attacker to overwrite the logon script path of the delegate
user, which means that the next time, when the user delegate
logs on, their system will execute our malicious script:
Below shows the user's
logon script field got updated in the AD:delegate
If you are the owner of a group, like I'm the owner of a Test
AD group:
Which you can of course do through powershell:
And you have a WriteDACL
on that AD object:
...you can give yourself GenericAll
privileges with a sprinkle of ADSI sorcery:
Which means you now fully control the AD object:
This effectively means that you can now add new users to the group.
Interesting to note that I could not abuse these privileges by using Active Directory module and Set-Acl
/ Get-Acl
cmdlets:
The DCSync permission implies having these permissions over the domain itself: DS-Replication-Get-Changes, Replicating Directory Changes All and Replicating Directory Changes In Filtered Set. Learn more about the DCSync attack here.****
Sometimes, certain users/groups may be delegated access to manage Group Policy Objects as is the case with offense\spotless
user:
We can see this by leveraging PowerView like so:
The below indicates that the user offense\spotless
has WriteProperty, WriteDacl, WriteOwner privileges among a couple of others that are ripe for abuse:
****More about general AD ACL/ACE abuse here.****
We know the above ObjectDN from the above screenshot is referring to the New Group Policy Object
GPO since the ObjectDN points to CN=Policies
and also the CN={DDC640FF-634A-4442-BC2E-C05EED132F0C}
which is the same in the GPO settings as highlighted below:
If we want to search for misconfigured GPOs specifically, we can chain multiple cmdlets from PowerSploit like so:
We can now resolve the computer names the GPO Misconfigured Policy
is applied to:
One of the ways to abuse this misconfiguration and get code execution is to create an immediate scheduled task through the GPO like so:
The above will add our user spotless to the local administrators
group of the compromised box. Note how prior to the code execution the group does not contain user spotless
:
ScheduledTask and its code will execute after the policy updates are pushed through (roughly each 90 minutes), but we can force it with gpupdate /force
and see that our user spotless
now belongs to local administrators group:
If we observe the Scheduled Tasks of the Misconfigured Policy
GPO, we can see our evilTask
sitting there:
Below is the XML file that got created by New-GPOImmediateTask
that represents our evil scheduled task in the GPO:
The same privilege escalation could be achieved by abusing the GPO Users and Groups feature. Note in the below file, line 6 where the user spotless
is added to the local administrators
group - we could change the user to something else, add another one or even add the user to another group/multiple groups since we can amend the policy configuration file in the shown location due to the GPO delegation assigned to our user spotless
:
Additionally, we could think about leveraging logon/logoff scripts, using registry for autoruns, installing .msi, edit services and similar code execution avenues.