Skip to main content

A Python tool and library and library that parses EVTX files and converts them into JSON formatted logs mimicking Wazuh agent behavior in version 4.x. wazuhevtx is designed as a helper for wazuh-logtest tool.

Project description

wazuhevtx

A Python tool and library that parses EVTX files and converts them into JSON formatted logs mimicking Wazuh agent behavior in version 4.x. wazuhevtx is designed as a helper for wazuh-logtest tool.

Now, you can test your detection capabilities by replaying known attack samples such as Windows EVTX Samples.

Note: It runs on Windows-only! See Caveats below.

Installation

Alternative 1: Clone this repository

  • Simply git clone https://github.com/zbalkan/wazuhevtx.git and start playing wih it.
  • initiate your favorite virtual environment.
  • Install dependencies using pip install -r requirements.txt
  • Run the script by providing the path to evtx file.

Alternative 2: Use pip/pipx

If you plan to use the library and CLI:

  • initiate your favorite virtual environment.
  • Install the module using pip install wazuhevtx
  • Run the script by providing the path to evtx file. Or you ca just use import wazuhevtx

If you want to use only CLI tool:

  • Install the module using pipx install wazuhevtx
  • Run the script by providing the path to evtx file.

Usage

As a CLI tool

usage: wazuhevtx [-h] [-o OUTPUT] evtx

A Python tool and library that parses EVTX files and converts them into JSON formatted logs mimicking Wazuh agent behavior in version 4.x. wazuhevtx is designed as a helper for wazuh-logtest tool.

positional arguments:
  evtx                  Path to the Windows EVTX event log file

options:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Path of output JSON file. If not defined, output will be printed to console.

Check the animation for a speed run:

Alt Text

As a library

You can use the package as a library to integrate into your scripts.

from wazuhevtx.evtx2json import EvtxToJson

for log in converter.to_json(evtx_file):
    print(log)

Caveats

Windows-only

Due to Windows API dependencies of win32evtlog, the script works on Windows systems only. If you try on a Linux or Mac environment, you will get "This script is intended to be run on Windows." message, and the script will exit with error code 1.

Workaround for testing

In order to be able to test with wazuh-logtest utility, you need a workaround as we are sending JSON logs, not event_channel format.

  • Navigate to /var/ossec/ruleset/rules/0575-win-base_rules.xml file.
  • Update the rule 60000 this way:
<rule id="60000" level="2">
    <!-- category>ossec</category -->
    <!-- decoded_as>windows_eventchannel</decoded_as -->
    <decoded_as>json</decoded_as>
    <field name="win.system.providerName">\.+</field>
    <options>no_full_log</options>
    <description>Group of windows rules.</description>
</rule>

Corrupted EVTX files

If you encounter this error below, you will see that you cannot parse event logs. That is because I utilize Windows APIs, and by default the API does not provide a way to read or recover corrupted sections. If the file is corrupted, you cannot read it as a whole. I suggest using third party tools lie CQEVTXRecovery to recover files before using with wazuhevtx.

Error: The event log file is corrupted. (1500)

Log Provider missing

It is possible that the log provider is missing on your computer. For instance, you may not have Sysmon installed on the analyst workstation, therefore the formatted message may be missing. Then, you will face the error message in the event's message field Failed to get metadata for provider Microsoft-Windows-Sysmon. This is by design. You cannot get metadata from a provider that does not exist. If you plan to use message field in detections, beware of the error message.

Thanks

Thanks to Birol Capa for his article pointing to the simplest way to parse EVTX files. Before that I tried many different solutions that were limited after some point.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wazuhevtx-1.0.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wazuhevtx-1.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file wazuhevtx-1.0.0.tar.gz.

File metadata

  • Download URL: wazuhevtx-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wazuhevtx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 99ab1563292d7652100b6704a582a44a6f82669d84ac2191ef97579c7bfd2296
MD5 614165c6cbd7e6b82ea9a529b821ea86
BLAKE2b-256 206306f9e5b2473ac322d522d2a5b2095cd29dc649c245dac9d83bf3fa988801

See more details on using hashes here.

Provenance

The following attestation bundles were made for wazuhevtx-1.0.0.tar.gz:

Publisher: publish-to-pypi.yml on zbalkan/wazuhevtx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wazuhevtx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wazuhevtx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wazuhevtx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7f04d530a4167a25f1ff4bdc845ece5a3ff8c070d6e5eab744a1c4a840f6c09
MD5 6ccd2ee8a69c6d17ec9a5531c5fa88a2
BLAKE2b-256 7480d541959e60ca49aa6f337f5b794761b43dbb6d72ceb0c4bfb83037285bdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for wazuhevtx-1.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on zbalkan/wazuhevtx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page