Detection rules › Kusto
TI map Domain entity to EmailUrlInfo
Identifies a match in EmailUrlInfo table from any Domain IOC from TI.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Initial Access |
Telemetry coverage
Rule body
id: 87cc75df-d7b2-44f1-b064-ee924edfc879
name: TI map Domain entity to EmailUrlInfo
description: |
'Identifies a match in EmailUrlInfo table from any Domain IOC from TI.'
severity: Medium
requiredDataConnectors:
- connectorId: Office365
dataTypes:
- EmailUrlInfo
- connectorId: ThreatIntelligence
dataTypes:
- ThreatIntelligenceIndicator
- connectorId: ThreatIntelligenceTaxii
dataTypes:
- ThreatIntelligenceIndicator
- connectorId: MicrosoftDefenderThreatIntelligence
dataTypes:
- ThreatIntelligenceIndicator
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 = ThreatIntelligenceIndicator
| where TimeGenerated >= ago(ioc_lookBack) // Filter threat intelligence indicators within the lookback period
| where isnotempty(Url) // Filter for non-empty URLs
| extend Url = tolower(Url) // Convert URLs to lowercase
| join kind=innerunique (EmailUrlInfo_) on Url // Join with email URL info on URL
| where Active == true and ExpirationDateTime > now() // Filter for active indicators that haven't expired
| where EmailUrlInfo_TimeGenerated < ExpirationDateTime // Ensure email info was generated before the indicator expired
| summarize EmailUrlInfo_TimeGenerated = arg_max(EmailUrlInfo_TimeGenerated, *) by IndicatorId, Url // Get the latest email info for each indicator
| project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore, Url, UrlLocation, NetworkMessageId; // Select relevant columns
let TI_Domains = ThreatIntelligenceIndicator
| where TimeGenerated >= ago(ioc_lookBack) // Filter threat intelligence indicators within the lookback period
| where isnotempty(DomainName) // Filter for non-empty domain names
| extend DomainName = tolower(DomainName) // Convert domain names to lowercase
| join kind=innerunique (EmailUrlInfo_) on $left.DomainName == $right.UrlDomain // Join with email URL info on domain name
| where Active == true and ExpirationDateTime > now() // Filter for active indicators that haven't expired
| where EmailUrlInfo_TimeGenerated < ExpirationDateTime // Ensure email info was generated before the indicator expired
| summarize EmailUrlInfo_TimeGenerated = arg_max(EmailUrlInfo_TimeGenerated, *) by IndicatorId, UrlDomain // Get the latest email info for each indicator
| project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore, UrlDomain, UrlLocation, NetworkMessageId; // Select relevant columns
union TI_Urls, TI_Domains // 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.3
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 = ThreatIntelligenceIndicator <inlined as stages below>;
let TI_Domains = ThreatIntelligenceIndicator <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
Stage 5: union
union of 2 branches
Stage 6: source
ThreatIntelligenceIndicator
Stage 7: where
where TimeGenerated >= ago(1209600s)
Stage 8: where
where isnotempty(Url)
Stage 9: extend
extend Url
Stage 10: join
join kind=innerunique (EmailUrlInfo_) on Url
Stage 11: where
where Active =~ true
Stage 12: where
where EmailUrlInfo_TimeGenerated < ExpirationDateTime
Stage 13: summarize
summarize EmailUrlInfo_TimeGenerated by IndicatorId, Url
Stage 14: project
project ActivityGroupNames, ConfidenceScore, Description, EmailUrlInfo_TimeGenerated, ExpirationDateTime, IndicatorId, NetworkMessageId, ThreatType, Url, UrlLocation
Stage 15: source
ThreatIntelligenceIndicator
Stage 16: where
where TimeGenerated >= ago(1209600s)
Stage 17: where
where isnotempty(DomainName)
Stage 18: extend
extend DomainName
Stage 19: join
join kind=innerunique (EmailUrlInfo_) on DomainName, UrlDomain
Stage 20: where
where Active =~ true
Stage 21: where
where EmailUrlInfo_TimeGenerated < ExpirationDateTime
Stage 22: summarize
summarize EmailUrlInfo_TimeGenerated by IndicatorId, UrlDomain
Stage 23: project
project ActivityGroupNames, ConfidenceScore, Description, EmailUrlInfo_TimeGenerated, ExpirationDateTime, IndicatorId, NetworkMessageId, ThreatType, UrlDomain, UrlLocation
Stage 24: extend
extend timestamp
Stage 25: join
join kind=inner (EmailEvents_) on NetworkMessageId
Stage 26: where
where not (DeliveryAction contains "Blocked")
Stage 27: extend
extend Name, UPNSuffix
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
Active | eq |
| field:"Active" kind:eq value:"true" |
DomainName | is_not_null | field:"DomainName" kind:is_not_null | |
EmailUrlInfo_TimeGenerated | cross_field_compare |
| field:"EmailUrlInfo_TimeGenerated" kind:cross_field_compare value:"ExpirationDateTime" |
Url | is_not_null | field:"Url" kind:is_not_null | |
UrlDomain | is_not_null | field:"UrlDomain" kind:is_not_null |
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
DeliveryAction | match | Blocked | excludes:DeliveryAction field:"DeliveryAction" value:"Blocked" |
Output fields
These fields are emitted when the rule matches.
| Field | Source |
|---|---|
ActivityGroupNames | project |
ConfidenceScore | project |
Description | project |
EmailUrlInfo_TimeGenerated | project |
ExpirationDateTime | project |
IndicatorId | project |
NetworkMessageId | project |
ThreatType | project |
UrlDomain | project |
UrlLocation | project |
timestamp | extend |
Name | extend |
UPNSuffix | extend |