Dsquery
Dsquery is a helpful command-line tool that can be utilized to find Active Directory objects.
dsquery
will exist on any host with the Active Directory Domain Services Role
installed, and the dsquery
DLL exists on all modern Windows systems by default now and can be found at C:\Windows\System32\dsquery.dll
.
All we need is elevated privileges on a host or the ability to run an instance of Command Prompt or PowerShell from a SYSTEM
context.
Basic commands
Last update: 2024-12-27 Created: December 27, 2024 22:00:41
userAccountControl:1.2.840.113556.1.4.803:
Specifies that we are looking at the User Account Control (UAC) attributes for an object.
userAccountControl:1.2.840.113556.1.4.803:
Specifies that we are looking at the User Account Control (UAC) attributes for an object.
=8192
represents the decimal bitmask we want to match in this search. OIDs are rules used to match bit values with attributes, as seen above. For LDAP and AD, there are three main matching rules:
1.2.840.113556.1.4.803
When using this rule as we did in the example above, we are saying the bit value must match completely to meet the search requirements. Great for matching a singular attribute.
1.2.840.113556.1.4.804
When using this rule, we are saying that we want our results to show any attribute match if any bit in the chain matches. This works in the case of an object having multiple attributes set.
1.2.840.113556.1.4.1941
This rule is used to match filters that apply to the Distinguished Name of an object and will search through all ownership and membership entries.