该项目是 ProHunter 系统的核心模块,主要用于对从 PPG 模块 采样的威胁图进行恶意判定。该方法的核心思想是利用非精确图向量匹配,计算威胁图与由 CTI 生成的攻击查询图之间的向量相似度,从而产生用于判定的威胁分数。框架如下图所示。
注意: 本项目作为 PPG 的下游检测模块,即攻击表示与匹配(Attack Representation & Matching)。有关包含溯源图存储和威胁图采样在内的完整工作流程,请先参阅 PPG 模块。
Python 版本: 3.7.12
# Clone the repository
git clone https://github.com/xueboQiu/ProHunter
cd ProHunter
# Install dependencies
pip install -r requirements.txt
对 PPG 模块采样的威胁图进行可视化。
用法:
将威胁图数据放入相应的数据集目录:
dataset/darpa_cadets/sgs_demo/sce041214_E5A15412-68E0-FD54-A068-DD6114FD9040_2.txt # The case provided for visualization
准备映射文件(例如 names.json),该文件可通过运行 dataset_preprocess.py 自动生成(参见威胁检测模块的工作流程)
修改 subgraph_vision.py 中的数据集路径,并运行可视化脚本:
python subgraph_vision.py
在脚本中指定相应的数据集。程序将自动从 sgs_demo 目录中读取并可视化子图数据。
可视化结果示例:
将下载的文件按以下结构放入项目目录:
datasets/darpa_{dataset_name}/raws/xx.json
python preprocess/dataset_preprocess.py # Extract triple information from raw datasets:
这将生成元组文件,位于:
datasets/darpa_{dataset_name}/tuples/xx.txt
python preprocess/parse_trace.py
python pretrain_gmpt_cl.py --mode={dataset_name} --eval=False
注意: 其他参数(例如 epoch、学习率)可在 util.py 的 parse_args() 函数中找到。
python pretrain_gmpt_cl.py --mode={dataset_name} --eval=True
模型将从 models/{dataset_name}/best.pth 加载模型参数。
本项目提供了预处理后的 CADETS 数据集样本,可用于即时测试:
# Direct evaluation (using pre-trained model)
python pretrain_gmpt_cl.py --mode=cadets --eval=True
# Re-train the model
python pretrain_gmpt_cl.py --mode=cadets --eval=False
python pretrain_gmpt_cl.py --mode=cadets --eval=True
示例评估结果:
ProHunter/
├── dataset/
│ └── darpa_cadets/ # Example dataset
│ ├── raws/ # Raw dataset files
│ ├── sgs_demo/
│ ├── test/
│ ├── train/
│ ├── tuples/ # Extracted tuples
│ ├── edge_type_map.json
│ ├── names.json # UUID to name mapping
│ ├── node_type_map.json
│ └── types.json # UUID to type mapping
├── models/
│ └── {dataset_name}/
│ └── best.pth # Trained model parameters
├── preprocess/ # Data preprocessing scripts
├── subgraph/
├── batch.py
├── darpa_loader.py # DARPA data loader
├── darpa_model.py
├── dataloader.py # Data loading utilities
├── graph_matching.py
├── pretrain_gmpt_cl.py # Main training & evaluation script
├── splitters.py
├── util.py # Utility functions & arguments
├── requirements.txt # Dependencies
└── readme.md
| 数据集 | 日志文件 | 平台 | 下载链接 |
|---|
| E3-Cadets | ta1-cadets-e3-official-1.json.{0-4} | FreeBSD | DARPA E3 |
| E3-Theia | ta1-theia-e3-official-6r.json.{0-12} | Linux | DARPA E3 |
| E3-Trace | ta1-trace-e3-official.json.{0-203} | Linux | DARPA E3 |
| E5-Theia | ta1-theia-1-e5-official-2.bin.{27-31} | Linux | DARPA E5 |
| E5-Clearscope2_1 | ta1-clearscope-2-e5-official-1.bin.{15-20} | Android | DARPA E5 |
| E5-Clearscope2_2 | ta1-clearscope-2-e5-official-1.bin.{24-33} | Android | DARPA E5 |
| OPTC | benign/20-23Sep19/AIA-201-225/{*} | Windows | OpTC |