Detect Active Directory Attacks with Wazuh & Sysmon

July 29, 2024 15 min read Threat Detection • Wazuh • Sysmon • AD Security

Learn how to integrate Sysmon telemetry with Wazuh to detect and investigate Active Directory attacks. This guide covers Sysmon deployment, agent configuration, and real-time threat detection across your AD infrastructure.

This guide is adapted from the official Wazuh blog: How to Detect Active Directory Attacks with Wazuh - Part 2

Prerequisites

Before deploying Sysmon and integrating with Wazuh, ensure:

Preparation: Download Required Tools

1. Download Sysmon

Sysmon is a Windows system service and device driver that monitors system activity and logs it to the Windows event log. Download the latest version from Microsoft Sysinternals:

2. Download Sysmon Configuration

A well-crafted Sysmon configuration file is essential for comprehensive monitoring. Use the community-maintained SwiftOnSecurity configuration:

3. Organize Files

Create a directory and place both files together for easy installation:

C:\Sysmon\
  ├── Sysmon64.exe
  └── sysmonconfig.xml

Installation: Deploy Sysmon

Step 1: Open PowerShell as Administrator

Right-click PowerShell and select "Run as Administrator", then navigate to your Sysmon directory:

cd C:\Sysmon

Step 2: Install Sysmon with Configuration

Execute the following command to install Sysmon as a Windows service with the security-focused configuration:

.\Sysmon64.exe -i .\sysmonconfig.xml -accepteula

What this command does:

Sysmon installation in PowerShell

Sysmon installation command executed successfully

Verification: Confirm Sysmon is Running

Check the Sysmon Service

Verify that Sysmon has been installed as a Windows service:

Get-Service -Name "Sysmon64"

You should see output indicating the service is running:

Status   Name             DisplayName
------   ----             -----------
Running  Sysmon64         System Monitor

Check Event Viewer for Sysmon Logs

Navigate to Event Viewer and verify that Sysmon is logging activity:

Sysmon operational logs in Event Viewer

Sysmon events captured in Event Viewer's Operational channel

Detailed Sysmon event logs

Detailed process creation and system events from Sysmon

Wazuh Agent Configuration

Configure Wazuh to Ingest Sysmon Logs

To collect Sysmon logs, you need to configure the Wazuh agent to monitor the Sysmon operational event log channel.

Step 1: Locate the Wazuh Configuration File

Open the Wazuh agent configuration file:

C:\ProgramData\ossec\ossec.conf

Step 2: Add Sysmon Localfile Configuration

Add the following configuration block to monitor the Microsoft-Windows-Sysmon/Operational channel. Insert this within the <ossec_config> tags:

<localfile>
    <location>Microsoft-Windows-Sysmon/Operational</location>
    <log_format>eventchannel</log_format>
</localfile>

What this configuration does:

Wazuh agent configuration with Sysmon

Wazuh agent ossec.conf file updated with Sysmon monitoring

Step 3: Restart the Wazuh Service

Restart the Wazuh agent service to apply the configuration changes:

Restart-Service -Name "Wazuh"

Or manually restart via Services:

Testing: Generate Sysmon Activity

Create Observable Process Activity

Now let's generate some activity for Sysmon to capture and Wazuh to ingest. Open PowerShell and run commands that will be logged:

PowerShell commands triggering Sysmon events

Executing PowerShell commands that trigger Sysmon event logging

Trigger a Process Creation Event

Execute this command to spawn a cmd.exe process, which will be captured by Sysmon as Event ID 1 (Process Creation):

Start-Process cmd

This simple command will create observable telemetry that Sysmon logs and Wazuh can ingest.

Verification: Wazuh Ingesting Sysmon Logs

Check the Wazuh Manager to confirm it's receiving and processing Sysmon logs from your endpoint.

Wazuh dashboard showing ingested Sysmon logs

Wazuh dashboard displaying process creation events from Sysmon

Detailed Sysmon event analysis in Wazuh

Detailed breakdown of a Sysmon Event ID 1 (Process Creation) in Wazuh

What's Next: Building Detection Rules

Now that Sysmon is integrated with Wazuh, you can build powerful detection rules for:

Pro Tips

Resources

Have questions or insights on AD security? Reach out via email or connect on LinkedIn.

All Articles Next Lab: Wazuh in Proxmox