Process Execution (KQL Triage)
Investigating suspicious process execution using Windows Security Logs, Microsoft Defender XDR, and KQL (Kusto Query Language) in Microsoft Sentinel. Below are extensive KQL query examples to help you detect, analyse, and respond to malicious activity effectively.
Phase 1: Understand Windows Event Logs & KQL Basics
Objective: Gain foundational knowledge of Windows Event Logs and KQL for querying logs in Microsoft Sentinel.
Key Actions:
Learn the Basics of Windows Event Logs:
Log Types:
Security Logs: Track authentication, privilege changes, and access control.
System Logs: Record system-level events like service startups and hardware issues.
Application Logs: Log application-specific events.
Event IDs:
Process Creation: Event ID
4688
(native Windows logging).Account Logon: Event ID
4624
(successful logon) and4625
(failed logon).File Access: Event ID
4663
(file access attempts).
Understand KQL in Microsoft Sentinel:
Learn how to write queries in KQL to filter, analyse, and visualise data in Sentinel.
Use the Schema Explorer in Sentinel to explore available tables (e.g.,
SecurityEvent
,DeviceEvents
).
Set Up a Lab Environment:
Use Windows 10/11 or Windows Server in a virtual machine (e.g., VirtualBox, VMware).
Simulate malicious activity using tools like Atomic Red Team, Cobalt Strike, or Metasploit.
Connect your lab environment to Microsoft Sentinel for log ingestion.
Basic KQL Queries:
Example: Query all process creation events from Security Logs:
Example: Query Defender XDR process creation events:
Phase 2: Detect Suspicious Process Execution
Objective: Use KQL to detect suspicious process execution patterns in Sentinel and Defender XDR.
Key Actions:
Focus on Key Event IDs:
Process Creation: Event ID
4688
(native Windows logging).Network Connections: Use Defender XDR logs (
DeviceNetworkEvents
) to track network activity.
Write Advanced KQL Queries:
Detect Unusual Parent-Child Relationships:
Look for
explorer.exe
spawningpowershell.exe
:
Detect Suspicious Command-Line Arguments:
Look for encoded PowerShell commands:
Detect Processes in Unexpected Locations:
Look for processes running from
AppData
orUsers\Public:
Detect Lateral Movement via PsExec:
Look for
PsExec
usage, which is often used for lateral movement:
Detect Scheduled Task Creation:
Look for scheduled tasks being created:
Detect Remote Logons:
Look for remote logons (Event ID
4624
with Logon Type10
):
Correlate Events with Defender XDR:
Combine process creation logs with Defender XDR logs to identify suspicious outbound traffic:
Use Defender XDR for Detection:
Query Defender XDR logs for suspicious process execution:
Detect suspicious file modifications:
Phase 3: Investigate and Analyse
Objective: Perform in-depth analysis of suspicious process execution.
Key Actions:
Extract IOCs (Indicators of Compromise):
Extract file paths, command-line arguments, IP addresses, and user accounts from logs:
Map Activity to MITRE ATT&CK:
Map suspicious PowerShell activity to Execution (T1059):
Reconstruct the Attack Chain:
Build a timeline of events by correlating process creation, network connections, and file modifications:
Detect Persistence Mechanisms:
Look for registry modifications that could indicate persistence:
Detect Credential Dumping:
Look for processes accessing sensitive files like
lsass.exe
:
Phase 4: Respond and Mitigate
Objective: Automate detection and response workflows using KQL in Sentinel and Defender XDR.
Key Actions:
Automate Detection:
Create detection rules in Sentinel for suspicious process execution:
Develop Playbooks:
Use Azure Logic Apps to automate responses:
Example: Isolate a device when suspicious PowerShell activity is detected:
Leverage Threat Intelligence:
Enrich logs with threat intelligence feeds:
Phase 5: Continuous Monitoring & Improvement
Objective: Continuously monitor and improve detection capabilities.
Key Actions:
Review and Update Queries:
Regularly review KQL queries to adapt to evolving threats.
Example: Add new IOCs or behaviours to existing queries.
Leverage Defender XDR Analytics:
Use Defender XDR’s built-in analytics to detect advanced threats and correlate them with custom KQL queries.
Contribute to the Community:
Share your KQL queries, playbooks, and findings with the cybersecurity community.
Final Thoughts
While there are different approaches to investigating suspicious process execution using Windows Security Logs, Microsoft Sentinel, and Defender XDR with KQL, by leveraging the KQL query examples provided, you’ll be able to detect, analyse, and respond to malicious activity effectively.
Last updated