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.

Password spray followed by a successful sign-in
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 desc

Latest queries

All 2 queries

Latest detections

All 2 detections