Discovery · Windows
dsquery.exe
Directory Service Query
Queries Active Directory for users, computers, groups and other objects. It is part of RSAT, so it is unusual on ordinary workstations.
Legitimate use
Directory admins use it to search AD from the command line.
Subcommands
Searches for user accounts.
LowSearches for computer accounts.
LowSearches for groups.
LowSearches for domain controllers.
LowSearches for AD sites.
LowSearches for AD subnets, which shows the network layout.
LowRuns a raw LDAP filter against the directory.
MediumSwitches
LDAP filter for a * query.
MediumAttributes to return.
LowMaximum number of results. 0 means no limit.
LowCommand lines to worry about
- Medium
Unbounded directory query
Pulls every matching object from AD. Bulk exports like this are typical of domain mapping.
Detection regex
dsquery(\.exe)?\s+\*.*-limit\s+0
Where it is recorded
- Security4688Process creation with the full command line, when command-line auditing is enabled.
- Sysmon1Process creation with command line, hashes and parent process.
Community detections
2 SigmaHQ rules for dsquery.exe. The explainer checks every pasted command line against all of them.
- HighWebshell Detection With Command Line Keywords
Detects certain command line parameters often used during reconnaissance activity via web shells
T1505.003T1018T1033T1087by Florian Roth (Nextron Systems), Jonhnathan Ribeiro, Anton Kutepov, oscd.community, Chad Hudson, Matt Anderson
- MediumDomain Trust Discovery Via Dsquery
Detects execution of "dsquery.exe" for domain trust discovery
T1482by E.M. Anhaus, Tony Lambert, oscd.community, omkar72
Rules from SigmaHQ (rules/windows/process_creation), Detection Rule License (DRL) 1.1. Each rule links to its source and credits its authors.