mdshoaibuddinchanda/zombieguard
GitHub: mdshoaibuddinchanda/zombieguard
基于机器学习的 ZIP 存档头部规避攻击检测系统,通过结构和熵特征识别解析器混淆技术。
Stars: 1 | Forks: 0
# ZombieGuard
ZombieGuard 是一个用于检测 ZIP 容器中存档头部规避模式的机器学习系统,其中包括 CVE-2026-0866 攻击类别,即声明的头部元数据与实际负载行为相冲突。ZombieGuard 并不充当通用的恶意软件扫描器,而是专注于结构和熵不一致性,这些不一致性表明存在用于绕过静态检查管道的解析器混淆技术。
## ZombieGuard 检测内容
ZombieGuard 检测 ZIP 元数据被故意操纵的存档头部规避攻击。
1. 变体 A - 经典僵尸 ZIP:LFH 声明 STORE,而 CDH 声明 DEFLATE 并包含压缩的负载字节。
2. 变体 B - 仅方法不匹配:LFH 和 CDH 压缩方法不一致,而负载以存储形式存在。
3. 变体 C - Gootloader 拼接:拼接多个 ZIP 容器以制造 EOCD 链歧义。
4. 变体 D - 多文件诱饵容器:看似良性的条目隐藏了一个结构性规避负载条目。
5. 变体 E - CRC 不匹配:LFH CRC 值与 CDH CRC 不同,以混淆验证器信任路径。
6. 变体 F - 扩展字段噪声:扩展字段中的垃圾字节移动了解析器偏移量和边界假设。
7. 变体 G - 高压缩不匹配:高压缩负载与误导性的 STORE 声明配对。
8. 变体 H - 大小字段不匹配:LFH 压缩大小元数据与 CDH/负载实际情况冲突。
## 结果
### XGBoost 分类器 - 留出测试集(530 个样本)
| Accuracy | Precision | Recall | F1 | ROC-AUC |
|:--------:|:---------:|:------:|:------:|:-------:|
| 0.9849 | 0.9962 | 0.9741 | 0.9850 | 0.9980 |
### 真实世界验证 - 157 个 MalwareBazaar 样本
| Signal Type | Count | Share |
|------------------------------------------------|-------:|-----------:|
| Gootloader-style EOCD chaining (EOCD > 1) | 67 | 42.7% |
| LFH/CDH method mismatch (CVE-2026-0866 class) | 1 | 0.6% |
| Undefined LFH method code | 1 | 0.6% |
| **Total header evasion detected** | **69** | **43.9%** |
| Non-header-evasion ZIP malware (outside scope) | 88 | 56.1% |
## 项目结构
```
zombieguard/
├── src/ # Core detection, training, explainability, and study modules
│ ├── extractor.py # ZIP structural + entropy feature extraction
│ ├── classifier.py # XGBoost training/inference pipeline
│ ├── detector.py # CLI detector (single-file and batch)
│ ├── entropy.py # Shannon and Renyi entropy utilities
│ ├── shap_analysis.py # SHAP analysis and figure generation
│ ├── transformer_model.py # Byte-level Transformer baseline
│ └── generalisation_study.py # Cross-format generalization study
├── data/
│ ├── raw/ # Raw benign/malicious ZIP collections (git-ignored)
│ ├── processed/ # features.csv and labels.csv
│ ├── real_world_validation/ # MalwareBazaar validation samples (git-ignored)
│ ├── build_dataset.py # Dataset construction script
│ ├── generate_zombie_samples.py
│ ├── collect_benign.py
│ ├── download_malicious.py
│ └── download_realworld.py
├── tests/
│ ├── fixtures/ # Local test ZIP fixtures
│ ├── test_extractor.py
│ └── test_classifier.py
├── models/ # Saved model artifacts (git-ignored)
├── paper/
│ └── figures/ # SHAP and generalization figures/tables
├── notebooks/ # Analysis notebooks (kept clean)
├── requirements.txt # Project dependencies
└── README.md
```
## 安装
```
git clone https://github.com/mdshoaibuddinchanda/zombieguard
cd zombieguard
uv venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -r requirements.txt
```
## 用法
1. 单文件检测
```
python src/detector.py tests/fixtures/zombie.zip
```
1. 显示特征的详细检测
```
python src/detector.py tests/fixtures/zombie.zip --verbose
```
1. 批量目录扫描
```
python src/detector.py --batch data/real_world_validation/
```
## 数据集
ZombieGuard 目前使用:
- 2647 个总样本
- 8 种结构变体的 1348 个恶意 ZIP 样本
- 来自 PyPI wheels 和生成的干净存档的 1299 个良性 ZIP 样本
- 来自 MalwareBazaar 的 157 个真实世界恶意 ZIP 样本用于流行度验证
从头重新生成:
```
python data/generate_zombie_samples.py
python data/collect_benign.py
python data/download_malicious.py
python data/build_dataset.py
```
## 工作原理
ZombieGuard 使用从 ZIP 内部提取的九个结构和统计特征对每个存档进行评分。
| Feature | Description |
|---------------------------|-----------------------------------------------------------------|
| lf_compression_method | Compression method declared in Local File Header (LFH) |
| cd_compression_method | Compression method declared in Central Directory Header (CDH) |
| method_mismatch | Whether LFH and CDH method fields disagree |
| data_entropy_shannon | Shannon entropy of actual payload bytes |
| data_entropy_renyi | Renyi entropy of payload bytes ($\alpha=2$) |
| declared_vs_entropy_flag | LFH claims STORE but payload entropy looks compressed |
| eocd_count | Number of EOCD signatures (concatenation indicator) |
| file_size_bytes | File size metadata feature used in analysis exports |
| lf_unknown_method | LFH method code not in known ZIP method set |
模型解释工件可在 paper/figures/ 中找到,包括 SHAP 重要性图表和格式泛化图。
## 研究
一篇完整的论文正在准备中,目标是投稿至 IEEE Access 和 Computers & Security。当前的出版物资产,包括 SHAP 图和泛化图表,位于 paper/figures/ 中。
## 重要安全提示
- 本项目仅供授权安全研究和防御验证使用。
- data/real_world_validation/ 下的真实恶意软件样本已通过 .gitignore 从版本控制中排除。
- 切勿将恶意软件样本或活动负载提交到任何公共存储库。
## 引用
```
@software{zombieguard2026,
author = {Md Shoaib Uddin Chanda},
title = {ZombieGuard: ML-Based Archive Header Evasion Detection},
year = {2026},
url = {https://github.com/mdshoaibuddinchanda/zombieguard}
}
```
标签:Apex, CVE-2026-0866, DNS 反向解析, Gootloader, Go语言工具, XGBoost, ZIP文件分析, 二进制分析, 云安全监控, 云安全运维, 威胁情报, 开发者工具, 异常检测, 恶意样本分析, 文件结构分析, 无服务器架构, 机器学习, 熵分析, 私有化部署, 网络安全, 解压缩攻击, 解析器混淆, 逃逸检测, 逆向工具, 防御规避, 隐私保护, 静态分析