muchdogesec / txt2stix

txt2stix is a Python script that is designed to identify and extract IoCs and TTPs from text files, identify the relationships between them, convert them to STIX 2.1 objects, and output as a STIX 2.1 bundle.
https://www.dogesec.com/
Apache License 2.0
23 stars 3 forks source link
cyber-threat-intelligence stix2 stix2-extensions stix2-patterns

txt2stix

Overview

txt2stix

txt2stix is a Python script that is designed to identify and extract IoCs and TTPs from text files, identify the relationships between them, convert them to STIX 2.1 objects, and output as a STIX 2.1 bundle.

The general design goal of txt2stix was to keep it flexible, but simple, so that new extractions could be added or modified over time.

In short txt2stix;

  1. takes a txt file input
  2. (optional) rewrites file with enabled aliases
  3. extracts observables for enabled extractions (ai, pattern, or lookup)
  4. (optional) removes any extractions that match whitelists
  5. converts extracted observables to STIX 2.1 objects
  6. generates the relationships between extracted observables (ai, standard)
  7. converts extracted relationships to STIX 2.1 SRO objects
  8. outputs a STIX 2.1 bundle

tl;dr

txt2stix

Watch the demo.

Usage

Setup

Install the required dependencies using:

# clone the latest code
git clone https://github.com/muchdogesec/txt2stix
cd txt2stix
# create a venv
python3 -m venv txt2stix-venv
source txt2stix-venv/bin/activate
# install requirements
pip3 install -r requirements.txt

Now copy the .env file to set your config:

cp .env.sample .env

You can new set the correct values in .env.

Usage

python3 txt2stix.py \
    --relationship_mode MODE \
    --input_file FILE.txt \
    --name NAME \
    --tlp_level TLP_LEVEL \
    --confidence CONFIDENCE_SCORE \
    --labels label1,label2 \
    --created DATE \
    --use_identity \{IDENTITY JSON\} \
    --use_extractions EXTRACTION1,EXTRACTION2 \
    --use_aliases ALIAS1,ALIAS2 \
    --use_whitelist WHITELIST1,WHITELIST2

Adding new extractions/lookups/aliases

It is very likely you'll want to extend txt2stix to include new extractions, aliases, and/or lookups. The following is possible:

Currently it is not possible to easily add any other types of extractions (without modifying the logic at a code level).

Detailed documentation

If you would like to understand how txt2stix works in more detail, please refer to the documentation in /docs/README.md.

This documentation is paticularly helpful to read for those of you wanting to add your own custom extractions.

Useful supporting tools

Support

Minimal support provided via the DOGESEC community.

License

Apache 2.0.