INVESTIGATION QUERIES & SCRIPTS
Microsoft Sentinel and Defender hunting queries, plus PowerShell incident-response scripts and one-liners
Insider Threat - Bulk File Access/Download
Detect bulk file downloads or synchronisation events from SharePoint/OneDrive that may indicate data staging for exfiltration.
KQL (Sentinel) · insider-threat, data-exfiltration, sharepoint, onedrive
OfficeActivity | where TimeGenerated > ago(30d) | where Operation in ("FileDownloaded", "FileAccessed", "FileCopied", "FileSyncDownloadedFull") | where UserId !endswith "@admin.onmicrosoft.com" | summarize FileCount = count(), TotalSizeMB = sum(OfficeWorkload), Sites = make_set(Site_Url), FileTypes = make_set(SourceFileExtension) by UserId, bin(TimeGenerated, 1h) | where FileCount > 100 | order by FileCount descURL Click Events - Phishing Link Detection
Identify users who clicked phishing links in emails, joined with email metadata for full context.
KQL (Sentinel) · phishing, email, url, microsoft365
UrlClickEvents | where TimeGenerated > ago(7d) | where Url has_any ("malicious-domain.com", "phishing-site.net") or ActionType == "ClickAllowed" | project TimeGenerated, Url, AccountUpn, NetworkMessageId, IsClickedThrough | join kind=inner ( EmailEvents | project NetworkMessageId, SenderFromAddress, Subject, RecipientEmailAddress ) on NetworkMessageId | order by TimeGenerated descSuspicious Mailbox Inbox Rules
Detect suspicious mailbox inbox rules created by attackers to forward emails to external addresses or hide security alerts.
KQL (Sentinel) · phishing, email, persistence, microsoft365
OfficeActivity | where TimeGenerated > ago(30d) | where Operation in ("Set-InboxRule", "New-InboxRule", "Enable-InboxRule") | extend RuleDetails = parse_json(Parameters) | project TimeGenerated, UserId, Operation, ClientIP, RuleName = tostring(RuleDetails[0].Value), ForwardTo = tostring(RuleDetails[1].Value) | where ForwardTo != "" | order by TimeGenerated descMalware Process Execution Detection
Detect suspicious process execution patterns commonly associated with malware loaders, PowerShell abuse, and living-off-the-land techniques.
KQL (Sentinel) · malware, endpoint, execution, LOLBAS
DeviceProcessEvents | where TimeGenerated > ago(24h) | where FileName in~ ("powershell.exe", "cmd.exe", "wscript.exe", "cscript.exe", "mshta.exe", "regsvr32.exe", "rundll32.exe") | where ProcessCommandLine has_any ("-enc", "-EncodedCommand", "IEX", "Invoke-Expression", "DownloadString", "WebClient", "bypass", "-nop", "-w hidden") | project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine | order by TimeGenerated descPersistence - Registry Run Keys
Hunt for malware persistence via registry Run keys, Winlogon modifications, and new service installations.
KQL (Sentinel) · malware, persistence, registry, endpoint
DeviceRegistryEvents | where TimeGenerated > ago(7d) | where RegistryKey has_any ( "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", "\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", "\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "\\System\\CurrentControlSet\\Services" ) | where ActionType in ("RegistryValueSet", "RegistryKeyCreated") | project TimeGenerated, DeviceName, AccountName, RegistryKey, RegistryValueName, RegistryValueData, InitiatingProcessFileName | order by TimeGenerated descNetwork C2 Beaconing Detection
Detect potential C2 beaconing by identifying processes making repeated outbound connections at regular intervals to the same remote IP.
KQL (Sentinel) · malware, C2, network, endpoint
DeviceNetworkEvents | where TimeGenerated > ago(24h) | where RemotePort in (4444, 1337, 8080, 8443, 443, 80) | where ActionType == "ConnectionSuccess" | where RemoteIPType != "Private" | summarize ConnectionCount = count(), BytesSent = sum(SentBytes), BytesReceived = sum(ReceivedBytes), RemotePorts = make_set(RemotePort) by DeviceName, RemoteIP, InitiatingProcessFileName, bin(TimeGenerated, 1h) | where ConnectionCount > 10 | order by ConnectionCount descRansomware - File Encryption Activity
Detect ransomware file encryption activity by identifying processes that are rapidly creating or renaming files with suspicious extensions.
KQL (Sentinel) · ransomware, endpoint, file-activity
DeviceFileEvents | where TimeGenerated > ago(1h) | where ActionType in ("FileCreated", "FileRenamed", "FileModified") | where FileName has_any (".encrypted", ".locked", ".crypted", ".enc", ".ransom", ".pays", ".rsa") or FileName matches regex @".*\.[a-z0-9]{6,8}$" | summarize ModifiedFiles = count(), Extensions = make_set(FileName), Directories = make_set(FolderPath) by DeviceName, InitiatingProcessFileName, InitiatingProcessId, bin(TimeGenerated, 5m) | where ModifiedFiles > 20 | order by ModifiedFiles descLateral Movement - Pass the Hash / Pass the Ticket
Detect NTLM-based lateral movement techniques including Pass-the-Hash by identifying network logons from multiple source IPs using the same credentials.
KQL (Sentinel) · ransomware, lateral-movement, identity, NTLM
SecurityEvent | where TimeGenerated > ago(24h) | where EventID == 4624 | where LogonType == 3 // Network logon | where AuthenticationPackageName == "NTLM" | where SubjectUserName != TargetUserName | where SubjectUserName !endswith "$" | summarize LogonCount = count(), SourceIPs = make_set(IpAddress), TargetSystems = make_set(Computer) by TargetUserName, AccountDomain | where LogonCount > 5 | order by LogonCount descAccount Compromise - Impossible Travel
Detect impossible travel scenarios where the same account authenticates from two geographically distant locations within a short time window.
KQL (Sentinel) · identity, account-compromise, azure-ad, entra-id
SigninLogs | where TimeGenerated > ago(7d) | where ResultType == 0 // Successful sign-in | project TimeGenerated, UserPrincipalName, IPAddress, Location, DeviceDetail, AppDisplayName | sort by UserPrincipalName, TimeGenerated asc | extend prev_time = prev(TimeGenerated), prev_location = prev(Location), prev_user = prev(UserPrincipalName) | where UserPrincipalName == prev_user | extend TimeDiffMinutes = datetime_diff('minute', TimeGenerated, prev_time) | where TimeDiffMinutes < 60 and Location != prev_location | project UserPrincipalName, TimeGenerated, Location, prev_location, TimeDiffMinutes, IPAddress, AppDisplayNameMFA Fatigue Attack Detection
Detect MFA fatigue (push bombing) attacks where an attacker repeatedly triggers MFA prompts hoping the user approves out of frustration.
KQL (Sentinel) · identity, MFA, account-compromise
AADNonInteractiveUserSignInLogs | where TimeGenerated > ago(1h) | where ResultType == 50074 // MFA required or ResultType == 500121 // Authentication required | summarize MFARequests = count(), UniqueIPs = dcount(IPAddress), Apps = make_set(AppDisplayName) by UserPrincipalName, bin(TimeGenerated, 15m) | where MFARequests > 5 | order by MFARequests descPhishing Email Search - All Tenants
Search all email events in Microsoft Sentinel for phishing indicators. Customise the SenderFromAddress and Subject values with your IOCs.
KQL (Sentinel) · phishing, email, microsoft365
EmailEvents | where TimeGenerated > ago(7d) | where SenderFromAddress has_any ("suspicious-domain.com", "attacker.net") or Subject has_any ("Invoice", "Urgent", "Action Required", "Verify your account") | project TimeGenerated, SenderFromAddress, SenderIPv4, RecipientEmailAddress, Subject, DeliveryAction, ThreatTypes | order by TimeGenerated descInsider Threat - Email Exfiltration to Personal Address
Detect employees emailing attachments to personal webmail accounts, a common data exfiltration technique used by insiders.
KQL (Sentinel) · insider-threat, data-exfiltration, email
EmailEvents | where TimeGenerated > ago(30d) | where SenderFromDomain == "yourcompany.com" // Replace with your domain | where RecipientEmailAddress has_any ("gmail.com", "yahoo.com", "hotmail.com", "protonmail.com", "outlook.com") | where AttachmentCount > 0 | project TimeGenerated, SenderFromAddress, RecipientEmailAddress, Subject, AttachmentCount, DeliveryAction | order by TimeGenerated descBulk SharePoint & OneDrive Downloads
Detect mass file downloads from SharePoint/OneDrive that may indicate data exfiltration.
KQL (Sentinel) ·
OfficeActivity | where UserId == "<UPN>" | where TimeGenerated > ago(14d) | where Operation in ("FileDownloaded", "FileSyncDownloadedFull", "SharingLinkCreated", "AnonymousLinkCreated") | summarize EventCount = count(), FileList = make_set(OfficeObjectId, 20) by UserId, Operation, bin(TimeGenerated, 1h) | where EventCount > 10 | order by TimeGenerated descRisky User Sign-In Activity (Last 14 Days)
Review all sign-in events for a risky user, highlighting anomalous locations and MFA results.
KQL (Sentinel) ·
SigninLogs | where UserPrincipalName == "<UPN>" | where TimeGenerated > ago(14d) | project TimeGenerated, IPAddress, Location, AppDisplayName, ClientAppUsed, ResultType, ResultDescription, MfaDetail, ConditionalAccessStatus, DeviceDetail, RiskLevelDuringSignIn, RiskLevelAggregated | order by TimeGenerated descSuspicious Inbox Rule Creation
Detect inbox rules that forward or delete mail — a common attacker persistence technique.
KQL (Sentinel) ·
OfficeActivity | where UserId == "<UPN>" | where Operation in ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules") | extend RuleParameters = tostring(Parameters) | where RuleParameters has_any ("ForwardTo", "ForwardAsAttachmentTo", "RedirectTo", "DeleteMessage", "MarkAsRead") | project TimeGenerated, UserId, Operation, RuleParameters, ClientIP | order by TimeGenerated descOAuth Application Consent Grants
Identify OAuth application consents granted by the user, highlighting high-risk permission scopes.
KQL (Sentinel) ·
AuditLogs | where TimeGenerated > ago(90d) | where OperationName == "Consent to application" | extend InitiatedByUser = tostring(InitiatedBy.user.userPrincipalName) | where InitiatedByUser == "<UPN>" | extend AppName = tostring(TargetResources[0].displayName) | extend Scopes = tostring(TargetResources[0].modifiedProperties) | project TimeGenerated, InitiatedByUser, AppName, Scopes, Result | order by TimeGenerated descDefender Alerts by Severity — Last 7 Days
Summary of all Defender XDR alerts grouped by severity and category over the past 7 days — useful for daily SOC triage.
KQL (Defender) · alerts, SOC, triage, overview
AlertInfo | where Timestamp > ago(7d) | summarize AlertCount = count(), Titles = make_set(Title, 5) by Severity, Category | order by case(Severity, "High", 1, "Medium", 2, "Low", 3, "Informational", 4, 5) asc, AlertCount descSuspicious PowerShell Encoded Command Execution
Detect PowerShell processes using encoded commands, a common technique for obfuscating malicious scripts and bypassing detection.
KQL (Defender) · powershell, defense-evasion, execution, LOLBAS
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName =~ "powershell.exe" or FileName =~ "pwsh.exe" | where ProcessCommandLine has_any ("-enc", "-EncodedCommand", "-e ", "IEX", "Invoke-Expression", "DownloadString", "FromBase64String") | project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine | order by Timestamp descScheduled Task Persistence
Detect new scheduled task creation — a common attacker persistence mechanism on Windows endpoints.
KQL (Defender) · persistence, scheduled-task, endpoint
DeviceProcessEvents | where Timestamp > ago(7d) | where FileName =~ "schtasks.exe" | where ProcessCommandLine has_any ("/create", "/change", "/run") | where ProcessCommandLine !has "MicrosoftEdgeUpdate" | project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName | order by Timestamp descLiving-off-the-Land Binary Abuse
Detect abuse of trusted Windows binaries (certutil, bitsadmin, mshta, regsvr32) commonly used to download or execute malicious payloads.
KQL (Defender) · LOLBAS, defense-evasion, execution, endpoint
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName in~ ("certutil.exe", "bitsadmin.exe", "mshta.exe", "regsvr32.exe", "wmic.exe", "cmstp.exe", "installutil.exe") | where ProcessCommandLine has_any ("http", "ftp", "download", "urlcache", "transfer", "/s ", "scrobj") | project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName | order by Timestamp descSuspicious Network Connections to Rare External IPs
Identify processes making outbound connections to external IPs that are rarely seen in your environment — a potential C2 indicator.
KQL (Defender) · C2, network, threat-hunting, endpoint
DeviceNetworkEvents | where Timestamp > ago(24h) | where RemoteIPType == "Public" | where ActionType == "ConnectionSuccess" | summarize ConnectionCount = count(), Devices = make_set(DeviceName, 5), Processes = make_set(InitiatingProcessFileName, 5) by RemoteIP, RemotePort | where ConnectionCount < 3 // rare connections | where RemotePort !in (80, 443, 53) | order by ConnectionCount ascBulk File Encryption — Ransomware Indicator
Detect mass file modification or rename events with suspicious extensions, indicating active ransomware encryption.
KQL (Defender) · ransomware, file-activity, endpoint
DeviceFileEvents | where Timestamp > ago(1h) | where ActionType in ("FileCreated", "FileRenamed", "FileModified") | where FileName has_any (".encrypted", ".locked", ".crypted", ".enc", ".ransom", ".pays") or FileName matches regex @"\.[a-zA-Z0-9]{5,8}$" | summarize ModifiedFiles = count(), SampleFiles = make_set(FileName, 10), Folders = make_set(FolderPath, 5) by DeviceName, InitiatingProcessFileName, InitiatingProcessId, bin(Timestamp, 5m) | where ModifiedFiles > 20 | order by ModifiedFiles descBrute Force & Suspicious Logon Activity
Detect accounts with a high volume of failed logon attempts followed by a success — a pattern consistent with brute force or password spray attacks.
KQL (Defender) · brute-force, identity, logon, endpoint
DeviceLogonEvents | where Timestamp > ago(24h) | where ActionType == "LogonFailed" | summarize FailedCount = count(), SourceIPs = make_set(RemoteIP, 5), LastFailed = max(Timestamp) by AccountName, DeviceName | where FailedCount > 10 | join kind=leftouter ( DeviceLogonEvents | where Timestamp > ago(24h) | where ActionType == "LogonSuccess" | summarize FirstSuccess = min(Timestamp) by AccountName, DeviceName ) on AccountName, DeviceName | where isnotnull(FirstSuccess) and FirstSuccess > LastFailed | project AccountName, DeviceName, FailedCount, SourceIPs, LastFailed, FirstSuccess | order by FailedCount descLateral Movement — PsExec & Remote Execution
Detect PsExec and similar remote execution tools used for lateral movement between endpoints.
KQL (Defender) · lateral-movement, psexec, remote-execution, endpoint
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName =~ "psexec.exe" or FileName =~ "psexec64.exe" or (FileName =~ "cmd.exe" and ProcessCommandLine has_any ("\\\\", "/s ", "sc start", "sc create")) or InitiatingProcessFileName =~ "PSEXESVC.exe" | project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, RemoteDeviceName = InitiatingProcessRemoteSessionDeviceName | order by Timestamp descFile Hash IOC Hunt
Hunt across all endpoints for known-bad file hashes. Replace the hash values with your IOCs from threat intel.
KQL (Defender) · IOC, threat-hunting, file-hash, endpoint
let BadHashes = dynamic([ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", // SHA256 placeholder — replace with IOC "d41d8cd98f00b204e9800998ecf8427e" // MD5 placeholder — replace with IOC ]); DeviceFileEvents | where Timestamp > ago(7d) | where SHA256 in (BadHashes) or MD5 in (BadHashes) | project Timestamp, DeviceName, ActionType, FileName, FolderPath, SHA256, MD5, InitiatingProcessFileName | order by Timestamp descLSASS Memory Access — Credential Dumping
Detect processes attempting to read LSASS memory, the primary technique used by tools like Mimikatz to dump credentials.
KQL (Defender) · credential-dumping, lsass, mimikatz, endpoint
DeviceEvents | where Timestamp > ago(24h) | where ActionType == "LsassProcessAccess" | where InitiatingProcessFileName !in~ ("MsMpEng.exe", "svchost.exe", "WerFault.exe", "csrss.exe") | project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName | order by Timestamp descAccount Lockout Events — Last 24 Hours
List all account lockout events (Event ID 4740) in the past 24 hours, showing the locking computer and target account.
KQL (Sentinel) · brute-force, account-lockout, active-directory, identity
SecurityEvent | where EventID == 4740 | where TimeGenerated > ago(24h) | project TimeGenerated, LockedAccount = TargetUserName, LockingComputer = Computer, CallerComputer = SubjectUserName, Domain = TargetDomainName | order by TimeGenerated descAzure AD Sign-In Failures by IP — Brute Force View
Summarise Entra ID / Azure AD authentication failures by source IP. Detects password spray against cloud-only or hybrid accounts via the Azure AD sign-in endpoint.
KQL (Sentinel) · azure-ad, entra-id, brute-force, password-spray, cloud
SigninLogs | where TimeGenerated > ago(1h) | where ResultType != 0 | summarize FailureCount = count(), TargetedAccounts = make_set(UserPrincipalName), ErrorCodes = make_set(ResultDescription), Apps = make_set(AppDisplayName) by IPAddress, Location | where FailureCount > 20 | extend AttackType = iff(array_length(TargetedAccounts) > 3, "Password Spray", "Targeted") | order by FailureCount descPassword Spray Detection — Many Accounts from One Source
Detect password spray attacks by identifying source IPs that attempted authentication against 5 or more distinct accounts within one hour.
KQL (Sentinel) · password-spray, brute-force, active-directory, identity
SecurityEvent | where EventID == 4625 | where TimeGenerated > ago(1h) | summarize DistinctAccounts = dcount(TargetUserName), FailureCount = count(), AccountList = make_set(TargetUserName) by IpAddress | where DistinctAccounts >= 5 | extend SpraySeverity = case(DistinctAccounts >= 20, "High", DistinctAccounts >= 10, "Medium", "Low") | order by DistinctAccounts descFailed Logon Events by Source IP
Summarise authentication failures (Event ID 4625) grouped by source IP. High failure counts from a single IP indicate a brute force or spray attack in progress.
KQL (Sentinel) · brute-force, failed-logon, active-directory, identity
SecurityEvent | where EventID == 4625 | where TimeGenerated > ago(1h) | summarize FailureCount = count(), TargetedAccounts = make_set(TargetUserName), LogonTypes = make_set(LogonType) by IpAddress, WorkstationName | where FailureCount > 10 | extend AttackType = iff(array_length(TargetedAccounts) > 3, "Password Spray", "Targeted Brute Force") | order by FailureCount descSuccessful Logon After Multiple Failures — Potential Compromise
Identifies accounts where a successful logon followed 5 or more failures from the same IP — a strong indicator of successful brute force compromise requiring immediate investigation.
KQL (Sentinel) · brute-force, compromise, account-takeover, identity
let FailedLogons = SecurityEvent | where EventID == 4625 and TimeGenerated > ago(6h) | summarize FailureCount = count() by TargetUserName, IpAddress; let SuccessfulLogons = SecurityEvent | where EventID == 4624 and TimeGenerated > ago(6h) | project TargetUserName, IpAddress, LogonTime = TimeGenerated, LogonType; SuccessfulLogons | join kind=inner FailedLogons on TargetUserName, IpAddress | where FailureCount >= 5 | project LogonTime, TargetUserName, IpAddress, FailureCount, LogonType | order by FailureCount descFailed Logon Events by Device — Endpoint Brute Force
Detect devices generating a high volume of failed logon attempts — a key indicator of brute force or password spray activity originating from or targeting an endpoint.
KQL (Defender) · brute-force, failed-logon, endpoint, identity
DeviceLogonEvents | where Timestamp > ago(1h) | where ActionType == "LogonFailed" | summarize FailureCount = count(), TargetedAccounts = make_set(AccountName), RemoteIPs = make_set(RemoteIPAddress) by DeviceName, AccountDomain | where FailureCount > 10 | extend AttackType = iff(array_length(TargetedAccounts) > 3, "Password Spray", "Targeted Brute Force") | order by FailureCount descPassword Spray Detection — Many Accounts, Few Attempts Each
Identify password spray patterns on endpoints: a single source device attempting authentication against many distinct accounts with a low attempt count per account.
KQL (Defender) · password-spray, brute-force, endpoint, identity
DeviceLogonEvents | where Timestamp > ago(1h) | where ActionType == "LogonFailed" | summarize FailureCount = count(), DistinctAccounts = dcount(AccountName), AccountList = make_set(AccountName) by DeviceName, RemoteIPAddress | where DistinctAccounts >= 5 | extend SpraySeverity = case(DistinctAccounts >= 20, "High", DistinctAccounts >= 10, "Medium", "Low") | order by DistinctAccounts descSuccessful Logon After Multiple Failures — Endpoint Compromise
Find accounts on endpoints where a successful logon followed repeated failures from the same source — a strong indicator that a brute force attack succeeded.
KQL (Defender) · brute-force, compromise, account-takeover, endpoint
let FailedLogons = DeviceLogonEvents | where Timestamp > ago(6h) | where ActionType == "LogonFailed" | summarize FailureCount = count() by AccountName, DeviceName, RemoteIPAddress; let SuccessfulLogons = DeviceLogonEvents | where Timestamp > ago(6h) | where ActionType == "LogonSuccess" | project AccountName, DeviceName, RemoteIPAddress, LogonTime = Timestamp, LogonType; SuccessfulLogons | join kind=inner FailedLogons on AccountName, DeviceName, RemoteIPAddress | where FailureCount >= 5 | project LogonTime, AccountName, DeviceName, RemoteIPAddress, FailureCount, LogonType | order by FailureCount descNTLM Authentication Failures — Lateral Brute Force
Detect NTLM-based authentication failures which are commonly used in pass-the-hash and brute force attacks against Windows endpoints and servers.
KQL (Defender) · ntlm, brute-force, lateral-movement, endpoint, identity
DeviceLogonEvents | where Timestamp > ago(24h) | where ActionType == "LogonFailed" | where Protocol == "NTLM" | summarize FailureCount = count(), TargetedAccounts = make_set(AccountName), SourceDevices = make_set(DeviceName) by RemoteIPAddress, AccountDomain | where FailureCount > 5 | order by FailureCount descAccount Lockout Events — Endpoint View
Surface accounts that have been locked out across managed endpoints. Correlate lockout source devices to identify whether the origin is automated tooling or a compromised device.
KQL (Defender) · account-lockout, brute-force, endpoint, identity
DeviceEvents | where Timestamp > ago(24h) | where ActionType == "UserAccountLockedOut" | project Timestamp, DeviceName, AccountName, AccountDomain, InitiatingProcessFileName, InitiatingProcessCommandLine | order by Timestamp descURL Clicks to Lookalike Domain
Identify users who clicked links pointing to the lookalike domain and whether they reached it.
KQL (Defender) · lookalike-domain, phishing, url-click, brand-impersonation
let lookalikeDomain = "<lookalike-domain.com>"; UrlClickEvents | where Url has lookalikeDomain | project Timestamp, AccountUpn, Url, ActionType, UrlChain, IsClickedThrough, IPAddress, NetworkMessageId, WorkloadName | order by Timestamp descLookalike Domain — Web Traffic from Endpoints
Identify endpoint connections to the lookalike domain and the users and processes responsible.
KQL (Defender) · lookalike-domain, network, endpoint, phishing
let lookalikeDomain = "<lookalike-domain.com>"; DeviceNetworkEvents | where RemoteUrl has lookalikeDomain | project Timestamp, DeviceName, InitiatingProcessAccountName, RemoteUrl, RemoteIP, RemotePort, ActionType, InitiatingProcessFileName | order by Timestamp descDMARC Failures — Spoofed Email Detections
Detect inbound email that failed DMARC or SPF authentication for spoofing review.
KQL (Defender) · DMARC, SPF, email-spoofing, phishing, brand-impersonation
EmailEvents | where AuthenticationDetails has "dmarc=fail" or AuthenticationDetails has "spf=fail" | project Timestamp, SenderFromAddress, SenderFromDomain, SenderMailFromDomain, RecipientEmailAddress, Subject, DeliveryAction, AuthenticationDetails, ThreatTypes, NetworkMessageId | order by Timestamp descEmails Received from Lookalike Domain
Find email received from the domain under investigation and review delivery, threat, and authentication results.
KQL (Defender) · lookalike-domain, phishing, email, brand-impersonation
let lookalikeDomain = "<lookalike-domain.com>"; EmailEvents | where SenderFromDomain =~ lookalikeDomain or SenderMailFromDomain =~ lookalikeDomain | project Timestamp, SenderFromAddress, SenderFromDomain, RecipientEmailAddress, Subject, DeliveryAction, DeliveryLocation, ThreatTypes, AuthenticationDetails, NetworkMessageId | order by Timestamp desc