← Back to SOC feed Coverage →

Campaign with randomly named attachments

kql MEDIUM Azure-Sentinel
T1566
EmailAttachmentInfo
huntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-17T11:00:00Z · Confidence: medium

Hunt Hypothesis

Emails with randomly named attachments from the same sender to multiple recipients indicate potential phishing or malware distribution efforts, as adversaries often use unpredictable filenames to evade detection. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate targeted campaigns that may bypass traditional email security controls.

KQL Query

EmailAttachmentInfo
| where Timestamp > ago(7d)
| where FileType in ("png", "jpg", "jpeg", "gif", "svg")
| where isnotempty(FileName)
| extend firstFourFileName = substring(FileName, 0, 4)
| summarize RecipientsCount = dcount(RecipientEmailAddress), FirstFourFilesCount = dcount(firstFourFileName), suspiciousEmails = make_set(NetworkMessageId, 10) by SenderFromAddress
| where FirstFourFilesCount >= 10

Analytic Rule Definition

id: 25150085-015a-4673-9b67-bc6ad9475500
name: Campaign with randomly named attachments
description: |
  In this detection,we hunt for emails with randomly named attachment names from the same sender to multiple recipients
description-detailed: |
  In this detection,we hunt for emails with randomly named attachment names from the same sender to multiple recipients using Defender for Office 365 data, typically more than 50, can potentially indicate a QR code phishing campaign.
  Reference - https://techcommunity.microsoft.com/t5/microsoft-defender-for-office/hunting-and-responding-to-qr-code-based-phishing-attacks-with/ba-p/4074730
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - EmailEvents
tactics:
  - InitialAccess
relevantTechniques:
  - T1566
query: |
  EmailAttachmentInfo
  | where Timestamp > ago(7d)
  | where FileType in ("png", "jpg", "jpeg", "gif", "svg")
  | where isnotempty(FileName)
  | extend firstFourFileName = substring(FileName, 0, 4)
  | summarize RecipientsCount = dcount(RecipientEmailAddress), FirstFourFilesCount = dcount(firstFourFileName), suspiciousEmails = make_set(NetworkMessageId, 10) by SenderFromAddress
  | where FirstFourFilesCount >= 10
version: 1.0.0 

Required Data Sources

Sentinel TableNotes
EmailAttachmentInfoEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/QR code/Campaign with randomly named attachments.yaml