编程

S³ YARA Rule Authoring

试用

Write high-quality YARA-X detection rules for malware identification and threat hunting. Covers naming conventions, string selection, performance optimizatio...

它能做什么

Write detection rules that catch malware without drowning in false positives. Based on Trail of Bits methodology.

技能文档

YARA-X Rule Authoring

Write detection rules that catch malware without drowning in false positives. Based on Trail of Bits methodology.

Core Principles

  1. 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 scans.
  2. Target specific families, not categories — "Detects ransomware" is useless. "Detects LockBit 3.0 config extraction routine" is useful.
  3. Test against goodware — Validate against clean file sets before deployment.
  4. Short-circuit with cheap checks firstfilesize < 10MB and uint16(0) == 0x5A4D before expensive string searches.
  5. Metadata is documentation — Future you needs to know what this catches and why.

YARA-X Basics

YARA-X is the Rust successor to legacy YARA: 5-10x faster, better errors, built-in formatter, stricter validation, new modules (crx, dex).

Install: brew install yara-x / cargo install yara-x Commands: yr scan, yr check, yr fmt, yr dump

Rule Template

import "pe"

rule FamilyName_Variant_Technique : tag1 tag2 {
    meta:
        author      = "Solomon Neas"
        date        = "2026-02-14"
        description = "Detects [specific behavior] in [malware family]"
        reference   = "https://..."
        tlp         = "TLP:WHITE"
        hash        = ""
        score       = 75  // 0-100 confidence

    strings:
        // Unique strings from the sample
        $api1 = "VirtualAllocEx" ascii
        $api2 = "WriteProcessMemory" ascii
        $str1 = { 48 8B 05 ?? ?? ?? ?? 48 85 C0 }  // hex with wildcards
        $pdb  = /[A-Z]:\\.*\\Release\\.*\.pdb/ nocase

    condition:
        uint16(0) == 0x5A4D and
        filesize < 5MB and
        (2 of ($api*) and $str1) or
        $pdb
}

Naming Convention

Family_Variant_Technique — examples:

  • Emotet_Loader_DocumentMacro
  • CobaltStrike_Beacon_x64
  • Generic_Cryptominer_XMRig

String Selection

Good strings (unique, specific):

  • Mutex names, PDB paths, C2 URLs
  • Unique byte sequences from disassembly
  • Custom encryption constants
  • Uncommon API call sequences

Bad strings (too common, high FP):

  • http://, https://, common API names alone
  • Single common words, short strings (<4 bytes)
  • Strings found in Windows system files

Condition Patterns

// Performance-ordered (cheap → expensive)
condition:
    uint16(0) == 0x5A4D and     // Magic bytes (instant)
    filesize < 10MB and          // Size filter (instant)
    2 of ($unique*) and          // String matching (fast)
    pe.imports("kernel32.dll")   // Module check (slower)

Common magic bytes:

PlatformCheck
PE (Windows)uint16(0) == 0x5A4D
ELF (Linux)uint32(0) == 0x464C457F
Mach-O 64-bituint32(0) == 0xFEEDFACF
PDFuint32(0) == 0x25504446
Office/ZIPuint32(0) == 0x504B0304

Performance Rules

  1. Put filesize and magic byte checks FIRST in condition
  2. Never use unbounded regex like /.*/
  3. Avoid for all with complex conditions on large files
  4. Use ascii or wide, not both unless needed
  5. Hex strings with specific bytes > wildcards > regex
  6. Use at for fixed offsets instead of scanning entire file

Testing

# Validate syntax
yr check rules/

# Scan a sample
yr scan rules/my_rule.yar suspicious_file.exe

# Scan directory
yr scan rules/ samples/ --threads 4

# Format rules consistently
yr fmt rules/my_rule.yar

False Positive Reduction

  • Add filesize constraints (malware has typical size ranges)
  • Require multiple string matches (2 of ($str*) not any of)
  • Exclude known good paths/publishers via not conditions
  • Score-based approach: assign confidence scores in metadata, triage by threshold
  • Test against goodware corpus before deployment

Reference

Full methodology, module docs (pe, elf, crx, dex), and migration guide from legacy YARA: https://github.com/trailofbits/skills/tree/main/plugins/yara-authoring

相关技能

按用户明确指令,在得到大脑(Get笔记)中保存、搜索并管理笔记与知识库。

作者 iswalle763 次安装66 星标

为 Codex 生成一个可在任意目录运行的持久 CLI,包含可组合的读/写子命令和稳定的 JSON 输出。

作者 OpenAI27.5k 星标

为新建或现有 ASP.NET Core 项目挑选合适的应用模型,并按 Microsoft 最新文档规范组织 Program.cs、中间件和服务。

作者 OpenAI27.5k 星标

figma-use

官方

在调用 `use_figma` MCP 工具前加载,获得运行 Figma Plugin API 脚本的完整规则集。

作者 OpenAI27.5k 星标

基于算法哲学生成原创 p5.js 艺术作品,支持种子随机与参数调节。

作者 Anthropic177.5k 星标

创建、修改并量化评估 agent 技能,与无技能基线对比运行

作者 Anthropic177.5k 星标

solomonneas 的更多技能

浏览全部技能

Essential penetration testing command reference. Quick lookup for nmap, Metasploit, hydra, john, nikto, gobuster, and other offensive security tools. Covers...

作者 Solomon Neas65 次安装1 星标

Memory forensics with Volatility and related tools. Acquire RAM dumps, extract processes and DLLs, investigate rootkits and fileless malware, recover credent...

作者 solomonneas30 次安装1 星标

This skill should be used when the user asks to "run pentest commands", "scan with nmap", "use metasploit exploits", "crack passwords with hydra or john", "s...

作者 solomonneas36 次安装

Expert malware analysis for defensive security research. Static and dynamic analysis, sandbox triage, IOC extraction, unpacking, and malware family identific...

作者 solomonneas31 次安装

Knowledge card memory system with semantic search. Agents wake up fresh each session but remember everything through atomic ~350-token cards with YAML frontm...

作者 solomonneas28 次安装

Network traffic analysis with Wireshark and tshark. Capture packets, write display and BPF filters, follow TCP/UDP/TLS streams, detect C2 beacons, troublesho...

作者 solomonneas27 次安装