KQL queries, detection rules and projects from a security engineer.
Everything here is written for Microsoft Sentinel and Defender. Copy what is useful, tune it for your own environment, and test it before you rely on it.
let lookback = 1d;
let userThreshold = 10;
SigninLogs
| where TimeGenerated > ago(lookback)
| where ResultType in ("50126", "50053")
| summarize Failures = count(), Users = dcount(UserPrincipalName) by IPAddress
| where Users >= userThreshold
| join kind=inner (
SigninLogs
| where TimeGenerated > ago(lookback)
| where ResultType == "0"
| project SuccessTime = TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName
) on IPAddress
| project SuccessTime, IPAddress, UserPrincipalName, AppDisplayName, Failures, Users
| order by SuccessTime descLatest queries
All 2 queriesPassword spray followed by a successful sign-in
Example entry. Finds IP addresses that failed against many accounts, then signed in to one of them.
Encoded PowerShell grouped by parent process
Example entry. Shows which processes launch PowerShell with an encoded command, rarest first.
Latest detections
All 2 detectionsInbox rule that forwards or hides mail
Example entry. Alerts when a mailbox rule is created or changed to forward, redirect, move or delete messages.
mediumWindows Security event log cleared
Example entry. Alerts when the Security log is cleared on a monitored server.
high
Projects
All 2 projectsThis site
A static site built with Astro, kept in a private GitHub repo and published by Cloudflare.
in progressExample project
Example entry. One or two sentences on what the project is and who it is for.
idea