Detection rules › Kusto

TI Map URL Entity to EmailUrlInfo

Severity
medium
Time window
14d
Group by
DomainName, IndicatorId, NetworkMessageId, Url, UrlDomain
Source
github.com/Azure/Azure-Sentinel

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

MITRE ATT&CK coverage

TacticTechniques
Command & Control

Telemetry coverage

Rule body

id: a0038239-72f4-4f7b-90ff-37f89f7881e0
name: TI Map URL Entity to EmailUrlInfo
description: |
  'This query identifies any URL indicators of compromise (IOCs) from threat intelligence (TI) by searching for matches in EmailUrlInfo.'
severity: Medium
requiredDataConnectors:
  - connectorId: AzureActiveDirectory
    dataTypes:
      - EmailUrlInfo
  - 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 EmailUrlInfo_ = materialize(EmailUrlInfo
      | where isnotempty(Url)
      | where TimeGenerated >= ago(dt_lookBack)
      | extend Url = tolower(Url)
      | extend EmailUrlInfo_TimeGenerated = TimeGenerated);
  let EmailUrls = EmailUrlInfo_ | distinct Url | summarize make_list(Url);
  let EmailUrlDomains = EmailUrlInfo_ | distinct UrlDomain | summarize make_list(UrlDomain);
  let EmailEvents_ = materialize(EmailEvents
      | where TimeGenerated >= ago(dt_lookBack));
  let TI = materialize(ThreatIntelligenceIndicator
      | where TimeGenerated >= ago(ioc_lookBack)
      | where (isnotempty(Url) or isnotempty(DomainName)) 
      | where tolower(Url) in (EmailUrls) or tolower(DomainName) in (EmailUrlDomains)
      | summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
      | where Active == true and ExpirationDateTime > now());
  (union
      (TI | join kind=innerunique (EmailUrlInfo_) on Url),
      (TI | join kind=innerunique (EmailUrlInfo_) on $left.DomainName == $right.UrlDomain))
  | where EmailUrlInfo_TimeGenerated < ExpirationDateTime
  | summarize EmailUrlInfo_TimeGenerated = arg_max(EmailUrlInfo_TimeGenerated, *) by IndicatorId, Url
  | project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore, Url, UrlDomain, UrlLocation, NetworkMessageId
  | extend timestamp = EmailUrlInfo_TimeGenerated
  | join kind=inner (EmailEvents_) on NetworkMessageId
  | where DeliveryAction !has "Blocked"
  | extend Name = tostring(split(RecipientEmailAddress, '@', 0)[0]), UPNSuffix = tostring(split(RecipientEmailAddress, '@', 1)[0])
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: RecipientEmailAddress
      - identifier: Name
        columnName: Name
      - identifier: UPNSuffix
        columnName: UPNSuffix
  - entityType: URL
    fieldMappings:
      - identifier: Url
        columnName: Url
version: 1.0.2
kind: Scheduled

Stages and Predicates

Stage 0: let

let dt_lookBack = 1h;
let ioc_lookBack = 14d;
let EmailUrlInfo_ = materialize(EmailUrlInfo
    | where isnotempty(Url)
    | where TimeGenerated >= ago(dt_lookBack)
    | extend Url = tolower(Url)
    | extend EmailUrlInfo_TimeGenerated = TimeGenerated);
let EmailUrls = EmailUrlInfo_ | distinct Url | summarize make_list(Url);
let EmailUrlDomains = EmailUrlInfo_ | distinct UrlDomain | summarize make_list(UrlDomain);
let EmailEvents_ = materialize(EmailEvents
    | where TimeGenerated >= ago(dt_lookBack));
let TI = materialize(<inlined as stages below>);

Stage 1: source

let EmailUrlInfo_

Stage 2: source

let EmailUrls

Stage 3: source

let EmailUrlDomains

Stage 4: source

let EmailEvents_

Stage 5: union

union of 2 branches

Stage 6: source

ThreatIntelligenceIndicator

Stage 7: where

where TimeGenerated >= ago(1209600s)

Stage 8: where

where (isnotempty(DomainName) or isnotempty(Url))

Stage 9: where

where (DomainName =~ "EmailUrlDomains" or Url =~ "EmailUrls")

Stage 10: summarize

summarize LatestIndicatorTime by IndicatorId

Stage 11: where

where Active =~ true

Stage 12: join

join kind=innerunique (EmailUrlInfo_) on Url

Stage 13: source

ThreatIntelligenceIndicator

Stage 14: where

where TimeGenerated >= ago(1209600s)

Stage 15: where

where (isnotempty(DomainName) or isnotempty(Url))

Stage 16: where

where (DomainName =~ "EmailUrlDomains" or Url =~ "EmailUrls")

Stage 17: summarize

summarize LatestIndicatorTime by IndicatorId

Stage 18: where

where Active =~ true

Stage 19: join

join kind=innerunique (EmailUrlInfo_) on DomainName, UrlDomain

Stage 20: where

where EmailUrlInfo_TimeGenerated < ExpirationDateTime

Stage 21: summarize

summarize EmailUrlInfo_TimeGenerated by IndicatorId, Url

Stage 22: project

project ActivityGroupNames, ConfidenceScore, Description, EmailUrlInfo_TimeGenerated, ExpirationDateTime, IndicatorId, NetworkMessageId, ThreatType, Url, UrlDomain, UrlLocation

Stage 23: extend

extend timestamp

Stage 24: join

join kind=inner (EmailEvents_) on NetworkMessageId

Stage 25: where

where not (DeliveryAction contains "Blocked")

Stage 26: extend

extend Name, UPNSuffix

Indicators

These rows show field, operator, and value matches.

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
DeliveryActionmatchBlockedexcludes:DeliveryAction field:"DeliveryAction" value:"Blocked"

Output fields

These fields are emitted when the rule matches.

FieldSource
ActivityGroupNamesproject
ConfidenceScoreproject
Descriptionproject
EmailUrlInfo_TimeGeneratedproject
ExpirationDateTimeproject
IndicatorIdproject
NetworkMessageIdproject
ThreatTypeproject
Urlproject
UrlDomainproject
UrlLocationproject
timestampextend
Nameextend
UPNSuffixextend