mazen91111/YARA-Rule-Generator
GitHub: mazen91111/YARA-Rule-Generator
基于恶意样本自动生成YARA检测规则的Python工具,通过智能评分系统提取高价值特征并支持批量处理。
Stars: 0 | Forks: 0
# 🧬 YARA-Rule-Generator
## ⚙️ 功能
| 功能 | 详情 |
|---|---|
| 🔡 **智能字符串提取** | 根据恶意软件相关性(API 调用、URL、C2 模式)对字符串进行评分 |
| 🔢 **十六进制模式挖掘** | 提取重复出现的字节序列作为十六进制签名 |
| 📊 **熵值条件** | 为加壳样本添加 `math.entropy()` 条件 |
| 🏷️ **完整元数据块** | SHA-256 哈希、日期、作者、工具归属 |
| 📁 **多文件支持** | 一次性为多个样本生成规则 |
| 💾 **导出为 .yar** | 将合并的规则集保存到 YARA 文件 |
## 🚀 安装
```
git clone https://github.com/mazen91111/YARA-Rule-Generator.git
cd YARA-Rule-Generator
pip install -r requirements.txt
```
## 🧪 用法
```
# 单个样本
python yara_generator.py -f malware.exe
# 多个样本 → 合并 .yar 文件
python yara_generator.py -f sample1.exe sample2.dll -o detection.yar
# 自定义选项
python yara_generator.py -f ransomware.exe --max-strings 15 --hex-patterns 5
```
## 📸 输出示例
```
// YARA Rule generated by YARA-Rule-Generator
// File : suspicious.exe
// SHA-256 : a3f1c9...
// Entropy : 7.81
// Date : 2025-01-01 12:00 UTC
rule detect_suspicious_exe
{
meta:
description = "Auto-generated rule for suspicious.exe"
sha256 = "a3f1c9..."
entropy = "7.81"
author = "mazen91111"
date = "2025-01-01"
tool = "YARA-Rule-Generator"
strings:
$s1 = "VirtualAlloc" ascii wide nocase
$s2 = "CreateRemoteThread" ascii wide nocase
$s3 = "http://192.168.1.100/payload" ascii wide nocase
$b1 = { 55 8B EC 83 EC 10 }
$b2 = { 60 BE 00 10 40 00 }
condition:
5 of them and math.entropy(0, filesize) >= 7.0
}
```
## 🎯 字符串评分系统
字符串根据恶意软件相关性进行评分:
| 模式 | 分数 |
|---|---|
| Win32 API 调用 (`VirtualAlloc`, `CreateRemoteThread`…) | +2 |
| 网络函数 (`socket`, `connect`, `InternetOpen`…) | +2 |
| URL (`http://`, `https://`) | +3 |
| IP 地址 | +2 |
| 加密相关 (`xor`, `encrypt`, `base64`…) | +2 |
| 长度 > 10 个字符 | +1 |
## 👤 作者
**Mazen Obed** — [@mazen91111](https://github.com/mazen91111)
*恶意软件开发 | 红队 | 威胁狩猎*
## ⚠️ 免责声明
## 📄 许可证
MIT License
标签:DeepSeek, Hex模式挖掘, Python, SolidJS, YARA, YARA-Rule-Generator, 云资产可视化, 云资产清单, 数字取证, 无后门, 样本分析, 熵值分析, 签名提取, 网络安全, 网络调试, 自动化, 自动化脚本, 规则生成, 逆向工具, 逆向工程, 隐私保护