Skip to main content

THOR APT SCANNER to Timesketch

This log conversion utility makes it easy to import THOR logs into Timesketch. Combining THOR findings on a shared timeline it enables cybersecurity analysts to enhance detection and analysis of malicious activity.


Table of Contents

  1. Overview
  2. Quick Start
  3. Installation
  4. Usage
  5. Configuration for Timesketch Ingestion
  6. Filter Configuration
    • Standard THOR logs (JSON v1 / v2)
    • Audit-trail logs
  7. Input and Output Files
    • Input Files
    • Output File
  8. Ingesting into Timesketch
    • Manual Upload jsonl
    • Automatic Ingestion (-s, --sketch)
  9. Technical Details
    • THOR JSON v1/v2
    • Audit-trail Logs
  10. Troubleshooting
  • Issues and solutions
  1. Contributing
    • How to contribute
  2. License
  3. Support

Overview

thor2ts License: MIT

thor2ts is a lightweight CLI utility that converts THOR security scanner logs into Timesketch-compatible JSONL format by:

  • Extracting relevant fields from THOR logs

  • Generating entries with the required Timesketch fields: message, datetime, and timestamp_desc

  • Handling THOR events with multiple timestamps by creating separate entries for each timestamp


Quickstart with thor2ts

Install the tool

pip install thor2timesketch

Convert a THOR log file → Timesketch-ready JSONL

thor2ts thor_scan.json -o thor_events.jsonl

Convert and ingest directly into a (new or existing) sketch

thor2ts thor_scan.json -s "THOR APT SCANNER"

For filtering, batching, and other options, see Usage.


Installation

Prerequisites

Make sure you have the following installed on your system:

Note: Scan with --utc parameter to ensure timestamps are in UTC format.

Steps

  1. Create a virtual environment:

    • Linux / macOS (bash / zsh)
    python3 -m venv thor2ts-venv
    
    • Windows (cmd / powershell)
    py -3 -m venv thor2ts-venv
    
  2. Activate the virtual environment thor2ts-venv:

    • Linux / macOS (bash / zsh)
    source thor2ts-venv/bin/activate
    
    • Windows (cmd / powershell)
    thor2ts-venv\Scripts\activate
    
  3. Install thor2timesketch package:

    pip install thor2timesketch
    
  4. Future Use

    To use thor2ts in the new terminal, activate the virtual environment, (see step 2 - Activate the virtual environment above).


Usage

Once the virtual environment is active, you can run the tool from the command line:

thor2ts <INPUT_FILE> [OPTIONS]

Command-Line Arguments

Argument Description
<INPUT_FILE> Path to the THOR JSON log file. Required.
-o, --output-file <JSONL_FILE> Save the converted THOR logs to the specified JSONL output file. Optional.
-s, --sketch <ID|NAME> Ingest directly into the specified Timesketch sketch (by ID or name). Auto-creates the sketch if missing. Optional.
-b, --buffer-size <N> Set the Timesketch importer buffer size (batch size) for ingestion. Optional.
-F, --filter <YAML_FILE> Specify a YAML filter to select which THOR events are ingested. Optional.
--generate-filter Generate thor_filter.yaml by extracting filters from THOR v1/v2 logs or using a default template. Optional.
-v, --verbose Enable verbose debugging output. Optional.
--version Display the current thor2ts version. Optional.

Examples

Scenario Command
Convert to JSONL Output File thor2ts thor_scan.json -o mapped_events.jsonl
Convert & Ingest to Sketch thor2ts thor_scan.json -s "THOR APT SCANNER"
Set Custom Buffer Size thor2ts thor_scan.json -s "THOR APT SCANNER" -b 100000
Convert, Filter & Ingest to Sketch thor2ts thor_scan.json -F thor_filter.yaml -s "THOR APT SCANNER"
Extract Filter Template (file) thor2ts input_v1.json --generate-filter
Generate Default Filter Template thor2ts --generate-filter
Enable Debug Mode thor2ts thor_scan.json -s "THOR APT SCANNER" --verbose

Configuration for Timesketch Ingestion

When you ingest for the first time (-s, --sketch), you will be prompted to enter your Timesketch connection settings:

  1. host_uri URL of your Timesketch server (e.g. https://timesketch.example.com)

  2. auth_mode Authentication mode:

    • userpass (username/password)
    • oauth (OAuth2)
  3. username Timesketch USERNAME

  4. password Timesketch password (Note: It will be tokenized and stored securely)

This creates two configuration files in the user's home directory $HOME/:

File Purpose
~/.timesketch.token Encrypted authentication tokens
~/.timesketchrc Connection settings (host, auth mode, credentials)

~/.timesketchrc

[timesketch]
host_uri = https://timesketch.example.com
username = USERNAME
verify = True
client_id = 
client_secret = 
auth_mode = userpass
cred_key = <generated_key>

For more detailed information about the Timesketch API client configuration and usage, please check out the Timesketch API client documentation.


Filter Configuration

Thor2timesketch supports two filter scopes. The usage of filters is optional and sane defaults are used (that can be explicitly written to a config using the --generate-filter flag):

1. Standard THOR logs (JSON v1 / v2)

  • filters.levels A list of THOR log level values to include (e.g., Alert, Warning).

  • filters.modules

    • include: THOR log module names to include
    • exclude: THOR log module names to exclude

2. Audit-trail logs

  • filters.audit
    • info — ingest all audit information entries
    • findings — ingest audit findings entries (then apply filters.levels + filters.modules)

Example thor_filter.yaml

filters:
  levels:
    - Alert
    - Warning
  modules:
    include:
      - Antivirus
      - Firewall
    exclude:
      - Debug
  audit:
    - info
    - findings

Input and Output Files

Logs generated by THOR APT SCANNER v10.7.

Input Files

Output File

  • Timesketch-formatted JSONL
    • If the target filename does not end with .jsonl, the extension will be automatically changed to .jsonl.
    • If the file already exists, new events are appended rather than overwritten.

Warning

Timesketch accepts only JSON files with a .jsonl extension. Timesketch documentation


Ingesting into Timesketch

1. Manual Upload jsonl

2. Automatic Ingestion (-s, --sketch)

Add -s, --sketch <ID|NAME> to your thor2ts command and it will:

  1. Create or find the specified sketch
  2. Push the mapped events directly
  3. Wait up to 60 seconds for indexing to finish
    • If indexing completes in time, you can go to the sketch immediately
    • Otherwise, ingestion continues in the background
  4. Buffer size is set to 50,000 events by default, but you can adjust it with -b, --buffer-size <N>.

Technical Details

Field Mapping Logic

When a THOR record contains multiple timestamp fields, each timestamp is extracted into its own Timesketch event.

All events derived from the same THOR log share a common event_group_id (a UUID) so you can correlate primary and secondary events.

1. THOR JSON v1/v2

THOR event

  • message ← original "message" (e.g. "Malicious user details found")

  • datetime ← "time" (e.g. 2025-05-07T11:45:01+00:00)

  • timestamp_desc ← THOR scan timestamp

  • event_group_id ← UUID generated per THOR event

  • tag ← ["thor", <Level>] (e.g. ["thor","Alert"])

  • **fields ← all other fields from THOR log

  • Secondary events (for each timestamp in THOR event)

    • message ← original "message" (e.g. "Malicious user details found")
    • datetime ← time (e.g. "last_logon")
    • timestamp_desc ← "<module> - <field>" (e.g. Users - last_logon)
    • event_group_id ← same UUID as THOR event
    • tag ← ["ts_extra", <Level>]

2. Audit-trail Logs

Info entries

For each timestamp in info:

  • message ← Name (e.g. "File")
  • datetime ← timestamp value (e.g. 2025-05-07T11:45:01+00:00)
  • timestamp_desc ← timestamp key (e.g. accessed)
  • tag ← ["audit_info"]
  • event_group_id ← UUID for this audit record
  • First event includes all other info fields

Findings entries

For each finding under findings:

  • message ← finding’s Message (e.g. "Malware file found")
  • datetime ← timestamp value
  • timestamp_desc ← "<Module> - <field>" (e.g. Filescan - created)
  • tag ← ["findings", <Level>] (e.g. ["findings","Alert"])
  • event_group_id ← UUID for this audit record
  • First event includes all other finding fields

NOTE: Use event_group_id to correlate first and secondary events from the same THOR log or audit-trail log.

Troubleshooting

Issues recorded on 20.05.2025

1. Multiple data sources created

  • Symptom: Every ~50 000 events shows up as a separate data source in the sketch.
  • Cause: The importer’s default batch size is 50 000 events per upload.
  • Solution:
    1. Use the -b, --buffer-size argument to increase the batch size.
      thor2ts input.json -s "THOR APT SCANNER" -b 100000
      
    2. Convert to JSONL:
      thor2ts input.json -o mapped_events.jsonl
      
      Ingest the JSONL file into Timesketch using the CLI importer:
      timesketch_importer --sketch_id <ID> --threshold_entry 100000 mapped_events.jsonl
      

      Warning: Consider RAM size when increasing batch size.

2. Timesketch host becomes unresponsive while ingesting THOR logs

  • Symptom: High memory/CPU use, shell freezes, or Timesketch web UI becomes unresponsive during ingestion.
  • Cause: OpenSearch (Timesketch backend) allocates ~50 % of RAM for its JVM heap, on < 16 GB systems this leaves too little memory for the OS and the N event-buffer used by the importer.
  • Solution:
    • Run on a host with ≥ 16 GB RAM (recommended) for the default 50_000 event buffer size. Timesketch explicitly states 8GB is a minimum and "the more the better"
    • Import in smaller batches using the -b, --buffer-size argument.

3. JSON Line format required

  • Symptom: JSON parse errors.
  • Cause: Input is pretty-printed JSON or a JSON array, not newline-delimited.
  • Solution:
    • Use the unmodified THOR JSON output format or dump the THOR logs into JSON Lines format.

4. Web UI upload errors

  • Symptom: Web UI rejects large JSONL entries “Unterminated string in JSON at position ...”.
  • Cause: Browser-based uploader can’t handle very large files or large JSONL entries
  • Solution:
    • Ingest directly using thor2ts with the -s, --sketch argument.
    • Import via CLI importer for already mapped THOR events from a JSONL file:
    timesketch_importer --sketch_id <ID> mapped_events.jsonl
    

Contributing

Contributions to thor2ts are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with your improvements or bug fixes.

Support

If you encounter any issues or have questions, please open an issue in the GitHub repository.


Metadata

Release files for thor2timesketch 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thor2timesketch 0.1.6
File Size Uploaded Provenance Actions
thor2timesketch-0.1.6.tar.gz 26.8 kB With provenance Details for thor2timesketch-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thor2timesketch 0.1.6
File Interpreter ABI Platform Actions
thor2timesketch-0.1.6-py3-none-any.whl Python 3 none any Details for thor2timesketch-0.1.6-py3-none-any.whl

Total release size: 65.9 kB

Release files / thor2timesketch-0.1.6.tar.gz

Download URL thor2timesketch-0.1.6.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
65863e2efa8c13bff1d43a511afe8ae1b8769b64419251cf5bdd91297b508bb5
BLAKE2b-256 checksum
How to use checksums
60dc14537233ebd5348ac277eb055b1d2b355ea62e32f3175c80b897d6c91d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 12, 2025.

Transparency log

Release files / thor2timesketch-0.1.6-py3-none-any.whl

Download URL thor2timesketch-0.1.6-py3-none-any.whl
Size 39.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7dce145da9f014f395f027e94e22ae08c6aea8d27f042ef5186721ae4a44c72f
BLAKE2b-256 checksum
How to use checksums
70ddb7119f59af4b57aef5473e1bfbd2e30ffed7d51cdc2e937c3d1a99ea29d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 12, 2025.

Transparency log

Security for thor2timesketch 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for thor2timesketch-0.1.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 12, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page