ti-yara-hunting
它能做什么
这项技能说明如何把恶意软件样本和分析笔记转化为能够匹配文件的 YARA 规则。适合编写检测规则的恶意软件分析人员和安全团队。
适用场景
- ✓当分析人员要求智能体根据其分析过的恶意软件样本编写 YARA 规则时。
- ✓当智能体需要调整规则,使其运行快速且不会匹配过多正常文件时。
- ✓当团队想用一条已批准的规则在大量文件中搜索变种时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/ti-yara-hunting/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请根据这个样本中的字符串和行为编写一条 YARA 规则,并检查它不会匹配正常文件?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体从样本中挑选有辨识度的字符串和结构,编写规则,检查语法,并用干净和恶意的样本集进行测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
YARA Hunting
Write YARA rules from malware samples, behavioral observations, and threat intelligence reports. Deploy rules for retrohunting across VirusTotal (500M+ files) and ANY.RUN (2TB malware corpus) to discover campaign variants, earlier versions, and related infrastructure.
Quick Reference
# Install YARA
apt-get install -y yara || pip install yara-python
# Install YARA-X (Rust rewrite — faster, stricter)
cargo install yara-x
# Install yarGen for automated rule generation
git clone https://github.com/Neo23x0/yarGen.git /opt/yarGen
cd /opt/yarGen && pip install -r requirements.txt
python3 yarGen.py --update # Download goodware string DB (first run only)
# Scan a file with a rule
yara /workspace/rules/suspect.yar /workspace/samples/
# Compile rules for faster scanning
yarac /workspace/rules/*.yar /workspace/rules/compiled.yarc
yara /workspace/rules/compiled.yarc /workspace/samples/
# Validate rule syntax (YARA-X — stricter parser)
yr check /workspace/rules/suspect.yar
MITRE ATT&CK Mapping
| Technique | ID | Relevance |
|---|---|---|
| Obtain Capabilities: Exploits | T1588.005 | YARA identifies exploit tools/payloads in attacker arsenals |
| Develop Capabilities: Malware | T1587.001 | Rules detect custom malware based on unique strings/structures |
| Gather Victim Host Information: Software | T1592.002 | YARA scans reveal installed malware on victim hosts |
| Indicator Removal on Host | T1070 | Retrohunting finds samples attackers attempted to erase |
1. YARA Rule Syntax
Minimal Rule Structure
rule Malware_FamilyName_Variant {
meta:
author = "Decepticon TI"
date = "2025-01-01"
description = "Detects FamilyName variant based on unique strings"
hash = "e3b0c44298fc1c149afbf4c8996fb924..."
reference = "https://report-url"
tlp = "WHITE"
strings:
$s1 = "unique_string_from_sample" ascii wide
$s2 = { 4D 5A 90 00 03 00 00 00 } // MZ header + specific bytes
$s3 = /https?:\/\/[a-z0-9\-\.]+\/gate\.php/ nocase
condition:
uint16(0) == 0x5A4D and // PE file check
filesize < 5MB and
2 of ($s*)
}
String Types
strings:
// Text strings
$text1 = "CreateRemoteThread" // ASCII exact
$text2 = "CreateRemoteThread" ascii wide // Both encodings
$text3 = "http://c2.evil.com" nocase // Case insensitive
$text4 = "cmd /c" fullword // Word boundary match
// Hex strings (byte patterns)
$hex1 = { 48 8B 05 ?? ?? ?? ?? } // ?? = any byte (wildcard)
$hex2 = { 4D 5A [0-200] 50 45 00 00 } // Jump 0-200 bytes
$hex3 = { ( 74 | 75 ) 0? } // Alternation: je or jne
// Regex strings
$re1 = /https?:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?\/[a-z]+\.php/
$re2 = /[A-Za-z0-9+\/]{50,}={0,2}/ // Base64 blob
// XOR-encoded strings (YARA 4.0+)
$xor1 = "This program cannot" xor // All single-byte XOR keys
$xor2 = "config_url" xor(0x01-0xFF) // Specific XOR range
// Base64-encoded strings (YARA 4.0+)
$b64 = "powershell" base64 base64wide
Condition Essentials
condition:
// File type guards (always lead with these)
uint16(0) == 0x5A4D // PE (MZ header)
uint32(0) == 0x464C457F // ELF
uint16(0) == 0x4B50 // ZIP/DOCX/XLSX (PK)
// String matching
all of them // Every string must match
any of them // At least one
2 of ($s*) // 2+ from $s group
3 of ($api*) and 1 of ($str*) // Mixed groups
#s1 > 5 // $s1 appears 5+ times
// Size + offset constraints
filesize < 1MB
$mz at 0 // $mz must be at offset 0
$s1 in (0..1024) // $s1 in first 1KB
// PE module (import pe)
pe.imports("kernel32.dll", "VirtualAlloc")
pe.number_of_sections > 6
// Math module (import math)
math.entropy(0, filesize) > 7.0 // High entropy (packed)
// Typical combined condition
uint16(0) == 0x5A4D and filesize < 2MB and
(2 of ($s*) or all of ($api*))
2. Writing Rules from Malware Samples
Step-by-Step: Sample to Rule
# Step 1: Extract strings from sample
strings -n 6 /workspace/samples/<SAMPLE> > /
常见问题
什么是 YARA 规则?
它是一种模式文件,用于描述恶意软件的特征,例如文本字符串或文件结构,以便扫描器找到匹配项。
为什么要用正常文件测试?
该技能指出,匹配大量正常文件的规则会产生大量干扰,浪费分析人员的时间。
该技能提到了哪些工具?
它提到了 YARA、YARA-X,以及用于生成规则的 yarGen 工具。
详情
作者的原始描述
YARA rule writing from behavioral observations and TI report analysis — sample-to-rule conversion, condition optimization, performance tuning, and retrohunting on VirusTotal and ANY.RUN. Covers YARA/YARA-X syntax, yarGen automated generation, and production rule deployment.
热度
- GitHub 星标
- 6.5k
- 排名
- #13978
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …