> For the complete documentation index, see [llms.txt](https://faresbltagy.gitbook.io/footprintinglabs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faresbltagy.gitbook.io/footprintinglabs/build-home-lab-soc-automation/execute-mimikatz-and-create-detection-rules-in-wazuh.md).

# Execute Mimikatz & create detection rules in Wazuh

First, let's open **Virus & Threat Protection** to add the **Downloads** folder as an exclusion.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FsrHrZHJb47MAUmsOTnMU%2FScreenshot(9).png?alt=media&amp;token=7b573017-2cd0-431d-82dd-cb2c804ef96e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F4qU4LrMRBoFcTu1wjFxe%2FScreenshot(10).png?alt=media&amp;token=9dc6661b-849d-45b5-ae66-4c46aad98ca8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FtA61OwRXPzJFQdAOk8Du%2FScreenshot(11).png?alt=media&amp;token=a81af802-8bcf-456d-bcfb-fa8acd2efb5f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FGol3dLyeElCZeqB58Bfv%2FScreenshot(12).png?alt=media&amp;token=2704ae95-1505-415d-925c-8da9a3518d62" alt=""><figcaption></figcaption></figure>

Now, let's install Mimikatz from this link: <https://github.com/ParrotSec/mimikatz/blob/master/x64/mimikatz.exe>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Ffp6736iLtjR5isr0TOZ4%2FScreenshot(13).png?alt=media&amp;token=e3ea6210-dcc9-436c-9f4b-70122d4f03ba" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F9lz8NMD8GNevqSmZFvOu%2FScreenshot(14).png?alt=media&amp;token=c273d5f5-6877-4642-85b0-b10ecfb19bf8" alt=""><figcaption></figcaption></figure>

Now, let's execute `mimikatz.exe` and review the Wazuh dashboard for any related detections or alerts.

```powershell
.\mimikatz.exe
Add-MpPreference -ExclusionProcess "mimikatz.exe"
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FrG8GZM87TEaG3STT5NJr%2FScreenshot(15).png?alt=media&amp;token=7e94948a-b376-4365-9562-8de210a149e6" alt=""><figcaption></figcaption></figure>

When I execute `mimikatz.exe`, Windows Defender blocks it. To proceed, I need to exclude the `mimikatz` process from detection.

Now, let's check the Wazuh dashboard for any related detections or alerts.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FTe0UiZj7KHG3eaCbXrWS%2FScreenshot(16).png?alt=media&amp;token=bd8a12b0-40db-4078-a084-b88e16dc3a73" alt=""><figcaption></figcaption></figure>

Upon reviewing Wazuh, I did not find any indicators related to Mimikatz.

By default, Wazuh does not log all events; it only generates logs when a rule is triggered or an alert is generated. However, this behavior can be modified by configuring the `ossec.conf` file within the Wazuh Manager to enable comprehensive logging. Alternatively, specific rules can be created to monitor particular events. When these events occur, they will trigger an alert in Wazuh, allowing for efficient searching and analysis.

Next, let's proceed with editing the `ossec.conf` file.

```bash
nano /var/ossec/etc/ossec.conf
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FESww5YvFKghL6DVzFmS8%2FScreenshot(17).png?alt=media&amp;token=87b3808c-ed84-4f67-9274-00722b4eaae6" alt=""><figcaption></figcaption></figure>

Now, let's restart the Wazuh manager.

```bash
systemctl restart wazuh-manager
```

This action compels Wazuh to start archiving all logs and store them in a file named "archives."

```bash
cd /var/ossec/logs/archives/
ls
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FsuXuvCEW1XLZz7lvbaqE%2FScreenshot(19).png?alt=media&amp;token=6b672e97-fce4-42c4-a012-c8e692833de0" alt=""><figcaption></figcaption></figure>

We also need to configure the `filebeat.yml` file.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FHH9N1wVdU0NRsrXrjDkB%2FScreenshot(18).png?alt=media&amp;token=e84ea070-a05e-4906-97c9-95fefac3c0b1" alt=""><figcaption></figcaption></figure>

Next, let's restart the Filebeat manager.

```bash
systemctl restart filebeat
```

Next, we need to create an index for the archives. Let's move forward with this step.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F6fRS4jG6xFKcwGvRPoOG%2FScreenshot(20).png?alt=media&amp;token=f8805808-bf8a-4ba3-b338-4c559401d8ff" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FbTygiTB8QEAQFIpJKjdK%2FScreenshot(21).png?alt=media&amp;token=4f8f51af-3eb9-4dff-8134-04ee07bc15ab" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fsjr9MIDLIevQ30yLtXFZ%2FScreenshot(22).png?alt=media&amp;token=252aa55f-014b-42d9-9216-e93b0da12397" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Frbl5dGQ6ru253XEX19lY%2FScreenshot(23).png?alt=media&amp;token=289bb080-0b70-4b6a-b9f4-bc36e2b3f8aa" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FT0ioyjJOC2dUthvIivhT%2FScreenshot(25).png?alt=media&amp;token=23ce48d5-764b-478b-bd5b-2d0ca64d4bfd" alt=""><figcaption></figcaption></figure>

Let's return to the Discover page.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F8oYYryE9kun2t6242F69%2FScreenshot(26).png?alt=media&amp;token=760cd02f-e56d-490e-9317-d6f8f5596dd2" alt=""><figcaption></figcaption></figure>

Let's execute Mimikatz again and review the logs in the Wazuh dashboard.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FJscedbdyXpjHVUFDQinp%2FScreenshot(27).png?alt=media&amp;token=0c7c1729-692f-4d72-8f4e-329b160fb80c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FLXERGDxmBis70W80CGgw%2FScreenshot(28).png?alt=media&amp;token=91215192-0df6-47b2-a8ef-3385b7450533" alt=""><figcaption></figcaption></figure>

We now need to create a rule to detect and generate an alert for Mimikatz activity.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fu74KJcUXkxbUZaVakOoT%2FScreenshot(29).png?alt=media&amp;token=948d0070-d9b7-4780-9b22-5b916c562b31" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FlSUgnPt5Dns3MeRlWESK%2FScreenshot(30).png?alt=media&amp;token=fb1ec8fe-25cc-4f81-81ba-d2076914d51a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FkskpIGQJjTWsFyfg4Gs6%2FScreenshot(31).png?alt=media&amp;token=07cdce1c-bdeb-4ca3-8f29-4aacfdde987a" alt=""><figcaption></figcaption></figure>

We need to copy this section as it will be used to create a custom rule.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FqmxLjQ6wIlQC63QWJpd3%2FScreenshot(32).png?alt=media&amp;token=b0f7a42f-7a56-47dd-b4cf-0078e1ebfb0f" alt=""><figcaption></figcaption></figure>

Let's proceed with creating our custom rule.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FZ4WVM6X7hRIRGp4lOVUj%2FScreenshot(33).png?alt=media&amp;token=85081c46-bb93-4709-89f5-801ad14769e1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FZGx3S0K2K9pHyKq1ymAm%2FScreenshot(34).png?alt=media&amp;token=1ecb5b19-e8cf-452f-85e3-401cdae48675" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FHIlxgfVVHzmBk9HkW7lj%2FScreenshot(35).png?alt=media&amp;token=b6874aec-3e54-47ac-9d7d-4ce5d4359cfe" alt=""><figcaption></figcaption></figure>

```xml
  <rule id="100002" level="10">
    <if_group>sysmon_event1</if_group>
    <field name="win.eventdata.originalFileName" type="pcre2">(?i)mimikatz\.exe</field>
    <description>Mimikatz Usage Detected</description>
    <mitre>
      <id>T1003</id>
    </mitre>
  </rule>
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FAQGjzTwf9amWE4UQcqrU%2FScreenshot(36).png?alt=media&amp;token=5d7a3aa6-949a-4b4b-99d3-829dd52e8ba5" alt=""><figcaption></figcaption></figure>

The `win.eventdata.originalFileName` field refers to the original name embedded within the file's metadata, which doesn't change even if the file is renamed on disk. Therefore, if an attacker simply renames `mimikatz.exe` to another name, this rule would still trigger an alert because the original filename remains `mimikatz.exe`.

Let's rename **`mimikatz.exe`** to an alternative name, execute it, and verify whether Wazuh generates an alert.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FqzNDm2XgyBpw5FJiZemc%2FScreenshot(37).png?alt=media&amp;token=8231d159-fe93-4c6b-9fc3-8e1ad63b139f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FaEatoWB84MRWEEIyucWF%2FScreenshot(38).png?alt=media&amp;token=05e451cc-5b61-4eeb-8872-588aad883824" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F5ZU7IgYZVsIK9ex4vZGO%2FScreenshot(39).png?alt=media&amp;token=5aa7ed83-9645-4d23-99d6-6772a9c2993e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FRhIlsn0P2pO92cys1Tjg%2FScreenshot(40).png?alt=media&amp;token=aee0fe4c-b8e5-477d-97ac-88cc7b9f2c1c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fb80EwdRnVPMSeZrN0nvf%2FScreenshot(41).png?alt=media&amp;token=73a7bb27-4188-495a-8945-afda2d488857" alt=""><figcaption></figcaption></figure>

If the rule is based on the image, the alert will not be triggered.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faresbltagy.gitbook.io/footprintinglabs/build-home-lab-soc-automation/execute-mimikatz-and-create-detection-rules-in-wazuh.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
