Detection rules › Kusto

TI Map Domain entity to EmailUrlInfo

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

Identifies a match in EmailUrlInfo table from any Domain IOC from TI.

MITRE ATT&CK coverage

TacticTechniques
Initial Access

Telemetry coverage

Rule body

id: b56e2290-c65b-45a5-9636-3651e85bbe5d
name: TI Map Domain entity to EmailUrlInfo
description: |
  'Identifies a match in EmailUrlInfo table from any Domain IOC from TI.'
severity: Medium
requiredDataConnectors:
  - connectorId: MicrosoftThreatProtection
    dataTypes:
      - EmailUrlInfo
  - connectorId: ThreatIntelligence
    dataTypes:
      - ThreatIntelIndicators
  - connectorId: ThreatIntelligenceTaxii
    dataTypes:
      - ThreatIntelIndicators
  - connectorId: MicrosoftDefenderThreatIntelligence
    dataTypes:
      - ThreatIntelIndicators
queryFrequency: 1h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
  - InitialAccess
relevantTechniques:
  - T1566
query: |
    let dt_lookBack = 1h; // Define the lookback period for email data as 1 hour
    let ioc_lookBack = 14d; // Define the lookback period for threat intelligence data as 14 days
    let EmailUrlInfo_ = EmailUrlInfo| where isnotempty(Url) or isnotempty(UrlDomain) // Filter for non-empty URLs or URL domains
    | where TimeGenerated >= ago(dt_lookBack) // Filter for records within the lookback period
    | extend Url = tolower(Url), UrlDomain = tolower(UrlDomain) // Convert URLs and domains to lowercase
    | extend EmailUrlInfo_TimeGenerated = TimeGenerated; // Create a new column for the time generated
    let EmailEvents_ = EmailEvents
    | where TimeGenerated >= ago(dt_lookBack); // Filter email events within the lookback period
    let TI_Urls = ThreatIntelIndicators
    | where TimeGenerated >= ago(ioc_lookBack) // Filter threat intelligence indicators within the lookback period
    | summarize arg_max(TimeGenerated, *) by Id, ObservableValue // Get latest record per Id FIRST
    | where IsActive == true and ValidUntil > now() // THEN filter for active indicators that haven't expired
    | extend IndicatorType = replace(@"\[|\]|\""", "", tostring(split(ObservableKey, ":", 0)))
    | where isnotempty(IndicatorType) and IndicatorType == "url"
    | extend Url = tolower(ObservableValue)
    | where isnotempty(Url) // Filter for non-empty URLs
    | join kind=innerunique (EmailUrlInfo_) on Url // Join with email URL info on URL
    | extend Description = tostring(parse_json(Data).description)
    | extend ActivityGroupNames = extract("ActivityGroup:([^,]+)", 1, tostring(parse_json(Data).labels))
    | project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, Id, ValidUntil, Confidence, Url, UrlLocation, NetworkMessageId; // Select relevant columns
    let TI_Domains = ThreatIntelIndicators
    | where TimeGenerated >= ago(ioc_lookBack) // Filter threat intelligence indicators within the lookback period
    | where isnotempty(ObservableValue) // Filter for non-empty domain names
    | extend DomainName = tolower(ObservableValue) // Convert domain names to lowercase
    | where ObservableKey == "domain-name:value"
    | summarize arg_max(TimeGenerated, *) by Id, ObservableValue // Get latest record per Id FIRST
    | where IsActive == true // THEN filter for active indicators
    | extend TrafficLightProtocolLevel = AdditionalFields.TLPLevel
    | extend IndicatorId = tostring(split(Id, "--")[2]);
    let TI_Domains_UrlInfo = TI_Domains
    | project-reorder *, IsActive, Tags, TrafficLightProtocolLevel, DomainName, Type
    | join kind=innerunique (EmailUrlInfo_) on $left.DomainName == $right.UrlDomain // Join with email URL info on domain name
    | extend ExpirationDateTime = ValidUntil
    | extend Description = Data.description
    | extend ThreatType =  Data.type
    | extend ConfidenceScore = Confidence
    | extend ActivityGroupNames = replace_string(tostring(parse_json(tostring(Data.labels))[0]),"ActivityGroup:","")
    | where ExpirationDateTime > now() // Filter for indicators that haven't expired
    | project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore, UrlDomain, UrlLocation, NetworkMessageId; // Select relevant columns
    union TI_Urls, TI_Domains_UrlInfo // Combine URL and domain threat intelligence data
    | extend timestamp = EmailUrlInfo_TimeGenerated // Add a timestamp column
    | join kind=inner (EmailEvents_) on NetworkMessageId // Join with email events on network message ID
    | where DeliveryAction !has "Blocked" // Filter out blocked delivery actions
    | extend Name = tostring(split(RecipientEmailAddress, '@', 0)[0]), UPNSuffix = tostring(split(RecipientEmailAddress, '@', 1)[0]); // Extract name and UPN suffix from recipient email address"
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.7
kind: Scheduled

Stages and Predicates

Stage 0: let

let dt_lookBack = 1h;
let ioc_lookBack = 14d;
let EmailUrlInfo_ = EmailUrlInfo| where isnotempty(Url) or isnotempty(UrlDomain)
| where TimeGenerated >= ago(dt_lookBack)
| extend Url = tolower(Url), UrlDomain = tolower(UrlDomain)
| extend EmailUrlInfo_TimeGenerated = TimeGenerated;
let EmailEvents_ = EmailEvents
| where TimeGenerated >= ago(dt_lookBack);
let TI_Urls = ThreatIntelIndicators <inlined as stages below>;
let TI_Domains = ThreatIntelIndicators <inlined as stages below>;
let TI_Domains_UrlInfo = TI_Domains <inlined as stages below>;

Stage 1: source

let EmailUrlInfo_

Stage 2: source

let EmailEvents_

Stage 3: source

let TI_Urls

Stage 4: source

let TI_Domains_UrlInfo

Stage 5: union

union of 2 branches

Stage 6: source

ThreatIntelIndicators

Stage 7: where

where TimeGenerated >= ago(1209600s)

Stage 8: summarize

summarize by Id, ObservableValue

Stage 9: where

where IsActive =~ true

Stage 10: extend

extend IndicatorType

Stage 11: where

where IndicatorType =~ "url" and isnotempty(IndicatorType)

Stage 12: extend

extend Url

Stage 13: where

where isnotempty(Url)

Stage 14: join

join kind=innerunique (EmailUrlInfo_) on Url

Stage 15: extend

extend Description

Stage 16: extend

extend ActivityGroupNames

Stage 17: project

project ActivityGroupNames, Confidence, Description, EmailUrlInfo_TimeGenerated, Id, NetworkMessageId, Url, UrlLocation, ValidUntil

Stage 18: source

ThreatIntelIndicators

Stage 19: where

where TimeGenerated >= ago(1209600s)

Stage 20: where

where isnotempty(ObservableValue)

Stage 21: extend

extend DomainName

Stage 22: where

where ObservableKey =~ "domain-name:value"

Stage 23: summarize

summarize by Id, ObservableValue

Stage 24: where

where IsActive =~ true

Stage 25: extend

extend TrafficLightProtocolLevel

Stage 26: extend

extend IndicatorId

Stage 27: project-reorder

project-reorder

Stage 28: join

join kind=innerunique (EmailUrlInfo_) on DomainName, UrlDomain

Stage 29: extend (5 consecutive steps)

extend ActivityGroupNames, ConfidenceScore, Description, ExpirationDateTime, ThreatType

Stage 30: where

where ExpirationDateTime > now()

Stage 31: project

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

Stage 32: extend

extend timestamp

Stage 33: join

join kind=inner (EmailEvents_) on NetworkMessageId

Stage 34: where

where not (DeliveryAction contains "Blocked")

Stage 35: 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
UrlDomainproject
UrlLocationproject
timestampextend
Nameextend
UPNSuffixextend