Detection rules › Kusto

TI Map Domain Entity to DeviceNetworkEvents

Severity
medium
Time window
14d
Group by
Domain, IndicatorId, TI_Domain
Source
github.com/Azure/Azure-Sentinel

This query identifies any Domain indicators of compromise (IOCs) from threat intelligence (TI) by searching for matches in DeviceNetworkEvents.

MITRE ATT&CK coverage

TacticTechniques
Command & Control

Telemetry coverage

Rule body

id: c308b2f3-eebe-4a20-905c-cb8293b062db
name: TI Map Domain Entity to DeviceNetworkEvents
description: |
  'This query identifies any Domain indicators of compromise (IOCs) from threat intelligence (TI) by searching for matches in DeviceNetworkEvents.'
severity: Medium
requiredDataConnectors:
  - connectorId: MicrosoftThreatProtection
    dataTypes:
      - DeviceNetworkEvents
  - connectorId: ThreatIntelligence
    dataTypes:
      - ThreatIntelligenceIndicator
  - connectorId: ThreatIntelligenceTaxii
    dataTypes:
      - ThreatIntelligenceIndicator
  - connectorId: MicrosoftDefenderThreatIntelligence
    dataTypes:
      - ThreatIntelligenceIndicator
queryFrequency: 1h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
  - CommandAndControl
relevantTechniques:
  - T1071
query: |
  let dt_lookBack = 1h;
  let ioc_lookBack = 14d;
  let DeviceNetworkEvents_ = DeviceNetworkEvents
    | where isnotempty(RemoteUrl)
    | where TimeGenerated >= ago(dt_lookBack)
    | where ActionType !has "ConnectionFailed"
    | extend Domain = tostring(parse_url(tolower(RemoteUrl)).Host)
    | where isnotempty(Domain)
    | project-rename DeviceNetworkEvents_TimeGenerated = TimeGenerated;
  let DeviceNetworkEventDomains = DeviceNetworkEvents_
    | distinct Domain
    | summarize make_list(Domain);
  ThreatIntelligenceIndicator
  | where isnotempty(DomainName)
  | where TimeGenerated >= ago(ioc_lookBack)
  | extend TI_Domain = tolower(DomainName)
  | where TI_Domain in (DeviceNetworkEventDomains)
  | summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
  | where Active == true and ExpirationDateTime > now()
  | where Description !contains_cs "State: inactive;" and Description !contains_cs "State: falsepos;"
  | join kind=innerunique (DeviceNetworkEvents_) on $left.TI_Domain == $right.Domain
  | where DeviceNetworkEvents_TimeGenerated < ExpirationDateTime
  | summarize DeviceNetworkEvents_TimeGenerated = arg_max(DeviceNetworkEvents_TimeGenerated, *) by IndicatorId, TI_Domain
  | project DeviceNetworkEvents_TimeGenerated, IndicatorId, TI_Domain, Url = RemoteUrl, ConfidenceScore, Description, ThreatType, Tags, TrafficLightProtocolLevel, ActionType, DeviceId, DeviceName, InitiatingProcessAccountUpn, InitiatingProcessCommandLine, RemoteIP, RemotePort
  | extend Name = tostring(split(InitiatingProcessAccountUpn, '@', 0)[0]), UPNSuffix = tostring(split(InitiatingProcessAccountUpn, '@', 1)[0])
  | extend timestamp = DeviceNetworkEvents_TimeGenerated, UserPrincipalName = InitiatingProcessAccountUpn
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: Name
        columnName: Name
      - identifier: UPNSuffix
        columnName: UPNSuffix
  - entityType: Host
    fieldMappings:
      - identifier: FullName
        columnName: DeviceName
  - entityType: URL
    fieldMappings:
      - identifier: Url
        columnName: Url
  - entityType: Process
    fieldMappings:
      - identifier: CommandLine
        columnName: InitiatingProcessCommandLine
version: 1.0.1
kind: Scheduled

Stages and Predicates

Parameters

let dt_lookBack = 1h;
let ioc_lookBack = 14d;

Let binding: DeviceNetworkEvents_ used in Stages 1, 11

let DeviceNetworkEvents_ = DeviceNetworkEvents
  | where isnotempty(RemoteUrl)
  | where TimeGenerated >= ago(dt_lookBack)
  | where ActionType !has "ConnectionFailed"
  | extend Domain = tostring(parse_url(tolower(RemoteUrl)).Host)
  | where isnotempty(Domain)
  | project-rename DeviceNetworkEvents_TimeGenerated = TimeGenerated;

Let binding: DeviceNetworkEventDomains used in Stages 2, 7

let DeviceNetworkEventDomains = DeviceNetworkEvents_
  | distinct Domain
  | summarize make_list(Domain);

Stage 1: source

let DeviceNetworkEvents_

Stage 2: source

let DeviceNetworkEventDomains

Stage 3: source

ThreatIntelligenceIndicator

Stage 4: where

where isnotempty(DomainName)

Stage 5: where

where TimeGenerated >= ago(1209600s)

Stage 6: extend

extend TI_Domain

Stage 7: where

where TI_Domain =~ "DeviceNetworkEventDomains"

Stage 8: summarize

summarize LatestIndicatorTime by IndicatorId

Stage 9: where

where Active =~ true

Stage 10: where

where not (Description contains "State: falsepos;") and not (Description contains "State: inactive;")

Stage 11: join

join kind=innerunique (DeviceNetworkEvents_) on TI_Domain, Domain

Stage 12: where

where DeviceNetworkEvents_TimeGenerated < ExpirationDateTime

Stage 13: summarize

summarize DeviceNetworkEvents_TimeGenerated by IndicatorId, TI_Domain

Stage 14: project

project ActionType, ConfidenceScore, Description, DeviceId, DeviceName, DeviceNetworkEvents_TimeGenerated, IndicatorId, InitiatingProcessAccountUpn, InitiatingProcessCommandLine, RemoteIP, RemotePort, TI_Domain, Tags, ThreatType, TrafficLightProtocolLevel, Url

Stage 15: extend

extend Name, UPNSuffix

Stage 16: extend

extend UserPrincipalName, timestamp

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
DescriptioncontainsState: falsepos;excludes:Description field:"Description" value:"State: falsepos;"
DescriptioncontainsState: inactive;excludes:Description field:"Description" value:"State: inactive;"
ActionTypematchConnectionFailedexcludes:ActionType field:"ActionType" value:"ConnectionFailed"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Activeeq
  • true corpus 70 (kusto 70)
field:"Active" kind:eq value:"true"
DeviceNetworkEvents_TimeGeneratedcross_field_compare
  • ExpirationDateTime transforms: op:lt corpus 2 (kusto 2)
field:"DeviceNetworkEvents_TimeGenerated" kind:cross_field_compare value:"ExpirationDateTime"
Domainis_not_null
  • (no value, null check)
field:"Domain" kind:is_not_null
DomainNameis_not_null
  • (no value, null check)
field:"DomainName" kind:is_not_null
RemoteUrlis_not_null
  • (no value, null check)
field:"DestinationHostname" kind:is_not_null
TI_Domainin
  • DeviceNetworkEventDomains
field:"TI_Domain" kind:in value:"DeviceNetworkEventDomains"

Output fields

These fields are emitted when the rule matches.

FieldSource
ActionTypeproject
ConfidenceScoreproject
Descriptionproject
DeviceIdproject
DeviceNameproject
DeviceNetworkEvents_TimeGeneratedproject
IndicatorIdproject
InitiatingProcessAccountUpnproject
InitiatingProcessCommandLineproject
RemoteIPproject
RemotePortproject
TI_Domainproject
Tagsproject
ThreatTypeproject
TrafficLightProtocolLevelproject
Urlproject
Nameextend
UPNSuffixextend
UserPrincipalNameextend
timestampextend