MDO (Office)

Introduction

Microsoft Defender for Office 365 is a cloud-based security solution designed to safeguard email and collaboration tools within Microsoft 365 against advanced threats like phishing, malware, ransomware, and business email compromise (BEC). It provides comprehensive protection by employing real-time threat intelligence, machine learning, and behavioural analysis to identify and neutralise emerging threats. Key features include Safe Links and Safe Attachments, which dynamically scan URLs and files for malicious content, along with anti-phishing capabilities that detect and block impersonation attempts and credential harvesting campaigns.

In addition to protection, Defender for Office 365 offers advanced threat investigation and response capabilities. Security teams can use its Threat Explorer and real-time detection dashboards to gain visibility into attacks, analyse trends, and identify compromised accounts or affected mailboxes. The platform integrates seamlessly with other Microsoft security tools like Defender for Endpoint and Azure Sentinel, enabling unified threat management. By extending its protection to SharePoint, OneDrive, and Teams, Defender for Office 365 helps organisations secure their collaboration environments, enhance compliance, and reduce the risk of data breaches in today's increasingly sophisticated threat landscape.

The following is a set of KQL queries that can be used to detect and analyse malicious or suspicious activities in your environment. The queries are designed to quickly grab the necessary information that will allow the investigator to determine whether the activity warrants deeper analysis or escalation.

Note: On some occasions, hopefully, at a minimum, the investigator will have to customise the queries for the environment where they are being used. Queries will only work if the data is available.

Identify Email Attachments Send From Compromised Mailbox

// Define search parameters
let CompromisedMailbox = "user1@exampledomain.com"; // Specify the compromised mailbox
let SearchWindow = 48h; // Set the search window for analysis
// Query to analyze emails sent from the compromised mailbox with attachments
EmailEvents
| where Timestamp >= ago(SearchWindow) // Filter for events within the search window
| where SenderFromAddress == CompromisedMailbox // Focus on the compromised mailbox
| where AttachmentCount > 0 // Include only emails with attachments
| join kind=leftouter EmailAttachmentInfo on NetworkMessageId // Join with attachment info using NetworkMessageId
| project
    Timestamp, // Email timestamp
    NetworkMessageId, // Unique identifier for the email
    SenderFromAddress, // Sender's email address
    RecipientEmailAddress, // Recipient's email address
    Subject, // Email subject
    ThreatTypes, // Identified threats (if any)
    SHA256 // Hash of the attachment
| join kind=leftouter DeviceFileEvents on SHA256 // Join with file events using attachment hash
| summarize
    EmailRecipients = make_set(RecipientEmailAddress), // Aggregate unique email recipients
    EmailSubjects = make_set(Subject), // Aggregate unique email subjects
    DevicesWithFile = make_set(DeviceName) // Aggregate devices interacting with the attachment
    by SHA256, NetworkMessageId // Group by attachment hash and email ID
| extend
    TotalRecipients = array_length(EmailRecipients), // Count unique email recipients
    DevicesWithFileInteraction = array_length(DevicesWithFile) // Count unique devices interacting with the file
//| order by Tim desc // Sort by the most recent email event

Identifying Executable File Attachments Sent to Users

Use Case: Threat Actors often use executable files to gain initial access. This query detects a common set of extensions that are normally targeted at Windows systems.

Search for Malware File Detected In Office 365

Use Case: This advanced query allows SOC analysts to: Detect and prioritize malware activity within Office workloads. Identify patterns in malware types and affected file extensions. Gain insights into impacted users and files for targeted remediation.

Identify Potential Phishing Campaign

Identifying Emails Categorised as Suspicious Delivered to Users

Use Case: This query is ideal for investigating emails sent to a compromised address, analyzing associated threats, and understanding post-delivery actions to mitigate risks effectively.

Identify User UrlClick Events

User Cases: Identify emails with URLs sent to user and they may have clicked URL and it wasn’t blocked.

Reference

Last updated