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.gitand 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:
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.xmlfile. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wazuhevtx-1.1.0.tar.gz.
File metadata
- Download URL: wazuhevtx-1.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f002f15125d40fa23ceb2d349298e3f58189da102f60c98e2ac65bf03e8c97f9
|
|
| MD5 |
b03a0fbdd3973be7ef5e3c4ee22c17ac
|
|
| BLAKE2b-256 |
cbb156bc12dbac1aa45c865eae507972d67026d7117b662823857cbcccb58663
|
Provenance
The following attestation bundles were made for wazuhevtx-1.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on zbalkan/wazuhevtx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wazuhevtx-1.1.0.tar.gz -
Subject digest:
f002f15125d40fa23ceb2d349298e3f58189da102f60c98e2ac65bf03e8c97f9 - Sigstore transparency entry: 564173878
- Sigstore integration time:
-
Permalink:
zbalkan/wazuhevtx@cc32fa6ae2d7c2f01f909f5851624853c3ca5631 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/zbalkan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@cc32fa6ae2d7c2f01f909f5851624853c3ca5631 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wazuhevtx-1.1.0-py3-none-any.whl.
File metadata
- Download URL: wazuhevtx-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7cd6b8769a17c15ea0a258d5f60f2d04e83735d6aff53df501c0c1beac1b49f
|
|
| MD5 |
a94863aa2c5c540f118c7efacb6b0b1d
|
|
| BLAKE2b-256 |
6fa8236ac85b3130cfb38fb2dd55ee2c744a46546d71428f46b1b1ec4433a4f9
|
Provenance
The following attestation bundles were made for wazuhevtx-1.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on zbalkan/wazuhevtx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wazuhevtx-1.1.0-py3-none-any.whl -
Subject digest:
d7cd6b8769a17c15ea0a258d5f60f2d04e83735d6aff53df501c0c1beac1b49f - Sigstore transparency entry: 564173884
- Sigstore integration time:
-
Permalink:
zbalkan/wazuhevtx@cc32fa6ae2d7c2f01f909f5851624853c3ca5631 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/zbalkan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@cc32fa6ae2d7c2f01f909f5851624853c3ca5631 -
Trigger Event:
push
-
Statement type: