Skip to main content

Karton

Distributed malware processing framework based on Python, Redis and S3.

The idea

Karton is a robust framework for creating flexible and lightweight malware analysis backends. It can be used to connect malware* analysis systems into a robust pipeline with very little effort.

We've been in the automation business for a long time. We're dealing with more and more threats, and we have to automate everything to keep up with incidents. Because of this, we often end up with many scripts stuck together with duck duct tape and WD-40. These scripts are written by analysts in the heat of the moment, fragile and ugly - but they work, and produce intel that must be stored, processed further, sent to other systems or shared with other organisations.

We needed a way to take our PoC scripts and easily insert them into our analysis pipeline. We also wanted to monitor their execution, centralise logging, improve robustness, reduce development inertia... For this exact purpose, we created Karton.

* while Karton was designed with malware analysis in mind, it works nicely in every microservice-oriented project.

Installation

Installation is as easy as a single pip install command:

pip3 install karton-core

In order to setup the whole backend environment you will also need S3-compatible storage and Redis, see the docs for details.

Example usage

To use karton you have to provide class that inherits from Karton.

from karton.core import Karton, Task, Resource

class GenericUnpacker(Karton):
    """
    Performs sample unpacking
    """
    identity = "karton.generic-unpacker"
    filters = [
        {
            "type": "sample",
            "kind": "runnable",
            "platform": "win32"
        }
    ]

    def process(self, task: Task) -> None:
        # Get sample object
        packed_sample = task.get_resource('sample')
        # Log with self.log
        self.log.info(f"Hi {packed_sample.name}, let me analyze you!")
        ...
        # Send our results for further processing or reporting
        task = Task(
            {
               "type": "sample",
               "kind": "raw"
            }, payload = {
               "parent": packed_sample,
               "sample": Resource(filename, unpacked)
            })
        self.send_task(task)

if __name__ == "__main__":
    GenericUnpacker.main()

Command line

This package also provies a command-line utility called "karton". You can use it for simple management tasks (but it's not designed as a fully capable management tool).

$ karton configure  # create a new configuration file

$ karton list -s  # list current binds
karton name                                        version    karton
------------------------------------------------------------------------
karton.yaramatcher                                 1.2.0      5.3.0
karton.autoit-ripper                               1.2.1      5.3.3
karton.mwdb-reporter                               1.3.0      5.3.2

$ karton logs  # start streaming all system logs

$ karton delete karton.something  # remove unused bind (will be GCed by system during the next operation)

Karton systems

Some Karton systems are universal and useful to everyone. We decided to share them with the community.

karton

This repository. It contains the karton.system service - main service, responsible for dispatching tasks within the system. It also contains the karton.core module, that is used as a library by other systems.

karton-dashboard

A small Flask dashboard for task and queue management and monitoring.

karton-classifier

The "router". It recognises samples/files and produces various task types depending on the file format. Thanks to this, other systems may only listen for tasks with a specific format (for example, only zip archives).

karton-archive-extractor

Generic archive unpacker. Archives uploaded into the system will be extracted, and every file will be processed individually.

karton-config-extractor

Malware extractor. It uses Yara rules and Python modules to extract static configuration from malware samples and analyses. It's a fishing rod, not a fish - we don't share the modules themselves. But it's easy to write your own!

karton-mwdb-reporter

A very important part of the pipeline. Reporter submits all files, tags, comments and other intel produced during the analysis to MWDB. If you don't use MWDB yet or just prefer other backends, it's easy to write your own reporter.

karton-yaramatcher

Automatically runs Yara rules on all files in the pipeline, and tags samples appropriately. Rules not included ;).

karton-asciimagic

Karton system that decodes files encoded with common methods, like hex, base64, etc. (You wouldn't believe how common it is).

karton-autoit-ripper

A small wrapper around AutoIt-Ripper that extracts embedded AutoIt scripts and resources from compiled AutoIt executables.

DRAKVUF Sandbox

Automated black-box malware analysis system with DRAKVUF engine under the hood, which does not require an agent on guest OS.


This is how these systems can be used to form a basic malware analysis pipeline:

Community projects that incorporate the Karton framework

c3rb3ru5d3d53c/karton-unpacker

A modular Karton Framework service that unpacks common packers like UPX and others using the Qiling Framework.

c3rb3ru5d3d53c/mwcfg / c3rb3ru5d3d53c/mwcfg-modules

A Feature Rich Modular Malware Configuration Extraction Utility for MalDuck

raw-data/karton-die-classifier

Detect-It-Easy classifier for the Karton framework

raw-data/karton-retdec-unpacker

RetDec unpacker module for the Karton framework

W3ndige/aurora / W3ndige/karton-similarity

Malware similarity platform with modularity in mind.

splintersfury/driver_analyzer

A scalable Windows driver vulnerability analyzer pipeline.

Co-financed by the Connecting Europe Facility by of the European Union

Release files for karton-core 5.9.1

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

Source distribution (sdist)

Source distribution for karton-core 5.9.1
File Size Uploaded
karton_core-5.9.1.tar.gz 62.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for karton-core 5.9.1
File Interpreter ABI Platform
karton_core-5.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 129.2 kB

Release files / karton_core-5.9.1.tar.gz

Download URL karton_core-5.9.1.tar.gz
Size 62.9 kB
Tags Source
SHA-256 checksum
How to use checksums
432d4c711ea783afa14e057175bcc91ac4eb5565931f6ad9cbacca49c2dc6374
BLAKE2b-256 checksum
How to use checksums
272452349125f9e005e1f5355832d9e512196c7d16d5c0c11ebf18a150e4baf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / karton_core-5.9.1-py3-none-any.whl

Download URL karton_core-5.9.1-py3-none-any.whl
Size 66.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d86680af54be1e44acde59e0637ad68e67fdc54d7bbd9fafd35e6afebecef44b
BLAKE2b-256 checksum
How to use checksums
88e71859a6433f05a6b78626e1a9d3d3e4c1819a7ace944881efd05071d369e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

5.9.1 This release

2 release files

5.9.0

2 release files

5.8.0

1 release file

5.7.0

1 release file

5.6.1

1 release file

5.6.0

1 release file

5.5.1

1 release file

5.5.0

1 release file

5.4.0

1 release file

5.3.4

1 release file

5.3.3

1 release file

5.3.2

1 release file

5.3.1

1 release file

5.3.0

1 release file

5.2.0

1 release file

5.1.0

1 release file

5.0.1

1 release file

5.0.0

1 release file

4.4.1

1 release file

4.4.0

1 release file

4.3.0

1 release file

4.2.0

1 release file

4.1.0

1 release file

4.0.5

1 release file

4.0.4

1 release file

4.0.3

1 release file

4.0.2

1 release file

4.0.1

1 release file

4.0.0

1 release file

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