Query Details
// Threat Hunting Mshta with Sentinel TI let QueryPeriod = 1d; let T1218IOC = ThreatIntelIndicators | where TimeGenerated > ago(365d) | where now() between (ValidFrom .. ValidUntil) | where isnotempty(Data.labels) | mv-expand Data.labels | where Data_labels has "mitre" | extend MitreID = parse_json(tostring(Data_labels)).Alias | where MitreID == "T1218.005"; let NetworkTraffic = DeviceNetworkEvents | where TimeGenerated > ago(QueryPeriod) | where ActionType == "ConnectionSuccess" | join T1218IOC on ($left.RemoteIP == $right.ObservableValue); let EmailURL = EmailUrlInfo | where TimeGenerated > ago(QueryPeriod) | join T1218IOC on $left.Url == $right.ObservableValue; DeviceFileEvents | where TimeGenerated > ago(QueryPeriod) | join T1218IOC on $left.SHA256 == $right.ObservableValue | union NetworkAccessTraffic, EmailURL
This query is designed for threat hunting using Microsoft Sentinel, specifically looking for suspicious activities related to the use of "mshta" (Microsoft HTML Application) as described by the MITRE ATT&CK technique T1218.005. Here's a simplified breakdown of what the query does:
Define Query Period: It sets a time frame of 1 day for the query to look back.
Identify Threat Intelligence Indicators:
Network Traffic Analysis:
Email URL Analysis:
File Events Analysis:
Combine Results:
In essence, this query is used to detect and analyze potential security threats involving the misuse of mshta by correlating various data sources with known threat intelligence indicators.

Steven Lim
Released: May 3, 2025
Tables
Keywords
Operators