Building datasets from scratch¶
PIDSMaker downloads preprocessed versions of all its datasets. This guide builds them yourself, for instance to change the parsing: the provenance datasets from the official DARPA files, and the network datasets (LANL and the network flows of OpTC) from the preprocessed files of LARES. The scripts write Parquet datasets with the tables and columns of the downloaded ones, without any database server.
Plan for time and disk space
Downloading, uncompressing and parsing raw files takes hours and a lot of storage, especially for E5 datasets and OpTC flows: the raw files take much more space than the datasets, and the scripts write temporary files (unsorted events) about as large as the dataset. The events are sorted with DuckDB, which uses up to 80% of the RAM and spills the rest to disk (about 85 GB of RAM for the 1.9 billion events of optc_net, built in 42 minutes). Running experiments takes more: a single run can produce more than 15 GB of artifacts on E3 datasets, and much more on E5.
The node tables of a dataset built from scratch are in the order in which the scripts write them, which can differ from the order of the downloaded datasets: features, which depend on this order, can differ slightly from those of the downloaded dataset.
The scripts are in the repository: install PIDSMaker from source (pip install -e .) and run them from its root.
Both kinds of datasets follow the same five steps. Pick your dataset in the tabs of each step.
1. Download the raw files¶
Create an empty folder for the raw data:
Note
DATA_FOLDER must be empty before downloading and parsing a dataset. Remove the files of a previous dataset first.
DATASET is one of clearscope_e3, cadets_e3, theia_e3, clearscope_e5, cadets_e5 or theia_e5, and DATA_FOLDER is the absolute path of the output folder. The datasets built in step 4 are CADETS_E3, THEIA_E3, CADETS_E5 and THEIA_E5, whose files are listed in dataset_preprocessing/darpa_tc/filelist.py.
DATASET is one of optc_h051, optc_h201 or optc_h501, and DATA_FOLDER is the absolute path of the output folder.
Downloading the files manually¶
For DARPA TC, you can also pick the files by hand on Google Drive. All files go in DATA_FOLDER:
- Data: all the
.gzfiles of the dataset, from the E3 or E5 folder. - Java consumer:
ta3-java-consumer.tar.gz, which converts the Avro files, for E3 or E5. - Schema: the
.avdland.avscfiles, for E3 or E5.
From the command line, use gdown with the ID of each file, taken from its URL. If a download stops, press Ctrl+C and re-run the same command with --continue.
For the network datasets, LANL can also be built from its official files, requested on the LANL website (authentications only, see step 4), and the official network flows of OpTC (ecar-bro folder of its Google Drive) are downloaded with:
2. Get Java for DARPA TC¶
The raw files of DARPA TC are Avro files, converted to JSON by the Java consumer of DARPA, which needs Java 8 and Maven. Install them in your conda environment, or with the package manager of your system (e.g. sudo apt install openjdk-8-jdk maven):
The other datasets need nothing more than PIDSMaker.
3. Extract the files¶
4. Build the dataset¶
Each script writes a dataset to <datasets_dir>/<database>/, where PIDSMaker reads it: --datasets_dir, else $PIDSMAKER_DATASETS_DIR, else ~/.cache/pidsmaker/datasets (see Where files are stored), and the database of the dataset, e.g. cadets_e3. The dataset is written to <database>.tmp and renamed once complete. An existing dataset, e.g. a downloaded one, is only replaced with --overwrite.
python dataset_preprocessing/darpa_tc/create_database_e3.py orthrus DATASET --raw_dir ${DATA_FOLDER}
DATASET is CADETS_E3 or THEIA_E3.
python dataset_preprocessing/darpa_tc/create_database_e5.py orthrus DATASET --raw_dir ${DATA_FOLDER}
DATASET is CADETS_E5 or THEIA_E5.
DATASET is one of optc_h051, optc_h201 or optc_h501.
python dataset_preprocessing/lanl/create_database_lanl.py LANL --lares_dir ${DATA_FOLDER}/lanl_optc_datasets/LANL/preprocessed
This builds the lanl dataset with the NTLM authentications of the LANL "Comprehensive, Multi-Source Cyber-Security Events" dataset, as used by Euler, Argus, Jbeil and LARES. Add --with_flows to also load its network flows.
From the official files of LANL instead (authentications only):
python dataset_preprocessing/lanl/create_database_lanl.py LANL --auth_file ${DATA_FOLDER}/auth.txt.gz --redteam_file ${DATA_FOLDER}/redteam.txt.gz
LANL timestamps are seconds from an undisclosed origin. They are mapped to UTC dates such that the first red team event happens on 2015-01-03: by default, models are trained on 2015-01-01, validated on 2015-01-02 and tested from 2015-01-03 to 2015-01-30.
python dataset_preprocessing/optc/create_database_optc_net.py OPTC_NET --lares_dir ${DATA_FOLDER}/lanl_optc_datasets/OPTC/preprocessed
This builds the optc_net dataset with the FLOW START and FLOW MESSAGE events of all the hosts of DARPA OpTC (about 1.9 billion events). Files are read by --num_workers processes (16 by default), each writing its events to temporary files, which are then sorted into the dataset. As in LARES and Argus, graphs are built from FLOW START events only: set construction.operations=all to also use FLOW MESSAGE events, or a comma-separated list of operations (e.g. construction.operations=FLOW_START) to select events of any dataset.
Labels. A flow is recorded several times in OpTC (FLOW START and FLOW MESSAGE events, by the hosts at both ends), and LARES labels only some of these records: e.g. in the lateral movement of 2019-09-24, the FLOW MESSAGE events of 561 flows are malicious but the FLOW START of only 56 of them. By default, the script labels malicious all the records of a malicious flow (same 5-tuple, in either direction, in the same LARES file): 5,165 malicious events (1,015 FLOW START) instead of 2,370 (115 FLOW START). Add --no_label_propagation to keep the labels of LARES as they are. A dataset built without propagation can be relabelled in place with --relabel; graphs built before must then be built again (the labels of edges are stored in the graphs).
5. Check the result¶
Run a system on the new dataset:
Sharing a dataset¶
A dataset is a folder, <datasets_dir>/<database>/, with a manifest.json and the Parquet files of its tables: copy the folder to share it. To publish it on Hugging Face, as the datasets of PIDSMaker, upload the folder to a dataset repository (hf upload-large-folder REPO <folder> --repo-type dataset, with one folder per database at the root of the repository), and download it with pidsmaker download DATASET --repo REPO.
Adding a new dataset
To add a dataset that PIDSMaker does not support yet, provenance or network, see Adding custom datasets.