executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
re-iocIOC 提取与 YARA 规则、报告结构。 触发词:IOC、YARA、写规则、分析报告、hash列表
Independent GitHub snapshot · Automated classification · Original documentation governs
本技能以静态处理为主(写规则/扫描文件),不运行样本;运行样本只在 [[re-sandbox]] 内(默认沙箱最高原则,见 [[re-analyze/platform-tips]])。
apt install yara / dnf install yara / pacman -S yarabrew install yarapip install yara-python(Python 版,跨平台兜底)yara --version;Python: python -c "import yara; print(yara.__version__)"pip install pefilepython -c "import pefile; print(pefile.__version__)"curl -s --request GET \
--url "https://www.virustotal.com/api/v3/search?query=<sha256>" \
-H "x-apikey: $VT_API_KEY" | python3 -m json.tool
验证: 带 key 的请求返回 JSON(401 说明 key 无效)按顺序执行,每步记下结果。
提取 IOC(按来源分类):
sha256sum sample.exe(sha256 为主,md5 仅辅助);脱壳产物、dropper 落盘文件各算一份strings sample | grep -iE 'http|https')YARA 规则编写(特征选择 + 评分):
{ 4D 5A 90 00 } 或 $a = { E8 ?? ?? ?? ?? } 通配)rule Win32_FamilyX_Dropper {
meta:
description = "FamilyX dropper 检测"
author = "analyst"
score = 4
strings:
$url = "http://c2.example.org" ascii wide
$mutex = "Global\\FamilyX_mutex" ascii wide
$pe = { 4D 5A 90 00 }
condition:
uint16(0) == 0x5A4D and (2 of them)
}
Win32_FamilyX_Dropper)报告结构(按五段写):
规则验证(yara 扫描样本):
yara rule.yar sample.exe # 命中 → 规则有效
yara -s rule.yar sample.exe # 显示命中的特征串,与样本实际内容核对
yara rule.yar benign_samples/* # 误报测试: 已知良性样本目录应 0 命中
yara -s 核对命中串确属恶意特征http:// 或常见库字符串);原因——特征不唯一,无评分与验证环节;对策——步骤 2 按唯一性选特征并打分,步骤 4 必须做良性样本阴性对照,误报即回改2 of them 而非单特征yr debug atoms(YARA-X)检查 atom,正则锚定字面量(/mshta\.exe http:\/\/.../ 而非 /http:/),条件顺序由廉到贵(filesize → magic → strings),"能用 uint32 就别加载模块"--excludegood / FLOSS 生成,回归用 YARA-CI / VT retrohuntMAL_/HKTL_/SUSP_ 等前缀 + 平台/家族/变体/日期(如 MAL_Win_Emotet_Loader_Jan25)for all 循环未绑 filesize → 大文件扫描爆炸:现象——规则在小样本上飞快,扫几十 MB 大文件卡死/超时;原因——for all i in (1..#a) 循环的迭代上限绑定特征命中次数,大文件上 #a 可达数千,for all i in (1..filesize) 一类写法迭代规模直接随文件大小膨胀;对策——循环条件一律先加 filesize 边界(filesize < 100KB and for all i in (1..#a): ...),再放特征条件yara 扫描报 string ... caused too many matches 错误,规则无法运行;原因——特征串是长重复/均匀内容(如 "2222..."、宽字符空格填充),预过滤阶段命中数爆炸触发 YARA 保护上限;对策——避免重复字符堆叠的内容做特征,改用带通配的 hex 模式或含多变字节的串,保证 atom 有区分度(与既有 atom 坑配合检查)