Enumerating Domain Trusts via DSQUERY.EXE
Identifies the use of dsquery.exe for domain trust discovery purposes. Adversaries may use this command-line utility to enumerate trust relationships that may be used for Lateral Movement opportunities in Windows multi-domain forest environments.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/27"
3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
4maturity = "production"
5updated_date = "2024/11/02"
6min_stack_version = "8.14.0"
7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
8
9[rule]
10author = ["Elastic"]
11description = """
12Identifies the use of dsquery.exe for domain trust discovery purposes. Adversaries may use this command-line utility to
13enumerate trust relationships that may be used for Lateral Movement opportunities in Windows multi-domain forest
14environments.
15"""
16false_positives = [
17 "Domain administrators may use this command-line utility for legitimate information gathering purposes.",
18]
19from = "now-9m"
20index = [
21 "winlogbeat-*",
22 "logs-endpoint.events.process-*",
23 "logs-windows.forwarded*",
24 "logs-windows.sysmon_operational-*",
25 "endgame-*",
26 "logs-system.security*",
27 "logs-m365_defender.event-*",
28 "logs-sentinel_one_cloud_funnel.*",
29 "logs-crowdstrike.fdr*",
30]
31language = "eql"
32license = "Elastic License v2"
33name = "Enumerating Domain Trusts via DSQUERY.EXE"
34note = """## Triage and analysis
35
36### Investigating Enumerating Domain Trusts via DSQUERY.EXE
37
38Active Directory (AD) domain trusts define relationships between domains within a Windows AD environment. In this setup, a "trusting" domain permits users from a "trusted" domain to access resources. These trust relationships can be configurable as one-way, two-way, transitive, or non-transitive, enabling controlled access and resource sharing across domains.
39
40This rule identifies the usage of the `dsquery.exe` utility to enumerate domain trusts. Attackers can use this information to enable the next actions in a target environment, such as lateral movement.
41
42#### Possible investigation steps
43
44- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
45- Identify the user account that performed the action and whether it should perform this kind of action.
46- Investigate other alerts associated with the user/host during the past 48 hours.
47
48### False positive analysis
49
50- Discovery activities are not inherently malicious if they occur in isolation and are done within the user business context (e.g., an administrator in this context). As long as the analyst did not identify suspicious activity related to the user or host, such alerts can be dismissed.
51
52### Related rules
53
54- Enumerating Domain Trusts via NLTEST.EXE - 84da2554-e12a-11ec-b896-f661ea17fbcd
55
56### Response and remediation
57
58- Initiate the incident response process based on the outcome of the triage.
59- Isolate the involved hosts to prevent further post-compromise behavior.
60- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
61- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
62- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
63- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
64"""
65references = [
66 "https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc732952(v=ws.11)",
67 "https://posts.specterops.io/a-guide-to-attacking-domain-trusts-971e52cb2944",
68]
69risk_score = 21
70rule_id = "06a7a03c-c735-47a6-a313-51c354aef6c3"
71severity = "low"
72tags = [
73 "Domain: Endpoint",
74 "OS: Windows",
75 "Use Case: Threat Detection",
76 "Tactic: Discovery",
77 "Data Source: Elastic Endgame",
78 "Resources: Investigation Guide",
79 "Data Source: Elastic Defend",
80 "Data Source: System",
81 "Data Source: Microsoft Defender for Endpoint",
82 "Data Source: Sysmon",
83 "Data Source: SentinelOne",
84 "Data Source: Crowdstrike",
85]
86timestamp_override = "event.ingested"
87type = "eql"
88
89query = '''
90process where host.os.type == "windows" and event.type == "start" and
91 (process.name : "dsquery.exe" or ?process.pe.original_file_name: "dsquery.exe") and
92 process.args : "*objectClass=trustedDomain*"
93'''
94
95
96[[rule.threat]]
97framework = "MITRE ATT&CK"
98[[rule.threat.technique]]
99id = "T1018"
100name = "Remote System Discovery"
101reference = "https://attack.mitre.org/techniques/T1018/"
102
103[[rule.threat.technique]]
104id = "T1482"
105name = "Domain Trust Discovery"
106reference = "https://attack.mitre.org/techniques/T1482/"
107
108
109[rule.threat.tactic]
110id = "TA0007"
111name = "Discovery"
112reference = "https://attack.mitre.org/tactics/TA0007/"
Triage and analysis
Investigating Enumerating Domain Trusts via DSQUERY.EXE
Active Directory (AD) domain trusts define relationships between domains within a Windows AD environment. In this setup, a "trusting" domain permits users from a "trusted" domain to access resources. These trust relationships can be configurable as one-way, two-way, transitive, or non-transitive, enabling controlled access and resource sharing across domains.
This rule identifies the usage of the dsquery.exe
utility to enumerate domain trusts. Attackers can use this information to enable the next actions in a target environment, such as lateral movement.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Identify the user account that performed the action and whether it should perform this kind of action.
- Investigate other alerts associated with the user/host during the past 48 hours.
False positive analysis
- Discovery activities are not inherently malicious if they occur in isolation and are done within the user business context (e.g., an administrator in this context). As long as the analyst did not identify suspicious activity related to the user or host, such alerts can be dismissed.
Related rules
- Enumerating Domain Trusts via NLTEST.EXE - 84da2554-e12a-11ec-b896-f661ea17fbcd
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved hosts to prevent further post-compromise behavior.
- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Peripheral Device Discovery
- Deleting Backup Catalogs with Wbadmin
- Execution via MSSQL xp_cmdshell Stored Procedure
- Group Policy Discovery via Microsoft GPResult Utility
- Modification of Boot Configuration