yara-rule-authoring
できること
YARA-X形式で、マルウェアの検出ルールを書く作業を案内します。特定のマルウェアの署名を書いたり確認したりするセキュリティアナリストや脅威ハンターの人向けです。
使う場面
- ✓特定のマルウェアファミリーを見つけるための新しいYARAルールを書くとき。
- ✓既存のYARAルールが通常のファイルにも反応し、誤検知を減らしたいとき。
- ✓古いYARAルールをYARA-Xに移行しているとき。
スキルのリンク
https://github.com/trailofbits/skills/blob/main/plugins/yara-authoring/skills/yara-rule-authoring/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“通常のWindowsファイルに一致させずに、このマルウェアファミリーを検出するYARA-Xのルールを書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、命名、文字列の選び方、性能についての判断を案内します。ルールを検査し、展開の前に確認するスクリプトも含まれています。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
YARA-X Rule Authoring
Write detection rules that catch malware without drowning in false positives.
Resolve the linter, atom analyzer,
and review helper from this installed SKILL.md's directory.
In commands below, replace each <resolved-...-path> with that script's absolute
path and keep the quotes. The rule file or directory is still relative to your
working directory unless you pass an absolute input path.
This skill targets YARA-X, the Rust-based successor to legacy YARA — 5-10x faster regex, better errors, built-in formatter, stricter validation, new modules (crx, dex), 99% rule compatibility. It powers VirusTotal's production systems. Install with brew install yara-x or cargo install yara-x; the CLI is yr. See Migrating from Legacy YARA for existing rules.
Core Principles
Strings must generate good atoms — YARA extracts 4-byte subsequences for fast matching. Strings with repeated bytes, common sequences, or under 4 bytes force slow bytecode verification on too many files.
Target specific families, not categories — "Detects ransomware" catches everything and nothing. "Detects LockBit 3.0 configuration extraction routine" catches what you want.
Test against goodware before deployment — A rule that fires on Windows system files is useless. Validate against VirusTotal's goodware corpus or your own clean file set.
Short-circuit with cheap checks first —
filesize(instant), then magic bytes (nearly instant), then strings (cheap), then modules (expensive).Metadata is documentation — Future you (and your team) need to know what this catches, why, and where the sample came from.
When to Use
- Writing new YARA-X rules for malware detection
- Reviewing existing rules for quality or performance issues
- Optimizing slow-running rulesets
- Converting IOCs or threat intel into detection signatures
- Debugging false positive issues
- Preparing rules for production deployment
- Migrating legacy YARA rules to YARA-X
- Analyzing Chrome extensions (crx module) or Android apps (dex module)
When NOT to Use
- Static analysis requiring disassembly → use Ghidra/IDA skills
- Dynamic malware analysis → use sandbox analysis skills
- Network-based detection → use Suricata/Snort skills
- Memory forensics with Volatility → use memory forensics skills
- Simple hash-based detection → just use hash lists
Platform Considerations
YARA works on any file type. Adapt patterns to your target:
| Platform | Magic Bytes | Bad Strings | Good Strings |
|---|---|---|---|
| Windows PE | uint16(0) == 0x5A4D |
API names, Windows paths | Mutex names, PDB paths |
| macOS Mach-O | uint32(0) == 0xFEEDFACE (32-bit), 0xFEEDFACF (64-bit), uint32be(0) == 0xCAFEBABE (universal) |
Common Obj-C methods | Keylogger strings, persistence paths |
| JavaScript/Node | (none needed) | require, fetch, axios |
Obfuscator signatures, eval+decode chains |
| npm/pip packages | (none needed) | postinstall, dependencies |
Suspicious package names, exfil URLs |
| Office docs | uint32(0) == 0x04034B50 |
VBA keywords | Macro auto-exec, encoded payloads |
| VS Code extensions | (none needed) | vscode.workspace |
Uncommon activationEvents, hidden file access |
| Chrome extensions | Use crx module |
Common Chrome APIs | Permission abuse, manifest anomalies |
| Android apps | Use dex module |
Standard DEX structure | Obfuscated classes, suspicious permissions |
uintNN()reads little-endian. Write the constant as the bytes reversed, or useuintNNbe()and write them in file order. A ZIP/OOXML file starts with bytes50 4B 03 04, so it isuint32(0) == 0x04034B50—uint32(0) == 0x504B0304compiles cleanly and never matches anything. The same trap catches Mach-O universal binaries: on disk they areCA FE BA BE, souint32(0) == 0xCAFEBABEis a dead branch; writeuint32be(0) == 0xCAFEBABEoruint32(0) == 0xBEBAFECA. Verify withyr scanagainst one known-good sample before trusting any magic-byte check.
macOS Malware Detection
No dedicated Mach-O module exists yet — use magic bytes plus string patterns. Good indicators:
- Keylogger artifacts:
CGEventTapCreate,kCGEventKeyDown - SSH tunnel strings:
ssh -D,tunnel,socks - Persistence paths:
~/Library/LaunchAgents, `/Library/Lau
よくある質問
文字列の選び方がなぜ重要ですか?
短い文字列や繰り返し出る文字列は、多くのファイルのスキャンを遅くするため、このスキルはより特徴的な文字列を選ぶよう導きます。
ルールは使う前にテストすべきですか?
はい。展開の前に、通常のソフトウェアに対してルールをテストするよう、このスキルは勧めています。
YARA-Xはどうインストールしますか?
HomebrewまたはCargoでのインストールに触れています。コマンドラインツールはyrと呼ばれます。
詳細
作者による元の説明
Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.
repo: trailofbits/skills
人気
- GitHubのスター
- 8.0k
- ランキング
- #12742
- ライセンス
- CC-BY-SA-4.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
audit-context-building
8.0kエージェントが、セキュリティ監査の前に、見慣れないコードベースを学べるよう支援します。各関数が何を前提とし、何を保証し、何に依存しているかを整理します。
algorand-vulnerability-scanner
8.0kエージェントが、TEALやPyTealで書かれたAlgorandのスマートコントラクトを、リレーキー攻撃や未検査の手数料など、11種類の一般的なセキュリティ問題について検査できるよう支援します。
audit-prep-assistant
8.0kエージェントが、外部のセキュリティレビューに向けてコードベースを準備できるよう支援します。静的解析、テストカバレッジ、不要コードの整理、分かりやすい文書化を含みます。
cairo-vulnerability-scanner
8.0kエージェントが、StarkNet上のCairoのスマートコントラクトを、算術オーバーフロー、危険なレイヤー間メッセージ、署名のリプレイなど、6つの深刻な問題について検査できるよう支援します。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。