Detect DNS queries reporting multiple errors from different clients - Static threshold based ASIM DNS Solution
| Id | 5b8344eb-fa28-4ac3-bcff-bc19d5d63089 |
| Rulename | Detect DNS queries reporting multiple errors from different clients - Static threshold based (ASIM DNS Solution) |
| Description | This rule creates an alert when multiple clients report errors for the same DNS query. This helps in identifying possible similar C2 communications originating from different clients. It utilizes ASIM normalization and is applied to any source that supports the ASIM DNS schema. |
| Severity | Medium |
| Tactics | CommandAndControl |
| Techniques | T1568 T1573 T1008 |
| Kind | Scheduled |
| Query frequency | 1h |
| Query period | 1h |
| Trigger threshold | 0 |
| Trigger operator | gt |
| Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/DNS Essentials/Analytic Rules/MultipleErrorsReportedForSameDNSQueryStaticThresholdBased.yaml |
| Version | 1.0.4 |
| Arm template | 5b8344eb-fa28-4ac3-bcff-bc19d5d63089.json |
let lookback=1h;
let threshold = 2;
let errors = dynamic(['NXDOMAIN', 'SERVFAIL', 'REFUSED']);
_Im_Dns(starttime=ago(lookback))
| where EventResultDetails has_any (errors)
| summarize SrcIPs = make_set(SrcIpAddr, 100), Dvcs = make_set(Dvc, 100), ResourceIds = make_set(_ResourceId, 100) by DnsQuery, bin(TimeGenerated, 10min)
| where array_length(SrcIPs) >= threshold
| extend TotalIPs = array_length(SrcIPs),IPCountthreshold = threshold
| extend DomainName = strcat(split(DnsQuery, ".")[1], ".", split(DnsQuery, ".")[2])
| mv-expand SrcIPs
| extend SrcIP = tostring(SrcIPs)
| mv-expand Dvcs
| extend Dvc = tostring(Dvcs)
| mv-expand ResourceIds
| extend ResourceId = tostring(ResourceIds)
| extend Dvc = strcat(split(Dvc, ".")[0])
| summarize Start=min(TimeGenerated), End=max(TimeGenerated) by SrcIP, Dvc, ResourceId, DnsQuery, DomainName, SrcIPs = tostring(SrcIPs), IPCountthreshold = threshold, TotalIPs
| extend HostName = tostring(split(Dvc, ".")[0]), DomainIndex = toint(indexof(Dvc, '.'))
| extend HostNameDomain = iff(DomainIndex != -1, substring(Dvc, DomainIndex + 1), Dvc)
customDetails:
SrcIPs: SrcIPs
TotalIPs: TotalIPs
IPCountthreshold: IPCountthreshold
alertDetailsOverride:
alertDisplayNameFormat: "[Static threshold] Multiple errors for the same DNS query has been detected - '{{DnsQuery}}'"
alertDescriptionFormat: |-
Multiple errors were detected on different clients for the same DNS query. These unsuccessful responses can be an indication of C2 communication.
Threshold for total clients reporting errors: '{{IPCountthreshold}}'
Current count of clients reporting errors for this DNS query: '{{TotalIPs}}'
Clients requesting this DNSQuery include:
'{{SrcIPs}}'
queryFrequency: 1h
queryPeriod: 1h
status: Available
kind: Scheduled
tactics:
- CommandAndControl
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/DNS Essentials/Analytic Rules/MultipleErrorsReportedForSameDNSQueryStaticThresholdBased.yaml
eventGroupingSettings:
aggregationKind: SingleAlert
version: 1.0.4
triggerThreshold: 0
description: |
'This rule creates an alert when multiple clients report errors for the same DNS query. This helps in identifying possible similar C2 communications originating from different clients. It utilizes [ASIM](https://aka.ms/AboutASIM) normalization and is applied to any source that supports the ASIM DNS schema.'
severity: Medium
relevantTechniques:
- T1568
- T1573
- T1008
id: 5b8344eb-fa28-4ac3-bcff-bc19d5d63089
name: Detect DNS queries reporting multiple errors from different clients - Static threshold based (ASIM DNS Solution)
query: |
let lookback=1h;
let threshold = 2;
let errors = dynamic(['NXDOMAIN', 'SERVFAIL', 'REFUSED']);
_Im_Dns(starttime=ago(lookback))
| where EventResultDetails has_any (errors)
| summarize SrcIPs = make_set(SrcIpAddr, 100), Dvcs = make_set(Dvc, 100), ResourceIds = make_set(_ResourceId, 100) by DnsQuery, bin(TimeGenerated, 10min)
| where array_length(SrcIPs) >= threshold
| extend TotalIPs = array_length(SrcIPs),IPCountthreshold = threshold
| extend DomainName = strcat(split(DnsQuery, ".")[1], ".", split(DnsQuery, ".")[2])
| mv-expand SrcIPs
| extend SrcIP = tostring(SrcIPs)
| mv-expand Dvcs
| extend Dvc = tostring(Dvcs)
| mv-expand ResourceIds
| extend ResourceId = tostring(ResourceIds)
| extend Dvc = strcat(split(Dvc, ".")[0])
| summarize Start=min(TimeGenerated), End=max(TimeGenerated) by SrcIP, Dvc, ResourceId, DnsQuery, DomainName, SrcIPs = tostring(SrcIPs), IPCountthreshold = threshold, TotalIPs
| extend HostName = tostring(split(Dvc, ".")[0]), DomainIndex = toint(indexof(Dvc, '.'))
| extend HostNameDomain = iff(DomainIndex != -1, substring(Dvc, DomainIndex + 1), Dvc)
requiredDataConnectors: []
tags:
- SchemaVersion: 0.1.6
Schema: ASimDns
entityMappings:
- fieldMappings:
- identifier: DomainName
columnName: DnsQuery
entityType: DNS
- fieldMappings:
- identifier: Address
columnName: SrcIP
entityType: IP
- fieldMappings:
- identifier: ResourceId
columnName: ResourceId
entityType: AzureResource
- fieldMappings:
- identifier: Url
columnName: DnsQuery
entityType: Url
- fieldMappings:
- identifier: HostName
columnName: HostName
- identifier: NTDomain
columnName: HostNameDomain
entityType: Host
triggerOperator: gt