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 = "2025/03/20"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies the use of dsquery.exe for domain trust discovery purposes. Adversaries may use this command-line utility to
 11enumerate trust relationships that may be used for Lateral Movement opportunities in Windows multi-domain forest
 12environments.
 13"""
 14false_positives = [
 15    "Domain administrators may use this command-line utility for legitimate information gathering purposes.",
 16]
 17from = "now-9m"
 18index = [
 19    "endgame-*",
 20    "logs-crowdstrike.fdr*",
 21    "logs-endpoint.events.process-*",
 22    "logs-m365_defender.event-*",
 23    "logs-sentinel_one_cloud_funnel.*",
 24    "logs-system.security*",
 25    "logs-windows.forwarded*",
 26    "logs-windows.sysmon_operational-*",
 27    "winlogbeat-*",
 28]
 29language = "eql"
 30license = "Elastic License v2"
 31name = "Enumerating Domain Trusts via DSQUERY.EXE"
 32note = """## Triage and analysis
 33
 34### Investigating Enumerating Domain Trusts via DSQUERY.EXE
 35
 36Active 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.
 37
 38This 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.
 39
 40#### Possible investigation steps
 41
 42- 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.
 43- Identify the user account that performed the action and whether it should perform this kind of action.
 44- Investigate other alerts associated with the user/host during the past 48 hours.
 45
 46### False positive analysis
 47
 48- 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.
 49
 50### Related rules
 51
 52- Enumerating Domain Trusts via NLTEST.EXE - 84da2554-e12a-11ec-b896-f661ea17fbcd
 53
 54### Response and remediation
 55
 56- Initiate the incident response process based on the outcome of the triage.
 57- Isolate the involved hosts to prevent further post-compromise behavior.
 58- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
 59- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 60- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 61- 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).
 62"""
 63references = [
 64    "https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc732952(v=ws.11)",
 65    "https://posts.specterops.io/a-guide-to-attacking-domain-trusts-971e52cb2944",
 66]
 67risk_score = 21
 68rule_id = "06a7a03c-c735-47a6-a313-51c354aef6c3"
 69severity = "low"
 70tags = [
 71    "Domain: Endpoint",
 72    "OS: Windows",
 73    "Use Case: Threat Detection",
 74    "Tactic: Discovery",
 75    "Data Source: Elastic Endgame",
 76    "Resources: Investigation Guide",
 77    "Data Source: Elastic Defend",
 78    "Data Source: Windows Security Event Logs",
 79    "Data Source: Microsoft Defender for Endpoint",
 80    "Data Source: Sysmon",
 81    "Data Source: SentinelOne",
 82    "Data Source: Crowdstrike",
 83]
 84timestamp_override = "event.ingested"
 85type = "eql"
 86
 87query = '''
 88process where host.os.type == "windows" and event.type == "start" and
 89    (process.name : "dsquery.exe" or ?process.pe.original_file_name: "dsquery.exe") and 
 90    process.args : "*objectClass=trustedDomain*"
 91'''
 92
 93
 94[[rule.threat]]
 95framework = "MITRE ATT&CK"
 96[[rule.threat.technique]]
 97id = "T1018"
 98name = "Remote System Discovery"
 99reference = "https://attack.mitre.org/techniques/T1018/"
100
101[[rule.threat.technique]]
102id = "T1482"
103name = "Domain Trust Discovery"
104reference = "https://attack.mitre.org/techniques/T1482/"
105
106
107[rule.threat.tactic]
108id = "TA0007"
109name = "Discovery"
110reference = "https://attack.mitre.org/tactics/TA0007/"
...
toml

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.

  • 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.
  • 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.
  • Enumerating Domain Trusts via NLTEST.EXE - 84da2554-e12a-11ec-b896-f661ea17fbcd
  • 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

to-top