fetihcakmak/yara-rule-generator
GitHub: fetihcakmak/yara-rule-generator
一款基于 Python 标准库的 YARA 规则自动生成工具,从文件中提取字符串并按威胁评分排序后自动生成可用的 YARA 检测规则。
Stars: 0 | Forks: 0
██╗ ██╗ █████╗ ██████╗ █████╗
╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
╚████╔╝ ███████║██████╔╝███████║
╚██╔╝ ██╔══██║██╔══██╗██╔══██║
██║ ██║ ██║██║ ██║██║ ██║
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
██████╗ ███████╗███╗ ██╗
██╔════╝ ██╔════╝████╗ ██║
██║ ███╗█████╗ ██╔██╗ ██║
██║ ██║██╔══╝ ██║╚██╗██║
╚██████╔╝███████╗██║ ╚████║
╚═════╝ ╚══════╝╚═╝ ╚═══╝
# 📝 YARA Rule 生成器
[](https://python.org)
[](./)
[](./)
## 📈 项目简介
该工具从文件中提取 ASCII/Wide 字符串,根据威胁分数对它们进行排序,并使用得分最高的字符串自动生成 YARA 规则。
**提交历史:**
| Commit | 描述 |
|--------|----------|
| `string extractor and hash calculator` | 提取 ASCII/Wide 字符串,计算 MD5/SHA256 哈希值,进行威胁评分。 |
| `yara rule builder and condition engine` | 生成 meta/strings/condition 块的 YARA 模板引擎。 |
| `cli interface and rule export engine` | Argparse CLI、演示模式、文件输出和彩色终端。 |
## 🧠 架构
```
main.py
├── generators/string_extractor.py ← ASCII/Wide string çıkarma + tehdit skorlama
├── generators/hash_calculator.py ← MD5/SHA1/SHA256 hesaplama
└── generators/rule_builder.py ← YARA kuralı meta/strings/condition üretici
```
## ⚡ 安装说明
```
git clone https://github.com/fetihcakmak/yara-rule-generator.git
cd yara-rule-generator
python main.py --demo # Ek bağımlılık gerekmez (yalnızca stdlib)
```
## 🚀 使用方法
```
# 演示模式(模拟的 malware 分析)
python main.py --demo
# 实际文件扫描
python main.py --scan malware.exe
# 将规则保存到文件
python main.py --scan sample.bin --output rule.yar --top 20
```
## 🖥️ 示例输出
```
rule demo_malware_sample
{
meta:
author = "fetihcakmak"
description = "Auto-generated YARA rule (8 strings, threat: high)"
threat_level = "high"
md5 = "977e007a23e9c1a7be5394f0e7ee76b0"
sha256 = "00749bb5d39fe0cc28f1381d15d99f43f4aa345600cc347d5ee826bc7d2452f2"
strings:
$s0 = "VirtualAllocEx"
$s1 = "WriteProcessMemory"
$s2 = "CreateRemoteThread"
$s5 = "http://malicious-c2.evil.com/payload"
condition:
4 of ($s0, $s1, $s2, $s3, $s4, $s5, $s6, $s7)
}
```
## ⚠️ 伦理使用
仅对您拥有或被授权进行分析的 malware 样本使用。请将可疑文件保存在隔离/虚拟环境(如 VM、sandbox)中 —— 此工具不会执行文件,仅以静态方式读取其字符串,但您正在检查的样本本身可能具有恶意。
## 📄 许可证
此仓库目前不包含许可证文件。有关使用条款,请联系项目所有者。
*Fetih Çakmak — 网络安全作品集*
标签:DAST, DNS 反向解析, Python, YARA, 云资产可视化, 威胁情报, 开发者工具, 恶意软件分析, 无后门, 自动化生成, 逆向工具