VeriKQL by Kaushik Saha

Level 6 · Is this one incident? · Mission 4 of 5 · by Kaushik Saha

Name it and ship it

Alert Six alerts, one attacker · Idea ATT&CK · analytics rule

Commands here where · == · and / or · ago · summarize · min / max · make_set / make_list · let · join · kind=inner · all commands

Briefing

The incident is understood. Two jobs remain: describe it in a language every SOC shares, and make sure the next one is caught without a ticket from the victim.

Name each step with MITRE ATT&CK

Step What happened ATT&CK technique
07:40 One address tried every user once (a separate attempt) T1110.003 Password Spraying
07:55 An "overdue invoice" email with a link T1566.002 Spearphishing Link
08:14 Six passwords tried against Alex T1110.001 Password Guessing
08:19 MFA prompts until one was approved T1621 Multi-Factor Authentication Request Generation
08:20 Signed in as Alex T1078.004 Valid Accounts: Cloud Accounts
09:40 Made the account a Global Administrator T1098.003 Account Manipulation: Additional Cloud Roles

One idea: hunt over the day, then schedule the rule

First, as a hunt over the whole day: a successful sign-in from an address that, earlier the same day, sent the company a first-contact email.

let Window = 1d;
let Senders = EmailEvents
    | where TimeGenerated > ago(Window) and IsFirstContact == true
    | summarize FirstEmail = min(TimeGenerated) by SenderIPv4;
SigninLogs
| where TimeGenerated > ago(Window) and ResultType == "0"
| join kind=inner Senders on $left.IPAddress == $right.SenderIPv4
| where TimeGenerated > FirstEmail
| summarize FirstSignIn = min(TimeGenerated), Apps = make_set(AppDisplayName) by UserPrincipalName, IPAddress, FirstEmail
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 1 row

UserPrincipalNameIPAddressFirstEmailFirstSignInApps
alex.morgan@contoso.com203.0.113.452026-06-10 07:55:122026-06-10 08:20:36["Office 365 Exchange Online","Microsoft Graph PowerShell","Azure Portal"]

A scheduled rule runs every hour. If it looked at a whole day of sign-ins, Alex's sign-ins would raise the same alert on every run until midnight. So the rule keeps a day of emails, the context, but only the last hour of sign-ins, the trigger:

let EmailWindow = 1d;
let RunEvery = 1h;
let Senders = EmailEvents
    | where TimeGenerated > ago(EmailWindow) and IsFirstContact == true
    | summarize FirstEmail = min(TimeGenerated) by SenderIPv4;
SigninLogs
| where TimeGenerated > ago(RunEvery) and ResultType == "0"
| join kind=inner Senders on $left.IPAddress == $right.SenderIPv4
| where TimeGenerated > FirstEmail
| summarize FirstSignIn = min(TimeGenerated), Apps = make_set(AppDisplayName) by UserPrincipalName, IPAddress, FirstEmail
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

At the story's clock, 12:00, its last hour holds nothing new. Its 09:00 run would have alerted on the sign-ins from 08:20:36, and its 10:00 run on the attacker's next one at 09:02: each sign-in once, never the same one twice. In Microsoft Sentinel it becomes a scheduled analytics rule:

Setting Value
Run every 1 hour (the RunEvery above)
Look back 1 day, the longest window in the query (EmailWindow)
Entities Account: UserPrincipalName · IP: IPAddress
Tactics and techniques Initial Access: T1566.002, T1078.004
Severity High

Your turn

Change the hunt to find any successful sign-in from an address that emailed the company that day, first contact or not.

Write it in the box below and check it. Then compare with one answer; others can be right too.

Show one answer
let Window = 1d;
let Senders = EmailEvents
    | where TimeGenerated > ago(Window) and DeliveryAction == "Delivered"
    | summarize FirstEmail = min(TimeGenerated) by SenderIPv4;
SigninLogs
| where TimeGenerated > ago(Window) and ResultType == "0"
| join kind=inner Senders on $left.IPAddress == $right.SenderIPv4
| where TimeGenerated > FirstEmail
| summarize FirstSignIn = min(TimeGenerated), Apps = make_set(AppDisplayName) by UserPrincipalName, IPAddress, FirstEmail
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 1 row

UserPrincipalNameIPAddressFirstEmailFirstSignInApps
alex.morgan@contoso.com203.0.113.452026-06-10 07:55:122026-06-10 08:20:36["Office 365 Exchange Online","Microsoft Graph PowerShell","Azure Portal"]

Check your own query

Write your query for the task above and check it against the real schema.

Debrief

You named the attack and wrote a rule for it. One bug hunt left, then the case is closed.

All data on this page is sample data, made up for this course. The IP addresses come from ranges reserved for documentation, and the people and the company are fictional.

Mission by Kaushik Saha. Every query checked with Microsoft.Azure.Kusto.Language 12.4.1 against schema bundle 2026.10.29; every result computed on the course's sample with Kusto-Loco 1.4.9, an open-source KQL engine (credits). The story's clock reads 12:00 UTC on 10 June 2026.