🔏
RootGuard
HomeSOC OperationsIncident ResponseWindows ForensicsLinux ForensicsKQL Investigations
  • Welcome
    • RootGuard
      • Who Am I?
        • Professional Profile
  • Resources Hub
    • Blogs
      • Articles
        • Safeguarding SMEs: The Strategic Importance of a Security Operations Center (SOC)
      • Posts
        • Roadmap to Becoming a Cybersecurity Specialist
        • Starting a Career in Cybersecurity
        • A Guide to Landing Your First Cybersecurity Analyst Role
        • Moving from Intermediate to Expert Incident Responder
  • SOC Operations
    • Introduction
      • Development Resources
        • SOC Analysts Roadmap
        • Becoming A SOC Analyst
        • SOC Analysts Prep Interview Questions
    • Essential Skills
      • Critical Windows EventIDs to Monitor
    • Junior Analyst Skills
      • Splunk Use Cases
      • KQL Use Cases
        • Reconnaissance (TA0043)
        • Initial Access (TA0001)
        • Execution (TA0002)
        • Persistence (TA0003)
        • Privilege Escalation (TA0004)
        • Defence Evasion (TA0005)
        • Credential Access (TA0006)
        • Discovery (TA0007)
        • Lateral Movement (TA0008)
        • Collection (TA0009)
        • Command and Control (TA0011)
        • Exfiltration (TA0010)
        • Impact (TA0040)
      • Investigating Common Attacks
        • Domain Dominance Attacks - Detection & Analysis
        • Investigating a Suspected AD FS Distributed Key Management (DKM) Attack
        • Authentication From Suspicious DeviceName
        • Identifying Interactive or RemoteInteractive Session From Service Account
        • Identifying Split or Part Archive File Transfers
        • Detect Potential Cleartext Credentials in Command Line
        • Detecting Command Line Interpreters Launched via Scheduled Tasks
        • Detecting Files Containing Potentially Sensitive Data
        • Detecting DeviceNetworkEvents From Windows Processes and Domains by TLD
        • Detecting Silent cmd.exe Execution With Redirected STDERR & STDOUT
        • Detecting Low Prevalence DLL Loaded From Process In User Downloads Directory
        • Detecting Virtual Drive Mounted From Archive
        • Identify Execution of Script From User's Downloads Folder
        • Identify Potential RDP Tunneled Sessions
        • Identify Instances of PowerShell Invoke-WebRequest, IWR or Net.WebClient
        • Identify Processes Launched by PowerShell Remoting (WSMProvHost.exe)
        • Detect DeviceNetworkEvents for LOLBAS with Download or Upload Functions
        • Detect Execution of PSEXESVC via Remote Systems
        • Identify Suspicious String in Service Creation ImagePath
        • Identify File with Double Extensions
        • Detect Potential Cleartext Credentials in Commandline
        • Detect When Large Number of Files Downloaded From OneDrive or SharePoint
        • Identify and Investigate Phishing Attacks with KQL
      • PowerShell for SecOps
        • Powershell Remoting
        • Reconnaissance Discovery
        • Initial Access Discovery
        • Execution Discovery
        • Persistence Discovery
        • Privilege Escalation Discovery
        • Defence Evasion Discovery
        • Credential Access Discovery
        • Discovery
        • Lateral Movement Discovery
        • Collection Discovery
        • Command & Control (C2) Discovery
        • Exfiltration Discovery
        • Impact Discovery
      • Packet Analysis (pcap)
        • Tcpdump
        • Tcpdump (Intermediate)
        • Tshark
        • Ngrep
      • Investigating Suspicious Emails Using KQL
    • Intermediate and Advanced Skills
      • Investigate Using MITRE ATT&CK Methodology
        • Reconnaissance (TA0043) Techniques
        • Resource Development (TA0042) Techniques
        • Initial Access (TA0001) Techniques
        • Command Execution (TA0002) Techniques
        • Persistence (TA0003) Techniques
        • Privilege Escalation (TA0004) Techniques
        • Defence Evasion (TA0005) Techniques
        • Credential Access (TA0006) Techniques
        • Discovery (TA0007) Techniques
        • Lateral Movement (TA0008) Techniques
        • Collection (TA0009) Techniques
        • Command and Control (C2) (TA0011) Techniques
        • Exfiltration (TA0010) Techniques
        • Impact (TA0040) Techniques
    • Vulnerability Management
    • Malware Analysis
  • DFIR
    • Incident Response
      • Incident Triage
        • Triage Types and Processes
        • PowerShell for Detection and Analysis
          • Malware or Compromise Investigation
          • Lateral Movement Discovery
        • Registry Analysis
        • Sysinternals Intrusion Analysis
        • PowerShell Intrusion Analysis
        • Velociraptor Intrusion Analysis
        • Zimmerman Tools Intrusion Analysis
      • KAPE Artifacts Analysis
      • Velociraptor Artifacts Analysis
      • Using The Unified Kill Chain Model to Analyse Individual Cyber Attacks
        • Phase 1 - Gaining an Initial Foothold
          • Gaining Access to the Network
          • Establishing a Foothold
          • Network Discovery
      • Response Strategies
        • Privilege Escalation Assessment
        • Command and Control Assessment
        • Command Execution Assessment
        • Defence Evasion Assessment
        • Detection Assessment
        • Discovery Assessment
        • Exfiltration Assessment
        • Initial Access Assessment
        • Initial Impact Assessment Techniques
        • Lateral Movement Assessment
        • Persistence Assessment
    • Windows Forensics
      • Evidence of Execution
      • Window Artifact Analysis
        • Account Usage
        • User Activity Tracking (Event Logs)
        • Program Execution
        • File and Folder Opening
        • File Download
        • Browser Usage
        • Deleted File or File Knowledge
        • External Device & USB Usage
    • Linux Forensics
      • Linux Commandline Basics
      • Host Compromise Assessment
    • KQL for Defender & Sentinel
      • MDO (Office)
      • MDI (Identity)
      • MDE (Endpoint)
    • Memory Forensics
      • Memory Forensics (Volatility 3)
    • Playbooks
      • First Responder DFIR Playbook
        • Device Isolation
        • Evidence Collection
          • Acquire Triage Image Using KAPE
          • Acquire Triage Data Using Velociraptor
          • Acquire Triage Data Using Powershell
          • Acquire Triage Memory Image
          • Acquire Image Using FTK
          • AXIOM Cyber Data Collection
        • Windows Forensic Artefacts
          • Application Execution
          • File & Folder Knowledge
          • External Device Usage
          • Network Activity
          • Windows Event Logs
        • Initial Analysis
          • Memory Analysis (Vol 3)
          • Axiom Cyber Examiner
  • Detection Engineering
    • AD Attack Detections & Mitigations
      • Kerberoasting
      • Authentication Server Response (AS-REP) Roasting
      • Password Spraying
      • MachineAccountQuota Compromise
      • Unconstrained Delegation
      • Password in Group Policy Preferences (GPP) Compromise
      • Active Directory Certificate Services (AD CS) Compromise
      • Golden Certificate
      • DCSync
      • Dumping ntds.dit
      • Golden Ticket
      • Silver Ticket
      • Golden Security Assertion Markup Language (SAML)
      • Microsoft Entra Connect Compromise
      • One-way Domain Trust Bypass
      • Security Identifier (SID) History Compromise
      • Skeleton Key
      • Active Directory Security Controls
      • Active Directory Events for Detecting Compromise
    • Attack Triage Playbooks (KQL Triage)
      • Windows Malware Detection Playbook
      • Linux Host Intrusion Detection Playbook (CLI)
      • Linux Intrusion Detection Playbook
      • Large-Scale Compromise Detection Playbook
      • Ransomware Detection Playbook
      • Phishing Email Compromise Detection Playbook
      • Scam Detection Playbook
      • Customer Phishing Detection Playbook
      • Insider Abuse Detection Playbook
      • Information Leakage Detection Playbook
      • Social Engineering Detection Playbook
      • Malicious Network Behaviour Detection Playbook
      • Windows Intrusion Detection Playbook
      • Vulnerability Detection Playbook
      • Business Email Compromise Detection Playbook
    • Process Execution (KQL Triage)
    • Threat Hunting
      • Hunting Ransomware Indicators
      • Hunting With KQL
        • Detecting Malware Infection (MITRE ATT&CK: T1566, T1059)
        • Discovery Activities (MITRE ATT&CK: T1016, T1083, T1046)
        • Credential Theft (MITRE ATT&CK: T1003, T1078)
        • Lateral Movement (MITRE ATT&CK: T1076, T1021)
        • Data Theft (MITRE ATT&CK: T1041, T1071)
        • Detecting CommandLine Executions (MITRE ATT&CK: T1059)
        • Windows Security Logs (Identity and Logon Activities)
      • Hunting With Splunk
Powered by GitBook
On this page
Edit on GitHub
  1. SOC Operations
  2. Junior Analyst Skills
  3. Investigating Common Attacks

Investigating a Suspected AD FS Distributed Key Management (DKM) Attack

Investigating a suspected AD FS Distributed Key Management (DKM) attack on an endpoint using KQL (Kusto Query Language) and Microsoft Defender.


Step 1: Understand the Attack Context

The AD FS DKM key is crucial for securing sensitive AD FS configuration data. Attackers targeting this key often aim to compromise AD FS configurations for lateral movement, privilege escalation, or data exfiltration.

Common TTPs (Tactics, Techniques, and Procedures) include:

  • Using tools like Mimikatz or PowerShell to dump sensitive keys.

  • Accessing AD FS-related directories (%ADFS_DATA%\Keys).

  • Privilege escalation or credential theft for unauthorised access.


Step 2: Queries for Microsoft Defender Using KQL

Below are some KQL queries and an approach tailored to identify suspicious activities associated with AD FS DKM attacks.


1. File Access to AD FS DKM Key Directory

Purpose: Detect unauthorized file access attempts to AD FS DKM key directories.

DeviceFileEvents
| where FolderPath contains "ADFS_DATA" and FileName endswith ".pfx"
| where ActionType in ("FileAccessed", "FileModified")
| project Timestamp, DeviceName, FolderPath, FileName, ActionType, InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName
| order by Timestamp desc

//Expanded Query
DeviceFileEvents
| where FolderPath contains "ADFS_DATA" and FileName endswith ".pfx"
| where ActionType in ("FileAccessed", "FileModified")
| project Timestamp, DeviceName, FolderPath, FileName, ActionType, InitiatingProcessFileName, InitiatingProcessCommandLine
| join kind=leftouter (DeviceProcessEvents
    | project DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName, InitiatingProcessAccountDomain
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
| project Timestamp, DeviceName, FolderPath, FileName, ActionType, InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName, InitiatingProcessAccountDomain
| order by Timestamp desc

2. Process Interacting with DKM-Related Files

Purpose: Identify processes attempting to interact with AD FS-related files.

DeviceProcessEvents
| where FileName contains "adfs" or FolderPath contains "ADFS_DATA"
| where InitiatingProcessFileName has_any ("mimikatz.exe", "adfind.exe", "powershell.exe")
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, AccountName
| order by Timestamp desc

//Expanded Query
DeviceProcessEvents
| where FileName contains "adfs" or FolderPath contains "ADFS_DATA"
| where InitiatingProcessFileName has_any ("mimikatz.exe", "adfind.exe", "powershell.exe")
| extend AccountDomain = split(AccountName, "\\")[0], AccountUser = split(AccountName, "\\")[1]
| join kind=leftouter (DeviceNetworkEvents
    | project DeviceName, RemoteIP, RemotePort, InitiatingProcessFileName, InitiatingProcessCommandLine
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, AccountDomain, AccountUser, RemoteIP, RemotePort
| order by Timestamp desc

3. Suspicious PowerShell Commands

Purpose: Detect PowerShell commands targeting AD FS or attempting to export sensitive configurations.

DeviceProcessEvents
| where InitiatingProcessFileName == "powershell.exe"
| where ProcessCommandLine has_any ("ADFS", "export", "keys", "Get-AdfsConfiguration")
| project Timestamp, DeviceName, ProcessCommandLine, AccountName, InitiatingProcessFileName
| order by Timestamp desc

// Expanded Query
DeviceProcessEvents
| where InitiatingProcessFileName == "powershell.exe"
| where ProcessCommandLine has_any ("ADFS", "export", "keys", "Get-AdfsConfiguration")
| extend AccountDomain = split(AccountName, "\\")[0], AccountUser = split(AccountName, "\\")[1]
| join kind=leftouter (DeviceNetworkEvents
    | project DeviceName, RemoteIP, RemotePort, InitiatingProcessFileName, InitiatingProcessCommandLine
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
| project Timestamp, DeviceName, ProcessCommandLine, AccountDomain, AccountUser, RemoteIP, RemotePort, InitiatingProcessFileName
| order by Timestamp desc

4. Privilege Escalation or Credential Dumping Attempts

Purpose: Spot attempts to dump credentials or escalate privileges using known tools.

DeviceProcessEvents
| where InitiatingProcessFileName in ("mimikatz.exe", "adfind.exe", "dsquery.exe")
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, AccountName
| order by Timestamp desc

// Expanded Query
DeviceProcessEvents
| where InitiatingProcessFileName in ("mimikatz.exe", "adfind.exe", "dsquery.exe")
| extend AccountDomain = split(AccountName, "\\")[0], AccountUser = split(AccountName, "\\")[1]
| join kind=leftouter (DeviceNetworkEvents
    | project DeviceName, RemoteIP, RemotePort, InitiatingProcessFileName, InitiatingProcessCommandLine
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, AccountDomain, AccountUser, RemoteIP, RemotePort
| order by Timestamp desc

5. Elevated Access Logon Events

Purpose: Highlight unusual elevated access that might indicate compromised credentials.

DeviceLogonEvents
| where LogonType in ("Elevated", "Interactive")
| where AccountName != "SYSTEM"
| project Timestamp, AccountName, DeviceName, LogonType, InitiatingProcessFileName, InitiatingProcessCommandLine
| order by Timestamp desc

//Expanded Query
// Filter DeviceProcessEvents for specific files and commands
DeviceProcessEvents
| where InitiatingProcessFileName in ("mimikatz.exe", "adfind.exe", "dsquery.exe")
// Extend AccountDomain and AccountUser from AccountName
| extend AccountDomain = tostring(split(AccountName, "\\")[0]), AccountUser = tostring(split(AccountName, "\\")[1])
// Join with DeviceNetworkEvents to enrich data with network information
| join kind=leftouter (
    DeviceNetworkEvents
    | project DeviceName, RemoteIP, RemotePort, InitiatingProcessFileName, InitiatingProcessCommandLine
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
// Project relevant columns
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, AccountDomain, AccountUser, RemoteIP, RemotePort
// Filter events within the last 30 days
| where Timestamp >= ago(30d)
// Summarize results to get a quick overview
| summarize Count = count() by Timestamp, DeviceName, InitiatingProcessFileName, AccountDomain, AccountUser
// Order by Timestamp in descending order
| order by Timestamp desc

6. Unusual Network Connections

Purpose: Uncover potential outbound connections for data exfiltration or communication with Command and Control (C2) servers.

DeviceNetworkEvents
| where InitiatingProcessFileName has_any ("powershell.exe", "mimikatz.exe")
| where RemoteUrl != "" or isnotempty(RemoteIP)
| project Timestamp, DeviceName, InitiatingProcessFileName, RemoteUrl, RemoteIP, RemotePort, InitiatingProcessAccountName
| order by Timestamp desc

// Expanded Query
// Filter DeviceNetworkEvents for specific processes and network activity
DeviceNetworkEvents
| where InitiatingProcessFileName has_any ("powershell.exe", "mimikatz.exe")
| where RemoteUrl != "" or isnotempty(RemoteIP)
// Extend AccountDomain and AccountUser from InitiatingProcessAccountName
| extend AccountDomain = tostring(split(InitiatingProcessAccountName, "\\")[0]), AccountUser = tostring(split(InitiatingProcessAccountName, "\\")[1])
// Join with DeviceProcessEvents to enrich data with process information
| join kind=leftouter (
    DeviceProcessEvents
    | project DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, AccountName
) on $left.DeviceName == $right.DeviceName and $left.InitiatingProcessFileName == $right.InitiatingProcessFileName
// Project relevant columns
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, RemoteUrl, RemoteIP, RemotePort, AccountDomain, AccountUser
// Filter events within the last 30 days
| where Timestamp >= ago(30d)
// Summarize results to get a quick overview
| summarize Count = count() by Timestamp, DeviceName, InitiatingProcessFileName, AccountDomain, AccountUser
// Order by Timestamp in descending order
| order by Timestamp desc

7. DKM File Access Correlated with User Accounts

Purpose: Correlate DKM key access with user logon events.

DeviceFileEvents
| where FolderPath contains "ADFS_DATA" and FileName endswith ".pfx"
| project Timestamp, DeviceName, FolderPath, FileName, ActionType
| join kind=inner (
    DeviceLogonEvents
    | project AccountName, Timestamp, DeviceName, LogonType
) on DeviceName
| project Timestamp, AccountName, DeviceName, FolderPath, FileName, ActionType, LogonType
| order by Timestamp desc

//Expanded Query
// Filter DeviceFileEvents for specific folder and file type
DeviceFileEvents
| where FolderPath contains "ADFS_DATA" and FileName endswith ".pfx"
// Join with DeviceLogonEvents to enrich data with logon information
| join kind=inner (
    DeviceLogonEvents
    | project AccountName, Timestamp, DeviceName, LogonType
) on $left.DeviceName == $right.DeviceName
// Project relevant columns
| project Timestamp, DeviceName, FolderPath, FileName, ActionType, LogonType, AccountName
// Filter events within the last 30 days
| where Timestamp >= ago(30d)
// Summarize results to get a quick overview
| summarize Count = count() by Timestamp, DeviceName, AccountName, LogonType
// Order by Timestamp in descending order
| order by Timestamp desc

Step 3: Investigation in Microsoft Defender

  1. Use the Advanced Hunting Tool:

    • Navigate to Microsoft Defender Security Center > Advanced Hunting.

    • Run the KQL queries above to identify suspicious activities.

  2. Analyse Alerts:

    • Look for triggered alerts on tools like Mimikatz, AD FS-related processes, or privilege escalation.

    • Review correlated incidents for further insights.

  3. Investigate Incident Timeline:

    • Examine the sequence of events to determine:

      • When the attack started.

      • How the attacker accessed the AD FS system.

      • Whether there was lateral movement or data exfiltration.


Step 4: Mitigation Steps

  • Isolate the Compromised Endpoint:

    • Use Defender to isolate the endpoint from the network.

  • Audit and Rotate the DKM Keys:

    • Regenerate the DKM key if compromise is suspected.

    • Follow Microsoft's guidance for secure key management.

  • Patch and Harden AD FS Servers:

    • Apply the latest patches and updates to AD FS servers.

    • Implement stricter access controls and monitoring.

  • Monitor and Validate Security Controls:

    • Enable logging for AD FS and monitor suspicious activities.

    • Use threat intelligence feeds to update IoC detections.


Step 5: Post-Incident Actions

  • Review Lessons Learned:

    • Conduct a post-mortem to understand weaknesses in your AD FS deployment.

    • Train staff on detecting and preventing AD FS-related threats.

  • Implement Enhanced Monitoring:

    • Use continuous monitoring for sensitive AD FS operations.

    • Integrate Defender alerts with SIEM for real-time analysis.

PreviousDomain Dominance Attacks - Detection & AnalysisNextAuthentication From Suspicious DeviceName

Last updated 4 months ago