Investigating Suspicious Emails Using KQL
Investigating phishing emails using Kusto Query Language (KQL) in Microsoft Sentinel and Microsoft Defender XDR. This will involve querying data from various sources, such as email logs, threat intelligence feeds, endpoint telemetry, and more.
1. Understand the Data Sources
Before writing queries, it’s important to know which tables contain relevant data:
Email Logs:
EmailEvents
(from Microsoft 365 Defender or Defender for Office 365).Threat Intelligence:
ThreatIntelligenceIndicator
.Endpoint Data:
DeviceEvents
,DeviceFileEvents,
DeviceNetworkEvents
(from Defender for Endpoint).Alerts:
SecurityAlert
.
2. Identify Suspicious Emails
Start by identifying suspicious emails that may indicate phishing attempts. Look for indicators like:
Emails with malicious attachments or links.
Emails sent from suspicious domains or IP addresses.
Emails flagged by Microsoft Defender for Office 365.
Example Query: Find Emails with Malicious Attachments
Example Query: Emails from External Domains
Example Query: Find Emails from Suspicious Senders
Example Query: Find Emails with Malicious Attachments
Example Query: Find Emails with Suspicious URLs
Example Query: Correlate Phishing Alerts with Email Data
Example Query: Investigate User Activity Post-Phishing
3. Correlate with Threat Intelligence
Check if the sender's domain or IP address matches known malicious indicators from threat intelligence feeds.
Example Query: Match Email Senders with Threat Intelligence
4. Investigate Clicked Links
If users clicked on links in phishing emails, investigate the URLs they visited.
Example Query: Find Clicked URLs
Example Query: Check URL Reputation
5. Analyse Endpoint Activity
If a user downloaded a malicious attachment or visited a malicious link, check for suspicious activity on their device.
Example Query: File Execution After Email Delivery
Example Query: Network Connections After Email Click
6. Review Security Alerts
Look for alerts generated by Microsoft Defender for Office 365 or Defender for Endpoint related to phishing.
Example Query: Phishing Alerts
7. Visualise and Summarise Findings
Use KQL to summarise and visualise your findings for reporting or further analysis.
Example Query: Count of Phishing Emails by Sender Domain
Example Query: Top Recipients of Phishing Emails
8. Automate Investigation
To streamline investigations, consider creating:
Hunting Queries: Save frequently used queries in Sentinel for quick access.
Playbooks: Use Azure Logic Apps to automate responses, such as blocking malicious domains or notifying affected users.
Key Tips
Filter Noise: Use filters like
where
clauses to narrow down results and focus on high-priority events.Time Range: Specify a time range (
| where TimeGenerated > ago(7d)
) to limit the scope of your queries.Collaboration: Share findings with your security team using workbooks or dashboards in Sentinel.
Last updated