Potential DNS Tunneling via NsLookup

This rule identifies a large number (15) of nslookup.exe executions with an explicit query type from the same host. This may indicate command and control activity utilizing the DNS protocol.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/11"
  3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2024/10/15"
  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 = """
 12This rule identifies a large number (15) of nslookup.exe executions with an explicit query type from the same host. This
 13may indicate command and control activity utilizing the DNS protocol.
 14"""
 15from = "now-9m"
 16index = [
 17    "winlogbeat-*",
 18    "logs-endpoint.events.process-*",
 19    "logs-windows.forwarded*",
 20    "logs-windows.sysmon_operational-*",
 21    "endgame-*",
 22    "logs-system.security*",
 23    "logs-m365_defender.event-*",
 24    "logs-sentinel_one_cloud_funnel.*",
 25]
 26language = "eql"
 27license = "Elastic License v2"
 28name = "Potential DNS Tunneling via NsLookup"
 29note = """## Triage and analysis
 30
 31### Investigating Potential DNS Tunneling via NsLookup
 32
 33Attackers can abuse existing network rules that allow DNS communication with external resources to use the protocol as their command and control and/or exfiltration channel.
 34
 35DNS queries can be used to infiltrate data such as commands to be run, malicious files, etc., and also for exfiltration, since queries can be used to send data to the attacker-controlled DNS server. This process is commonly known as DNS tunneling.
 36
 37More information on how tunneling works and how it can be abused can be found on [Palo Alto Unit42 Research](https://unit42.paloaltonetworks.com/dns-tunneling-how-dns-can-be-abused-by-malicious-actors).
 38
 39#### Possible investigation steps
 40
 41- Investigate the script 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.
 42- Investigate other alerts associated with the user/host during the past 48 hours.
 43- Inspect the DNS query and identify the information sent.
 44- Extract this communication's indicators of compromise (IoCs) and use traffic logs to search for other potentially compromised hosts.
 45
 46### False positive analysis
 47
 48- This mechanism can be used legitimately. If the parent process is trusted and the data sent is not sensitive nor command and control related, this alert can be closed.
 49
 50### Response and remediation
 51
 52- Initiate the incident response process based on the outcome of the triage.
 53- Isolate the involved host to prevent further post-compromise behavior.
 54- Immediately block the identified indicators of compromise (IoCs).
 55- Implement any temporary network rules, procedures, and segmentation required to contain the attack.
 56- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
 57- Update firewall rules to be more restrictive.
 58- Reimage the host operating system or restore the compromised files to clean versions.
 59- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 60- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 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 = ["https://unit42.paloaltonetworks.com/dns-tunneling-in-the-wild-overview-of-oilrigs-dns-tunneling/"]
 64risk_score = 47
 65rule_id = "3a59fc81-99d3-47ea-8cd6-d48d561fca20"
 66severity = "medium"
 67tags = [
 68    "Domain: Endpoint",
 69    "OS: Windows",
 70    "Use Case: Threat Detection",
 71    "Tactic: Command and Control",
 72    "Resources: Investigation Guide",
 73    "Data Source: Elastic Endgame",
 74    "Data Source: Elastic Defend",
 75    "Data Source: System",
 76    "Data Source: Microsoft Defender for Endpoint",
 77    "Data Source: SentinelOne",
 78    "Data Source: Sysmon",
 79]
 80type = "eql"
 81
 82query = '''
 83sequence by host.id with maxspan=5m
 84[process where host.os.type == "windows" and event.type == "start" and
 85  process.name : "nslookup.exe" and process.args:("-querytype=*", "-qt=*", "-q=*", "-type=*")] with runs = 10
 86'''
 87
 88
 89[[rule.threat]]
 90framework = "MITRE ATT&CK"
 91[[rule.threat.technique]]
 92id = "T1071"
 93name = "Application Layer Protocol"
 94reference = "https://attack.mitre.org/techniques/T1071/"
 95[[rule.threat.technique.subtechnique]]
 96id = "T1071.004"
 97name = "DNS"
 98reference = "https://attack.mitre.org/techniques/T1071/004/"
 99
100
101[[rule.threat.technique]]
102id = "T1572"
103name = "Protocol Tunneling"
104reference = "https://attack.mitre.org/techniques/T1572/"
105
106
107[rule.threat.tactic]
108id = "TA0011"
109name = "Command and Control"
110reference = "https://attack.mitre.org/tactics/TA0011/"

Triage and analysis

Investigating Potential DNS Tunneling via NsLookup

Attackers can abuse existing network rules that allow DNS communication with external resources to use the protocol as their command and control and/or exfiltration channel.

DNS queries can be used to infiltrate data such as commands to be run, malicious files, etc., and also for exfiltration, since queries can be used to send data to the attacker-controlled DNS server. This process is commonly known as DNS tunneling.

More information on how tunneling works and how it can be abused can be found on Palo Alto Unit42 Research.

Possible investigation steps

  • Investigate the script 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.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Inspect the DNS query and identify the information sent.
  • Extract this communication's indicators of compromise (IoCs) and use traffic logs to search for other potentially compromised hosts.

False positive analysis

  • This mechanism can be used legitimately. If the parent process is trusted and the data sent is not sensitive nor command and control related, this alert can be closed.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • Immediately block the identified indicators of compromise (IoCs).
  • Implement any temporary network rules, procedures, and segmentation required to contain the attack.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • Update firewall rules to be more restrictive.
  • Reimage the host operating system or restore the compromised files to clean versions.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • 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