# Tracking Mimikatz Activity with Wazuh & Sysmon Logs

## **🔧 Configuring Wazuh to Ingest Sysmon Logs**

### **Step 1: Accessing and Editing Wazuh Configuration**

1. **Locate Wazuh Configuration File**
   * Open `Program Files (x86)`.
   * Find the `ossec.conf` file inside the `wazuh-agent` folder.
   * Right-click the file and open it with Notepad (admin privileges might be needed).<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FSeaEMDkrcKYkSOjTW4ep%2F2.png?alt=media&#x26;token=eae8dd56-9d3a-4df4-b7a1-eb162bcefe66" alt="" width="563"><figcaption></figcaption></figure>
2. **Modify Log Analysis Settings**
   * Inside the configuration file, locate the `log analysis` section.
3. **Enable Sysmon Logging**
   * Sysmon must be installed (done in [part 1](https://osamaa.gitbook.io/osama_homepage/cybersecurity-soc-analyst-labs/automation-lab-home-project/broken-reference)).
   * Modify `ossec.conf` to ingest Sysmon logs.
   * Get Sysmon’s channel name from the Windows Event Viewer:
     * Open Event Viewer.
     * Navigate to Applications and Services → Microsoft → Windows → Sysmon.
     * Right-click **Operational**, select **Properties**, and copy the **full name**.
   * Paste this name into the `ossec.conf` configuration under the correct log location.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FceBDlFd7h5OpFkKlhLZa%2F2.png?alt=media&#x26;token=686145a6-675e-494f-87fb-aadcdf79a32b" alt=""><figcaption></figcaption></figure>
4. **Remove Unnecessary Log Sources**
   * For testing, remove other log sources (`application`, `security`, `system`) to focus on Sysmon.
   * Save the configuration and replace the existing file.

### **Step 2: Restarting Wazuh Agent**

* Open **Windows Services**.
* Restart the **Wazuh Agent** service.<br>

  <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2Fi479YE87dfjUigDeDySc%2Fimage.png?alt=media&#x26;token=07c0bfee-8e22-4a92-b47b-9b55e606d6f4" alt="" width="563"><figcaption></figcaption></figure>
* **This step is required whenever configuration changes are made.**

### Step 3: Verify Sysmon Logs in Wazuh Dashboard

1. **Log in to the Wazuh Dashboard**
   * Open your browser and go to:\
     `https://<Wazuh_Server_IP>`
   * Sign in with your Wazuh credentials.
2. **Go to the "Discover" Section**
   * In Wazuh, click on **Discover** from the left panel.
3. **Select the Correct Index**
   * In the search bar, choose:\
     `wazuh-alerts-*`
4. **Filter for Sysmon Events**
   * Type **"sysmon"** in the search bar and press **Enter**.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2Fy7w75fNMGYaDKRLlY0j7%2Fimage.png?alt=media&#x26;token=4f2103ed-4b18-4335-a0b6-e608e0b5aaef" alt=""><figcaption></figcaption></figure>

## **🚀 Using Mimikatz for Security Testing**

#### 🔹 What is Mimikatz?

Mimikatz is a powerful post-exploitation tool used to extract passwords, hashes, and authentication tokens from Windows systems. It’s commonly used by security professionals for **penetration testing** and by attackers for **credential theft**.

#### 🔹 What Can Mimikatz Do?

✅ Dump plaintext passwords from memory.\
✅ Extract NTLM hashes for offline cracking.\
✅ Pass-the-Hash & Pass-the-Ticket attacks.\
✅ Extract Kerberos tickets (Golden Ticket, Silver Ticket).\
✅ Bypass Windows authentication protections.

***

### 👉 Running Mimikatz for Testing

1. **Disable Windows Defender (for testing purposes only)**
   * Open **Windows Security**.
   * Go to **Virus & threat protection** → **Manage settings**.
   * Add an **exclusion** for the **Downloads folder**.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FjbHKalQmppVLwDIVmU6o%2F2.png?alt=media&#x26;token=cadafb31-1cad-4809-a2f5-20876c1a48c6" alt=""><figcaption></figcaption></figure>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FI08EUpMjhghSuAmHYKm6%2F2.png?alt=media&#x26;token=6cbb4977-1896-4808-8972-0bfb5d2b9458" alt=""><figcaption></figcaption></figure>

2. **Download Mimikatz from**  :link:[GitHub Repository](https://github.com/ParrotSec/mimikatz)**.**  <br>

   <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FNNbV9ktjBp9BZ6LLnbXN%2F2.png?alt=media&#x26;token=0617a3ac-1a4b-403a-9b8a-df6e2e292562" alt=""><figcaption></figcaption></figure>

   * Some browsers (like Edge) may block Mimikatz.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FXhXsUiIc0UhKWEwOr0kS%2F2.png?alt=media&#x26;token=53036224-c33f-4c80-bfb4-121eee294680" alt="" width="341"><figcaption></figcaption></figure>
   * If you are using (Chrome) Disable Chrome’s security settings if needed:
     * Go to **Privacy & Security** → **Security**.
     * Turn off **Safe Browsing** (No Protection).
   * Click Keep and Download Mimikatz.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FzaqRqUdAaRddyaytuRdy%2Fimage.png?alt=media&#x26;token=853f9a7d-71a4-4c6b-b576-0db1560053fe" alt=""><figcaption></figcaption></figure>

     Now, let's execute **`mimikatz.exe`**, then review the **Wazuh dashboard** for detections or alerts.

   <br>

3. **Run Mimikatz in PowerShell**
   * Open **PowerShell as Administrator**.
   * Navigate to the extracted Mimikatz folder.
   * Run `mimikatz.exe`.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2Fg5mlAzB4WZH4dj3Woe22%2Fimage.png?alt=media&#x26;token=dbd0874e-cd99-4616-a502-193d624791f5" alt=""><figcaption></figcaption></figure>

4. **Checking Wazuh for Alerts**
   * Open the **Wazuh dashboard**.
   * Search for **Sysmon or Mimiktaz events** in the **alerts index**.
   * If no events appear immediately, wait a little or **check if Wazuh rules are triggering correctly**.\ <br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2F882AtdW6hbm8tGIAS5sV%2F3.png?alt=media&#x26;token=8841f581-c5ce-44b8-9758-07bcc10dc0c2" alt=""><figcaption></figcaption></figure>

5. #### **Configuring Wazuh to Log All Events**
   * **Modify `ossec.conf` on Wazuh Manager**
     * Create a backup of the `ossec.conf` file.

       ```bash
       cp /var/ossec/etc/ossec.conf ~/ossec_backup.conf
       ```
     * Open `ossec.conf` and find `logall` and `logall_json` settings.<br>

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FB9ti1wqFtl7o0wdYUX51%2F3.png?alt=media&#x26;token=86e16a34-d17c-49c4-8871-253744fe3e81" alt="" width="563"><figcaption></figcaption></figure>
     * Change both values from `no` to `yes`.
       * **`<logall>   yes`** → Logs everything (useful for debugging, but large logs).
       * **`<logall_json>   yes`** → Logs everything in JSON format (structured but more storage).
     * Save and exit.

   * **Restart Wazuh Manager**
     * Use `systemctl restart wazuh-manager` to apply changes.

   * **Enable Filebeat to Process Archives**
     * Edit the **Filebeat configuration** file (`filebeat.yml`).
     * Locate `archives_enabled: false` and change it to `true`.<br>

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FC4frHDvPpMT11L6aIuvf%2F3.png?alt=media&#x26;token=8249dc56-c5e7-4fbf-a837-36cab2e35167" alt="" width="563"><figcaption><p>It lets Filebeat process archived logs for analysis and auditing.</p></figcaption></figure>
     * Save and restart Filebeat (`systemctl restart filebeat`).\ <br>

   * **Create an Index for Archives in Wazuh Dashboard**
     * Open **Dashboards Management** in Wazuh.

     * Go to **Index patterns**.

     * Name it `wazuh-archives-*` and click on Next step.\
       &#x20;

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FApyihRiqhTqmhH6Pqf6V%2F3.png?alt=media&#x26;token=36bc5518-977e-4faf-972e-600f6ed50eb8" alt="" width="563"><figcaption></figcaption></figure>

     * select **timestamp** at the bottom as the time field.

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FFRAhcCfZ4eqImyclRUND%2F3.png?alt=media&#x26;token=db97cfb5-d545-4d6e-8693-709472291034" alt="" width="563"><figcaption></figcaption></figure>

     * Now, let's head to Discover page to check our index.<br>

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FaEMt2lfIRAuAIzin5FVI%2F3.png?alt=media&#x26;token=e04448c6-9606-499b-b00a-19d68bd35bba" alt="" width="563"><figcaption></figcaption></figure>

   * **Verify Events in the Archive**
     * Check the archive logs (`/var/ossec/logs/archives/`).
     * Run `cat archives.json | grep -i mimikatz` to confirm logs are being stored.<br>

       <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FgXz5ABWdHLm5TNPITN0i%2Fimage.png?alt=media&#x26;token=8301a745-8526-4990-871d-4edecbb83558" alt=""><figcaption></figcaption></figure>

   * **If you got nothing, it means no logs were recorded and we must execute Mimikatz again to generate new logs and verify if they appear in the archive.**<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FVhdm0vS1WRGIkVaIhRzZ%2Fimage.png?alt=media&#x26;token=134bc1c9-94e6-412f-a61e-9b2e22bbf497" alt=""><figcaption></figcaption></figure>

   * Now return to Discover page to verify Mimiktaz logs.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2F2GoDQlMzXcuYNGjQf8GN%2F4.png?alt=media&#x26;token=bf95cdef-9228-4404-b3ea-0c2858180939" alt=""><figcaption></figcaption></figure>

   * Also, we can check the archive logs agian.<br>

     <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2F7fL56OHsEsrUXzfLtyLT%2Fimage.png?alt=media&#x26;token=2cf265b1-99d4-4b4e-8cf4-19952d616802" alt=""><figcaption></figcaption></figure>

6. #### **Creating a Custom Rule for Mimikatz Detection**
   1. **Access Wazuh Rule Management**
      * Go to **Server** **Management** → **Rules** in the Wazuh dashboard.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FrzCDSnw6Y25oO7DaYSAA%2F4.png?alt=media&#x26;token=fc5334df-3702-416e-ad11-7ff2865ab994" alt="" width="563"><figcaption></figcaption></figure>
      * Click **Manage Rule Files** and search for existing Sysmon event ID 1 rules.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FxeO4KV4q0rtmlckmb9Rm%2F4.png?alt=media&#x26;token=82ced67a-3137-4c1e-8828-b47a9ecce5eb" alt="" width="563"><figcaption></figcaption></figure>
   2. **Create a Custom Rule**
      * Copy an existing Sysmon event ID 1 rule as a reference.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FQeO4bpx1H0VAy8v0mIZB%2Fimage.png?alt=media&#x26;token=1fd68fdc-1374-4df8-81cd-d79689cd5337" alt=""><figcaption></figcaption></figure>
      * Open the **Custom Rules** section and edit the `local_rules.xml` file.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FZsfFE7gE6gbH9j9yJfhb%2F4.png?alt=media&#x26;token=6e338f84-053b-4894-bee7-b23d5e895064" alt=""><figcaption></figcaption></figure>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FmB74feVZQ9Z6g65CM1Nj%2F4.png?alt=media&#x26;token=0efaa40a-03f5-4532-8045-35a9832e7a3e" alt=""><figcaption></figcaption></figure>
      * Paste the copied rule and modify it:<br>
        * Change **Rule ID** to `100002`.
        * Set the **level** to `15` (critical).
        * Change the **field name** from `parentImage` to `originalFileName` (ensuring case sensitivity).
        * Set **regex match** for `mimikatz`.
        * Modify the **description** to indicate Mimikatz detection.
        * Update the **MITRE ATT\&CK ID** to `T1003` (Credential Dumping).<br>

          <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FqTcKdNr5QS2Z4VSEjcXt%2F4.png?alt=media&#x26;token=b0fef330-597d-4bd8-9d84-aaa7c90cff4b" alt=""><figcaption><p>Detection rule for Mimikatz: Triggers an alert when Sysmon logs show 'mimikatz.exe' execution, linking to MITRE ATT&#x26;CK T1003 (Credential Dumping).</p></figcaption></figure>
   3. **Save and Restart Wazuh Manager**
      * Click **Confirm Restart** to apply the custom rule.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2F2RdeQBiq1evJ9pQWThHi%2F4.png?alt=media&#x26;token=b6c884dc-ee9a-4958-a26a-04dbb093c0f7" alt=""><figcaption></figcaption></figure>

7. #### **Testing the Custom Rule**
   1. **Rename Mimikatz to Avoid Detection Bypass**
      * Rename `mimikatz.exe` to something else (e.g., `totally-not-mimikatz`).<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FglLOOo40v8NXH2E6wjh4%2Fimage.png?alt=media&#x26;token=711e75e4-9f30-49e0-b80b-290ee4314eac" alt="" width="371"><figcaption></figcaption></figure>
   2. **Run the Renamed File in PowerShell**
      * Open PowerShell and execute the renamed file.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FjjHl53aGEoeZ7bBanvR1%2Fimage.png?alt=media&#x26;token=c4861541-9c7f-4b23-a0cd-b0279eef42cb" alt=""><figcaption></figcaption></figure>
   3. **Check for Alerts in Wazuh Dashboard**
      * Refresh the **Security Events** section.<br>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FckaDI54kIXv1WezzAVqH%2F5.png?alt=media&#x26;token=a36d23f4-66fc-42d4-afb3-dfd017bf6c98" alt=""><figcaption></figcaption></figure>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FyTiOX5jmHMaaWXsbgyLl%2F5.png?alt=media&#x26;token=e43b99c0-a477-4600-bdb2-e5108175c360" alt=""><figcaption></figcaption></figure>

        <figure><img src="https://579311808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FncZU5ncqqrt7qhD7DZRg%2Fuploads%2FVTiRd0PPqofqxAt7Vnjv%2F5.png?alt=media&#x26;token=00329321-e53f-4237-b3db-d51e122078ae" alt=""><figcaption></figcaption></figure>
      * If the rule is working, Mimikatz should trigger an alert despite the name change.
