User Activity Tracking with KQL

Microsoft Sentinel & Defender XDR - SOC Analyst Playbook


🎯 Overview

This playbook provides KQL queries and investigation workflows for account usage analysis across:

  • Microsoft Sentinel (Azure Sentinel)

  • Microsoft Defender XDR (Defender for Endpoint, Identity, Cloud Apps)

  • Azure Active Directory (Entra ID)

  • Windows Security Events


📊 Data Sources Quick Reference

Available Tables

Table Name
Source
Description
Retention

SecurityEvent

Windows Events

Security.evtx via Log Analytics

90 days default

IdentityLogonEvents

Defender for Identity

Domain authentication

30 days

DeviceLogonEvents

Defender for Endpoint

Local logons

30 days

DeviceEvents

Defender for Endpoint

General device activity

30 days

SigninLogs

Azure AD/Entra ID

Cloud authentication

30 days

AADNonInteractiveUserSignInLogs

Azure AD

Service principal/app auth

30 days

AuditLogs

Azure AD

Account changes

30 days

IdentityDirectoryEvents

Defender for Identity

AD changes

30 days

CloudAppEvents

Defender for Cloud Apps

SaaS activity

30 days

BehaviorAnalytics

Sentinel UEBA

User behavior anomalies

14 days

OfficeActivity

Office 365

Exchange/SharePoint/Teams

90 days

Event ID to Table Mapping

Windows Event ID
Sentinel Table
Defender XDR Table

4624 (Logon)

SecurityEvent

DeviceLogonEvents

4625 (Failed Logon)

SecurityEvent

DeviceLogonEvents

4648 (Explicit Creds)

SecurityEvent

DeviceEvents

4672 (Admin Logon)

SecurityEvent

DeviceLogonEvents

4776 (NTLM Auth)

SecurityEvent

IdentityLogonEvents

4768 (Kerberos TGT)

SecurityEvent

IdentityLogonEvents

4769 (Kerberos Service)

SecurityEvent

IdentityLogonEvents

4771 (Kerberos Failed)

SecurityEvent

IdentityLogonEvents


🔍 Phase 1: Initial Triage Queries

1.1 Quick Account Profile (Sentinel)

1.2 Quick Account Profile (Defender XDR)

1.3 Is This Account Under Attack? (Quick Check)


🔐 Phase 2: Authentication Analysis

2.1 Complete Authentication Timeline (Sentinel)

2.2 Failed Logon Analysis - Brute Force Detection

2.3 Successful Logon After Failed Attempts (Successful Breach)

2.4 Logon Type Analysis (Sentinel)


🗺️ Phase 3: Lateral Movement Detection

3.1 Network Logon Chain Analysis (Defender XDR)

3.2 Lateral Movement with Process Correlation

3.3 Administrative Reconnaissance Detection

3.4 Pass-the-Hash Detection (Sentinel)


🚨 Phase 4: Privilege Escalation & Admin Activity

4.1 Detect New Admin Rights Assignments

4.2 Explicit Credential Usage (RunAs)

4.3 Service Account Interactive Logon Detection


🌍 Phase 5: Azure AD / Cloud Authentication Analysis

5.1 Comprehensive Azure AD Sign-in Analysis

5.2 Impossible Travel Detection

5.3 Anomalous Application Access

5.4 Conditional Access Policy Failures


🎯 Phase 6: Behavioral Analytics (UEBA)

6.1 User Risk Score Analysis

6.2 Peer Group Comparison


🔧 Phase 7: Advanced Hunting Techniques

7.1 Multi-Stage Attack Detection

7.2 Account Reconnaissance and Exploitation

7.3 Data Exfiltration via Compromised Account


📊 Phase 8: Workbooks and Dashboards

8.1 Account Usage Overview Dashboard (KQL for Workbook)

8.2 Real-Time Monitoring Query


🚀 Phase 9: Automated Response Queries

9.1 Automated Threat Hunting - Scheduled Query

9.2 Incident Creation Query (For Automation Rules)


🎓 Pro Tips and Best Practices

Query Optimization

Time Range Best Practices

Null Handling

Summarization Tips


🔔 Alert Rules (Analytic Rules)

High-Priority Alert: Admin Account Brute Force Success

Alert: Impossible Travel Detected


📚 Investigation Playbook Cheatsheet

Quick Investigation Steps

  1. Identify Account Type

  1. Get Recent Activity Summary

  1. Check for Failed Logons

  1. Review Recent Admin Activity

  1. Check Lateral Movement


🔗 Integration with SOAR

Logic App/Playbook Trigger Query


Remember: Always validate queries in a test environment first. Adjust thresholds based on your organisation's baseline. Document all customisations.

Last updated