Skip to main content

Fast import of Windows EventLogs(.evtx) into Elasticsearch.

Project description

evtx2es

MIT License PyPI version Python Versions DockerHub Status

evtx2es logo

Fast import of Windows EventLogs(.evtx) into Elasticsearch.

Life is too short and there is not enough time to process huge Windows EventLogs with pure-Python software.
evtx2es uses Rust library pyevtx-rs, so it runs much faster than traditional software.

Usage

When using from the commandline interface:

$ evtx2es /path/to/your/file.evtx

When using from the python-script:

from evtx2es import evtx2es

if __name__ == '__main__':
  filepath = '/path/to/your/file.evtx'
  evtx2es(filepath)

Arguments

evtx2es supports importing from multiple files.

$ evtx2es file1.evtx file2.evtx file3.evtx

Also, possible to import recursively from a specific directory.

$ tree .
evtxfiles/
  ├── file1.evtx
  ├── file2.evtx
  ├── file3.evtx
  └── subdirectory/
    ├── file4.evtx
    └── subsubdirectory/
      ├── file5.evtx
      └── file6.evtx

$ evtx2es /evtxfiles/ # The Path is recursively expanded to file1~6.evtx.

Options

--version, -v

--help, -h

--quiet, -q
  Flag to suppress standard output
  (default: False)

--multiprocess, -m:
  Flag to run multiprocessing (fast!)
  (default: False)

--size:
  Size of the chunk to be processed for each process
  (default: 500)

--host:
  ElasticSearch host address
  (default: localhost)

--port:
  ElasticSearch port number
  (default: 9200)

--index:
  Index name of Import destination
  (default: evtx2es)

--scheme:
  Scheme to use (http, or https)
  (default: http)

--pipeline
  Elasticsearch Ingest Pipeline to use
  (default: )

--datasetdate
  Date of latest record in dataset from TimeCreated record - MM/DD/YYYY.HH:MM:SS
  (default: 0)

--login:
  The login to use if Elastic Security is enable
  (default: )

--pwd:
  The password linked to the login provided
  (default: )

Examples

When using from the commandline interface:

$ evtx2es /path/to/your/file.evtx --host=localhost --port=9200 --index=foobar --size=500

When using from the python-script:

if __name__ == '__main__':
    evtx2es('/path/to/your/file.evtx', host=localhost, port=9200, index='foobar', size=500)

With the Amazon Elasticsearch Serivce (ES):

$ evtx2es /path/to/your/file.evtx --host=example.us-east-1.es.amazonaws.com --port=443 --scheme=https --index=foobar

With credentials for Elastic Security:

$ evtx2es /path/to/your/file.evtx --host=localhost --port=9200 --index=foobar --login=elastic --pwd=******

Note: The current version does not verify the certificate.

Appendix

Evtx2json

Extra feature. :sushi: :sushi: :sushi:

Convert from Windows Eventlog to json file.

$ evtx2json /path/to/your/file.evtx /path/to/output/target.json

Convert from Windows Eventlog to Python List[dict] object.

from evtx2es import evtx2json

if __name__ == '__main__':
  filepath = '/path/to/your/file.evtx'
  result: List[dict] = evtx2json(filepath)

Output Format Example

Using the sample evtx file of JPCERT/CC:LogonTracer as an example.

[
  {
    "event_record_id": 227559,
    "timestamp": "2016-10-06 01:50:49.420927 UTC",
    "winlog": {
      "channel": "Security",
      "computer_name": "WIN-WFBHIBE5GXZ.example.co.jp",
      "event_id": 4624,
      "opcode": 0,
      "provider_guid": "{54849625-5478-4994-a5ba-3e3b0328c30d}",
      "provider_name": "Microsoft-Windows-Security-Auditing",
      "record_id": 227559,
      "task": 12544,
      "version": 0,
      "process": {
        "pid": 572,
        "thread_id": 1244
      },
      "event_data": {
        "AuthenticationPackageName": "Kerberos",
        "IpAddress": "192.168.16.102",
        "IpPort": "49220",
        "KeyLength": 0,
        "LmPackageName": "-",
        "LogonGuid": "F4DC1C19-0544-BC52-0900-DFC19752C3C6",
        "LogonProcessName": "Kerberos",
        "LogonType": 3,
        "ProcessId": 0,
        "ProcessName": "-",
        "SubjectDomainName": "-",
        "SubjectLogonId": "0x0",
        "SubjectUserName": "-",
        "SubjectUserSid": "S-1-0-0",
        "TargetDomainName": "EXAMPLE",
        "TargetLogonId": "0x1fa0869",
        "TargetUserName": "WIN7_64JP_02$",
        "TargetUserSid": "S-1-5-21-1524084746-3249201829-3114449661-1107",
        "TransmittedServices": "-",
        "WorkstationName": "",
        "Status": null
      }
    },
    "log": {
      "file": {
        "name": "sample/Security.evtx"
      }
    },
    "event": {
      "code": 4624,
      "created": "2016-10-06T01:50:49.420927Z"
    },
    "@timestamp": "2016-10-06T01:50:49.420927Z"
  },
  ...
]

Performance Evaluations

evtx2es was evaluated using the sample evtx file of JPCERT/CC:LogonTracer (about 30MB binary data).

$ time evtx2es ./Security.evtx
> 6.25 user 0.13 system 0:14.08 elapsed 45%CPU

See Qiita for more information.

Running Environment

OS: Ubuntu 18.04
CPU: Intel Core i5-6500
RAM: DDR4 32GB

ElasticSearch 7.4 was running on the Docker version(Official Image).
https://hub.docker.com/_/elasticsearch

Installation

via PyPI

$ pip install evtx2es

via DockerHub

$ docker pull sumeshi/evtx2es:latest

Run with Docker

https://hub.docker.com/r/sumeshi/evtx2es

evtx2es

# "host.docker.internal" is only available in mac and windows environments.
# For linux, use the --add-host option.
$ docker run -t --rm -v $(pwd):/app/work sumeshi/evtx2es:latest evtx2es /app/work/Security.evtx --host=host.docker.internal

evtx2json

$ docker run -t --rm -v $(pwd):/app/work sumeshi/evtx2es:latest evtx2es /app/work/Security.evtx /app/work/out.json

Do not use the "latest" image if at all possible.
The "latest" image is not a released version, but is built from the contents of the master branch.

Contributing

CONTRIBUTING

The source code for evtx2es is hosted at GitHub, and you may download, fork, and review it from this repository(https://github.com/sumeshi/evtx2es). Please report issues and feature requests. :sushi: :sushi: :sushi:

License

evtx2es is released under the MIT License.

Powered by pyevtx-rs.
Inspired by EvtxtoElk.

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

evtx2es-1.5.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

evtx2es-1.5.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file evtx2es-1.5.0.tar.gz.

File metadata

  • Download URL: evtx2es-1.5.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.0 Darwin/19.6.0

File hashes

Hashes for evtx2es-1.5.0.tar.gz
Algorithm Hash digest
SHA256 95390c9dbfc58a9740f0c4a00258658ee1e1b5ed271acdec63c19f875119a245
MD5 2f7cca3798bccd3f4ea7c7f4564afe73
BLAKE2b-256 e6664b1642a12bdaf7384b1d303c7fc0c90038eb03fdb588767530f9cda5badb

See more details on using hashes here.

Provenance

File details

Details for the file evtx2es-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: evtx2es-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.0 Darwin/19.6.0

File hashes

Hashes for evtx2es-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2db344da50d001caf691f7ef33157a7b3e4fcbc437c40c1a0ec6f0c7f6cfe4c1
MD5 05a94d122907c132c51b39b9f60ab116
BLAKE2b-256 9ac7383f01184f200933152eca79509fb9086da15d6ea8cba7a7f378b7c67cae

See more details on using hashes here.

Provenance

Supported by

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