Skip to content

Instantly share code, notes, and snippets.

@seclib
Created August 7, 2019 01:51
Show Gist options
  • Save seclib/7a47fb2699ee60d97d723eb040ddca00 to your computer and use it in GitHub Desktop.
Save seclib/7a47fb2699ee60d97d723eb040ddca00 to your computer and use it in GitHub Desktop.
Azure Sentinel Password spray query
let valid_logons = (OfficeActivity
| where TimeGenerated > ago(30d)
| where Operation == 'UserLoggedIn'
| summarize by ClientIP);
let only_invalid_logons = (OfficeActivity
| where TimeGenerated > ago(30d)
| where Operation == 'UserLoginFailed'
| summarize by ClientIP)
| join kind=anti (valid_logons) on ClientIP;
OfficeActivity
| where TimeGenerated > ago(30d)
| join kind=inner (only_invalid_logons) on ClientIP
| extend UserAgent=tostring(parse_json(ExtendedProperties)[0].Value)
| where (UserAgent matches regex 'Microsoft Office/\\d+\\.\\d+ \\(Windows NT \\d+\\.\\d+; Microsoft Outlook \\d+\\.\\d+\\.\\d+; Pro\\)'
or UserAgent == 'CBAInPROD'
or UserAgent matches regex '^[\\w\\.\\d\\-\\_]{4,15}\\/[\\.\\w\\d\\-\\_]{4,30}$')
| summarize by ClientIP, UserAgent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment