[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M797VRTZK6FAPRMV5C44NNXT":3,"skill-same:01M797VRTZK6FAPRMV5C44NNXT":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M797VRTZK6FAPRMV5C44NNXT","ti-yara-hunting",null,"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\u002FYARA-X syntax, yarGen automated generation, and production rule deployment.","7ShIkI3\u002FDecepticon-x-DarkTriad","7ShIkI3","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78133376?v=4","01M797CTK5AHH2161YVG93NJ3B","Raphael Pascaud","01M797CTKRQS64R01J7E6TJSEM",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fanalyst\u002Fti-yara-hunting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: ti-yara-hunting\ndescription: \"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\u002FYARA-X syntax, yarGen automated generation, and production rule deployment.\"\nallowed-tools: Bash Read Write\nmetadata:\n  subdomain: analyst\n  when_to_use: \"yara, yara rule, yara-x, yargen, retrohunt, retrohunting, virustotal hunting, anyrun yara search, malware signature, malware hunting, yara condition, yara strings, threat hunting rules, livehunt\"\n  tags: \"yara, hunting, threat-intelligence, retrohunt, virustotal, anyrun, malware-detection, yargen\"\n  mitre_attack: \"T1588.005\"\n---\n\n# YARA Hunting\n\nWrite 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.\n\n## Quick Reference\n\n```bash\n# Install YARA\napt-get install -y yara || pip install yara-python\n\n# Install YARA-X (Rust rewrite — faster, stricter)\ncargo install yara-x\n\n# Install yarGen for automated rule generation\ngit clone https:\u002F\u002Fgithub.com\u002FNeo23x0\u002FyarGen.git \u002Fopt\u002FyarGen\ncd \u002Fopt\u002FyarGen && pip install -r requirements.txt\npython3 yarGen.py --update  # Download goodware string DB (first run only)\n\n# Scan a file with a rule\nyara \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fworkspace\u002Fsamples\u002F\n\n# Compile rules for faster scanning\nyarac \u002Fworkspace\u002Frules\u002F*.yar \u002Fworkspace\u002Frules\u002Fcompiled.yarc\nyara \u002Fworkspace\u002Frules\u002Fcompiled.yarc \u002Fworkspace\u002Fsamples\u002F\n\n# Validate rule syntax (YARA-X — stricter parser)\nyr check \u002Fworkspace\u002Frules\u002Fsuspect.yar\n```\n\n## MITRE ATT&CK Mapping\n\n| Technique | ID | Relevance |\n|---|---|---|\n| Obtain Capabilities: Exploits | T1588.005 | YARA identifies exploit tools\u002Fpayloads in attacker arsenals |\n| Develop Capabilities: Malware | T1587.001 | Rules detect custom malware based on unique strings\u002Fstructures |\n| Gather Victim Host Information: Software | T1592.002 | YARA scans reveal installed malware on victim hosts |\n| Indicator Removal on Host | T1070 | Retrohunting finds samples attackers attempted to erase |\n\n## 1. YARA Rule Syntax\n\n### Minimal Rule Structure\n\n```yara\nrule Malware_FamilyName_Variant {\n    meta:\n        author      = \"Decepticon TI\"\n        date        = \"2025-01-01\"\n        description = \"Detects FamilyName variant based on unique strings\"\n        hash        = \"e3b0c44298fc1c149afbf4c8996fb924...\"\n        reference   = \"https:\u002F\u002Freport-url\"\n        tlp         = \"WHITE\"\n\n    strings:\n        $s1 = \"unique_string_from_sample\" ascii wide\n        $s2 = { 4D 5A 90 00 03 00 00 00 }  \u002F\u002F MZ header + specific bytes\n        $s3 = \u002Fhttps?:\\\u002F\\\u002F[a-z0-9\\-\\.]+\\\u002Fgate\\.php\u002F nocase\n\n    condition:\n        uint16(0) == 0x5A4D and    \u002F\u002F PE file check\n        filesize \u003C 5MB and\n        2 of ($s*)\n}\n```\n\n### String Types\n\n```yara\nstrings:\n    \u002F\u002F Text strings\n    $text1 = \"CreateRemoteThread\"           \u002F\u002F ASCII exact\n    $text2 = \"CreateRemoteThread\" ascii wide \u002F\u002F Both encodings\n    $text3 = \"http:\u002F\u002Fc2.evil.com\" nocase    \u002F\u002F Case insensitive\n    $text4 = \"cmd \u002Fc\" fullword              \u002F\u002F Word boundary match\n\n    \u002F\u002F Hex strings (byte patterns)\n    $hex1 = { 48 8B 05 ?? ?? ?? ?? }        \u002F\u002F ?? = any byte (wildcard)\n    $hex2 = { 4D 5A [0-200] 50 45 00 00 }   \u002F\u002F Jump 0-200 bytes\n    $hex3 = { ( 74 | 75 ) 0? }              \u002F\u002F Alternation: je or jne\n\n    \u002F\u002F Regex strings\n    $re1 = \u002Fhttps?:\\\u002F\\\u002F\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d+)?\\\u002F[a-z]+\\.php\u002F\n    $re2 = \u002F[A-Za-z0-9+\\\u002F]{50,}={0,2}\u002F      \u002F\u002F Base64 blob\n\n    \u002F\u002F XOR-encoded strings (YARA 4.0+)\n    $xor1 = \"This program cannot\" xor       \u002F\u002F All single-byte XOR keys\n    $xor2 = \"config_url\" xor(0x01-0xFF)     \u002F\u002F Specific XOR range\n\n    \u002F\u002F Base64-encoded strings (YARA 4.0+)\n    $b64 = \"powershell\" base64 base64wide\n```\n\n### Condition Essentials\n\n```yara\ncondition:\n    \u002F\u002F File type guards (always lead with these)\n    uint16(0) == 0x5A4D                     \u002F\u002F PE (MZ header)\n    uint32(0) == 0x464C457F                 \u002F\u002F ELF\n    uint16(0) == 0x4B50                     \u002F\u002F ZIP\u002FDOCX\u002FXLSX (PK)\n\n    \u002F\u002F String matching\n    all of them                             \u002F\u002F Every string must match\n    any of them                             \u002F\u002F At least one\n    2 of ($s*)                              \u002F\u002F 2+ from $s group\n    3 of ($api*) and 1 of ($str*)           \u002F\u002F Mixed groups\n    #s1 > 5                                 \u002F\u002F $s1 appears 5+ times\n\n    \u002F\u002F Size + offset constraints\n    filesize \u003C 1MB\n    $mz at 0                                \u002F\u002F $mz must be at offset 0\n    $s1 in (0..1024)                        \u002F\u002F $s1 in first 1KB\n\n    \u002F\u002F PE module (import pe)\n    pe.imports(\"kernel32.dll\", \"VirtualAlloc\")\n    pe.number_of_sections > 6\n\n    \u002F\u002F Math module (import math)\n    math.entropy(0, filesize) > 7.0         \u002F\u002F High entropy (packed)\n\n    \u002F\u002F Typical combined condition\n    uint16(0) == 0x5A4D and filesize \u003C 2MB and\n    (2 of ($s*) or all of ($api*))\n```\n\n## 2. Writing Rules from Malware Samples\n\n### Step-by-Step: Sample to Rule\n\n```bash\n# Step 1: Extract strings from sample\nstrings -n 6 \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> > \u002Fworkspace\u002Frules\u002Fstrings_raw.txt\nstrings -n 6 -el \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> >> \u002Fworkspace\u002Frules\u002Fstrings_raw.txt  # Wide strings\n\n# Step 2: Identify unique strings (not in common binaries)\n# Look for: C2 URLs, mutex names, PDB paths, custom error messages,\n# registry keys, file paths, encryption keys, config markers\ngrep -iP '(http|ftp|\\.php|\\.aspx|mutex|pdb|\\\\\\\\Users|HKEY_|config|beacon|payload)' \\\n  \u002Fworkspace\u002Frules\u002Fstrings_raw.txt | sort -u > \u002Fworkspace\u002Frules\u002Fstrings_interesting.txt\n\n# Step 3: Extract hex patterns at key offsets\nxxd \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> | head -50  # File header\nxxd -s 0x400 -l 256 \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>  # Code section start\n\n# Step 4: Check PE imports (if PE file)\npython3 -c \"\nimport pefile\npe = pefile.PE('\u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>')\nfor entry in pe.DIRECTORY_ENTRY_IMPORT:\n    dll = entry.dll.decode()\n    for imp in entry.imports:\n        name = imp.name.decode() if imp.name else str(imp.ordinal)\n        print(f'{dll}:{name}')\n\" > \u002Fworkspace\u002Frules\u002Fimports.txt\n\n# Step 5: Check entropy per section\npython3 -c \"\nimport pefile, math\npe = pefile.PE('\u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>')\nfor s in pe.sections:\n    name = s.Name.rstrip(b'\\x00').decode(errors='replace')\n    data = s.get_data()\n    if data:\n        ent = sum(-p*math.log2(p) for p in [data.count(bytes([b]))\u002Flen(data) for b in range(256)] if p > 0)\n        print(f'{name}: entropy={ent:.2f} size={len(data)}')\n\"\n```\n\n### Template: Rule from Behavioral Observations\n\n```yara\nrule APT_Backdoor_ObservedBehavior {\n    meta:\n        author      = \"Decepticon TI\"\n        date        = \"2025-01-01\"\n        description = \"Backdoor observed during engagement — drops to %TEMP%, \"\n                      \"contacts C2 over HTTPS, exfiltrates via DNS TXT\"\n        tlp         = \"AMBER\"\n\n    strings:\n        \u002F\u002F Observed C2 communication pattern\n        $c2_uri  = \"\u002Fapi\u002Fv1\u002Fcheck\" ascii\n        $c2_ua   = \"Mozilla\u002F5.0 (compatible; MSIE 10.0)\" ascii\n\n        \u002F\u002F Observed mutex (from dynamic analysis)\n        $mutex   = \"Global\\\\{8A4E2C-\" ascii\n\n        \u002F\u002F Observed file drops\n        $drop1   = \"\\\\AppData\\\\Local\\\\Temp\\\\svchost32.exe\" ascii wide\n        $drop2   = \"\\\\ProgramData\\\\Microsoft\\\\updater.dll\" ascii wide\n\n        \u002F\u002F Observed registry persistence\n        $reg     = \"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\" ascii wide\n\n        \u002F\u002F DNS exfiltration pattern (hex-encoded subdomain)\n        $dns_exf = \u002F[0-9a-f]{16,}\\.data\\.[a-z0-9\\-]+\\.(com|net|org)\u002F\n\n        \u002F\u002F Encryption routine bytes (from disassembly)\n        $crypto  = { 8B 45 ?? 33 45 ?? 89 45 ?? 8B 4D ?? 03 4D ?? }\n\n    condition:\n        uint16(0) == 0x5A4D and\n        filesize \u003C 3MB and\n        ($mutex or $crypto) and\n        2 of ($c2_*, $drop*, $reg, $dns_exf)\n}\n```\n\n## 3. Automated Rule Generation with yarGen\n\n```bash\n# Generate rule from single sample\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_output.yar \\\n  --excludegood\n\n# Generate rules from directory of related samples\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002Fcampaign_x\u002F \\\n  -o \u002Fworkspace\u002Frules\u002Fcampaign_x.yar \\\n  --excludegood \\\n  -a \"Decepticon TI\" \\\n  -r \"https:\u002F\u002Fengagement-reference\"\n\n# AI-assisted mode (v0.24.0+) — generates expanded string set with AI prompt\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_ai.yar \\\n  --ai\n\n# Inverse match — generate rule for goodware (detect clean files)\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_output.yar \\\n  --inverse --excludegood\n\n# After generation: review and tighten the rule\n# yarGen over-selects strings — prune to 5-15 high-confidence indicators\n# Add file type checks (uint16(0) == 0x5A4D) and size constraints\n```\n\n### yarGen Output Review Checklist\n\n1. **Remove generic strings** — `\"Microsoft\"`, `\"Windows\"`, `\"kernel32.dll\"` add nothing\n2. **Keep unique artifacts** — PDB paths, mutex names, custom headers, C2 URIs\n3. **Add file type guard** — `uint16(0) == 0x5A4D` for PE, `uint32(0) == 0x464C457F` for ELF\n4. **Add size constraint** — `filesize \u003C 10MB` prevents scanning huge archives\n5. **Tighten condition** — change `all of them` to `N of ($s*)` to tolerate variants\n6. **Test against goodware** — scan `\u002Fusr\u002Fbin\u002F`, `C:\\Windows\\System32\\` for false positives\n\n## 4. Condition Optimization and Performance\n\n1. **Always lead with cheap checks**: `uint16(0) == 0x5A4D and filesize \u003C 5MB and ...`\n2. **Anchor strings to offsets**: `$mz at 0`, `$config in (filesize - 4096 .. filesize)`\n3. **Bound regex**: `\u002F.{0,1000}evil\u002F` causes backtracking; use `\u002Fevil[a-z]{0,20}\\.php\u002F`\n4. **Prefer hex over regex** for bytes: `{ 4D 5A [0-500] 50 45 }` > `\u002F\\x4D\\x5A.{0,500}\\x50\\x45\u002F`\n5. **Threshold matching**: `3 of ($s*)` instead of `all of them` — tolerates variant mutations\n6. **PE module for imports**: `pe.imports(\"ws2_32.dll\", \"connect\")` beats string-matching DLL names\n\n```bash\n# Test for false positives against goodware\nyara -r \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fusr\u002Fbin\u002F 2>\u002Fdev\u002Fnull | wc -l  # Target: 0\nyr scan --profile \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fworkspace\u002Fsamples\u002F  # YARA-X profiling\n```\n\n## 5. TI Report-to-YARA Conversion\n\nUse the `ti-ioc-extraction` skill to extract IOCs from reports, then build YARA:\n- **Hashes** → `meta:` section (for reference\u002Fcorrelation, not detection)\n- **Domains\u002FURLs** → text strings with `ascii nocase`\n- **File paths** → text strings with `ascii wide` (escape backslashes)\n- **Snort\u002FSuricata content matches** → YARA text strings (e.g., `content:\"\u002Fgate.php\"` → `$uri = \"\u002Fgate.php\" ascii`)\n\n## 6. Retrohunting Workflows\n\n### VirusTotal Retrohunt\n\n```bash\n# Submit retrohunt job via API\nVT_API_KEY=\"\u003CAPI_KEY>\"\n\n# Upload rule\ncurl -s -X POST \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\" \\\n  -H \"x-apikey: $VT_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"data\": {\n      \"type\": \"retrohunt_job\",\n      \"attributes\": {\n        \"rules\": \"rule test { strings: $s = \\\"unique_marker\\\" condition: $s }\",\n        \"notification_email\": \"analyst@example.com\",\n        \"corpus\": \"main\",\n        \"time_range\": { \"start\": 1700000000, \"end\": 1710000000 }\n      }\n    }\n  }' > \u002Fworkspace\u002Fhunting\u002Fretrohunt_job.json\n\n# Check job status\nJOB_ID=$(python3 -c \"import json; print(json.load(open('\u002Fworkspace\u002Fhunting\u002Fretrohunt_job.json'))['data']['id'])\")\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\u002F$JOB_ID\" \\\n  -H \"x-apikey: $VT_API_KEY\" | python3 -m json.tool\n\n# Retrieve matches (after job completes — typically 2-3 hours)\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\u002F$JOB_ID\u002Fmatching_files?limit=40\" \\\n  -H \"x-apikey: $VT_API_KEY\" > \u002Fworkspace\u002Fhunting\u002Fretrohunt_matches.json\n```\n\n**VirusTotal Retrohunt Limits:**\n- Corpus: 500M+ files (~680TB), scanned in 2-3 hours\n- Hunting Pro: 12-month lookback | Standard: 3-month lookback\n- Max 300 rules per job, total rule text \u003C 1MB\n- Max 10,000 matches per job\n- LiveHunt (real-time): rules tested against every new upload\n\n### VirusTotal LiveHunt (Real-Time)\n\n```bash\n# Create a LiveHunt ruleset — rules tested against every new VT upload\ncurl -s -X POST \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fhunting_rulesets\" \\\n  -H \"x-apikey: $VT_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"data\":{\"type\":\"hunting_ruleset\",\"attributes\":{\"name\":\"Campaign_X_Tracker\",\"enabled\":true,\"rules\":\"rule Campaign_X { strings: $c2 = \\\"evil-c2.example.com\\\" condition: uint16(0) == 0x5A4D and $c2 }\",\"notification_emails\":[\"analyst@example.com\"]}}}'\n```\n\n### ANY.RUN YARA Search\n\n```bash\n# Web interface: https:\u002F\u002Fyara.any.run\u002F\n# 1. Paste YARA rule into editor (syntax highlighting, multi-tab)\n# 2. Click \"Search\" — scans 2TB malware corpus\n# 3. Results link to sandbox sessions (interactive execution replay)\n# 4. Free tier: 20 YARA Search requests (shared with TI Lookup quota)\n\n# API submission\ncurl -s \"https:\u002F\u002Fapi.any.run\u002Fv1\u002Fyara\u002Fsearch\" \\\n  -H \"Authorization: API-Key \u003CANYRUN_API_KEY>\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"rule\": \"rule test { strings: $s = \\\"unique_marker\\\" ascii condition: $s }\"\n  }' > \u002Fworkspace\u002Fhunting\u002Fanyrun_yara_results.json\n\n# Results include sandbox session UUIDs — open for full analysis:\n# https:\u002F\u002Fapp.any.run\u002Ftasks\u002F\u003CUUID>\n```\n\n### Retrohunting End-to-End\n\n```bash\n# 1. Write rule from engagement sample (Section 2)\n# 2. Validate locally — must match known sample, must NOT match goodware\nyara \u002Fworkspace\u002Frules\u002Fcampaign.yar \u002Fworkspace\u002Fsamples\u002F\nyara \u002Fworkspace\u002Frules\u002Fcampaign.yar \u002Fusr\u002Fbin\u002F 2>\u002Fdev\u002Fnull  # Expect 0 matches\n\n# 3. Submit to VT Retrohunt (historical) + ANY.RUN YARA Search (sandbox corpus)\n# 4. Deploy as VT LiveHunt for ongoing monitoring\n# 5. Collect + deduplicate matches from both platforms\n# 6. Download new samples for deeper analysis\n```\n\n## 7. YARA-X Differences\n\nYARA-X (Rust rewrite) offers stricter parsing, better performance, and multi-line metadata (0.4.0+). Key commands:\n\n```bash\ncargo install yara-x          # Install\nyr check \u002Fworkspace\u002Frules\u002F*.yar  # Validate (catches bugs classic YARA ignores)\nyr scan \u002Fworkspace\u002Frules\u002F*.yar \u002Fworkspace\u002Fsamples\u002F  # Scan\n```\n\nIf classic YARA accepts a rule but YARA-X rejects it, fix the rule — the stricter parser catches real syntax bugs.\n\n## Tools & Resources\n\n| Tool | Purpose | Install\u002FURL |\n|---|---|---|\n| yara | Rule scanning engine | `apt install yara` |\n| yarac | Compile rules to binary | Ships with yara |\n| YARA-X | Rust rewrite — stricter, faster | `cargo install yara-x` |\n| yarGen | Auto-generate rules from samples | `github.com\u002FNeo23x0\u002FyarGen` |\n| yarGen-Go | Go rewrite of yarGen | `github.com\u002FNeo23x0\u002FyarGen-Go` |\n| yara-python | Python bindings | `pip install yara-python` |\n| VT Retrohunt | Scan 500M+ historical files | `virustotal.com` (paid) |\n| VT LiveHunt | Real-time rule matching on uploads | `virustotal.com` (paid) |\n| ANY.RUN YARA Search | Scan 2TB malware corpus | `yara.any.run` |\n| YARA rules repo (ANY.RUN) | Community detection rules | `github.com\u002Fanyrun\u002FYARA` |\n| awesome-yara | Curated rule\u002Ftool list | `github.com\u002FInQuest\u002Fawesome-yara` |\n\n## Detection Signatures\n\n| Rule Pattern | Detects | False Positive Risk |\n|---|---|---|\n| `uint16(0) == 0x5A4D and pe.imports(\"ntdll.dll\", \"NtCreateThreadEx\")` | Process injection via direct syscall | Low — legitimate use rare |\n| `$s xor(0x01-0xFF)` | Single-byte XOR-encoded strings | Medium — scan time increases |\n| `math.entropy(0, filesize) > 7.5` | Packed\u002Fencrypted payloads | Medium — compressed archives also match |\n| `pe.number_of_signatures == 0 and pe.timestamp > X` | Unsigned recent PE | High — many legitimate unsigned binaries |\n| `filesize \u003C 50KB and pe.imports(\"ws2_32.dll\")` | Small network-capable binary | Low — shellcode droppers are typically small |\n\n## Error Handling & Edge Cases\n\n| Problem | Cause | Solution |\n|---|---|---|\n| Rule compiles but matches nothing | Strings not present in target encoding | Add `ascii wide` to text strings; check endianness for hex |\n| Too many false positives | Overly generic strings | Add file type guard, size constraint, and tighten to `N of ($s*)` |\n| yarGen produces 100+ string rule | Default behavior — includes everything | Prune to 5-15 high-confidence strings; add manual conditions |\n| Retrohunt job times out | Rule too complex or regex too broad | Simplify regex; add `filesize \u003C` guard; split into multiple jobs |\n| YARA-X rejects valid YARA rule | Stricter parser | Fix deprecated syntax (e.g., unescaped special chars in regex) |\n| Hex pattern `??` matches too broadly | Wildcards without anchoring | Add surrounding fixed bytes; use `[N-M]` jumps instead |\n| PE module unavailable in sandbox | YARA compiled without PE module | Use `uint16(0) == 0x5A4D` as fallback; check `yara --help` for modules |\n| LiveHunt notifications delayed | VT processing backlog | Normal during high-volume periods; check dashboard |\n| Rule works locally but not on VT | Module version mismatch | Check VT supported YARA version and modules |\n\n## Decision Gate\n\n```\nIF you have a malware sample on disk\n  → Extract strings + imports → write rule manually (Section 2)\n  → Then run yarGen for additional string candidates (Section 3)\nIF you have a TI report with IOCs but no sample\n  → Extract IOCs (ti-ioc-extraction skill) → build string-based rule (Section 5)\nIF you need to find campaign variants in the wild\n  → Submit rule to VT Retrohunt (historical) + ANY.RUN YARA Search (Section 6)\nIF you need ongoing monitoring for new variants\n  → Deploy as VT LiveHunt rule (Section 6)\nIF rule produces false positives\n  → Add file type check, size constraint, raise string threshold (Section 4)\nIF yarGen output is too noisy\n  → Prune to 5-15 unique strings, add PE\u002FELF header check, test against goodware\nIF performance is poor on large corpus\n  → Lead condition with uint16\u002Ffilesize check; replace regex with hex patterns (Section 4)\nIF classic YARA accepts but YARA-X rejects\n  → Fix the rule — YARA-X catches real bugs; the stricter parser is correct\n```\n","# YARA Hunting\n\nWrite 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.\n\n## Quick Reference\n\n```bash\n# Install YARA\napt-get install -y yara || pip install yara-python\n\n# Install YARA-X (Rust rewrite — faster, stricter)\ncargo install yara-x\n\n# Install yarGen for automated rule generation\ngit clone https:\u002F\u002Fgithub.com\u002FNeo23x0\u002FyarGen.git \u002Fopt\u002FyarGen\ncd \u002Fopt\u002FyarGen && pip install -r requirements.txt\npython3 yarGen.py --update  # Download goodware string DB (first run only)\n\n# Scan a file with a rule\nyara \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fworkspace\u002Fsamples\u002F\n\n# Compile rules for faster scanning\nyarac \u002Fworkspace\u002Frules\u002F*.yar \u002Fworkspace\u002Frules\u002Fcompiled.yarc\nyara \u002Fworkspace\u002Frules\u002Fcompiled.yarc \u002Fworkspace\u002Fsamples\u002F\n\n# Validate rule syntax (YARA-X — stricter parser)\nyr check \u002Fworkspace\u002Frules\u002Fsuspect.yar\n```\n\n## MITRE ATT&CK Mapping\n\n| Technique | ID | Relevance |\n|---|---|---|\n| Obtain Capabilities: Exploits | T1588.005 | YARA identifies exploit tools\u002Fpayloads in attacker arsenals |\n| Develop Capabilities: Malware | T1587.001 | Rules detect custom malware based on unique strings\u002Fstructures |\n| Gather Victim Host Information: Software | T1592.002 | YARA scans reveal installed malware on victim hosts |\n| Indicator Removal on Host | T1070 | Retrohunting finds samples attackers attempted to erase |\n\n## 1. YARA Rule Syntax\n\n### Minimal Rule Structure\n\n```yara\nrule Malware_FamilyName_Variant {\n    meta:\n        author      = \"Decepticon TI\"\n        date        = \"2025-01-01\"\n        description = \"Detects FamilyName variant based on unique strings\"\n        hash        = \"e3b0c44298fc1c149afbf4c8996fb924...\"\n        reference   = \"https:\u002F\u002Freport-url\"\n        tlp         = \"WHITE\"\n\n    strings:\n        $s1 = \"unique_string_from_sample\" ascii wide\n        $s2 = { 4D 5A 90 00 03 00 00 00 }  \u002F\u002F MZ header + specific bytes\n        $s3 = \u002Fhttps?:\\\u002F\\\u002F[a-z0-9\\-\\.]+\\\u002Fgate\\.php\u002F nocase\n\n    condition:\n        uint16(0) == 0x5A4D and    \u002F\u002F PE file check\n        filesize \u003C 5MB and\n        2 of ($s*)\n}\n```\n\n### String Types\n\n```yara\nstrings:\n    \u002F\u002F Text strings\n    $text1 = \"CreateRemoteThread\"           \u002F\u002F ASCII exact\n    $text2 = \"CreateRemoteThread\" ascii wide \u002F\u002F Both encodings\n    $text3 = \"http:\u002F\u002Fc2.evil.com\" nocase    \u002F\u002F Case insensitive\n    $text4 = \"cmd \u002Fc\" fullword              \u002F\u002F Word boundary match\n\n    \u002F\u002F Hex strings (byte patterns)\n    $hex1 = { 48 8B 05 ?? ?? ?? ?? }        \u002F\u002F ?? = any byte (wildcard)\n    $hex2 = { 4D 5A [0-200] 50 45 00 00 }   \u002F\u002F Jump 0-200 bytes\n    $hex3 = { ( 74 | 75 ) 0? }              \u002F\u002F Alternation: je or jne\n\n    \u002F\u002F Regex strings\n    $re1 = \u002Fhttps?:\\\u002F\\\u002F\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d+)?\\\u002F[a-z]+\\.php\u002F\n    $re2 = \u002F[A-Za-z0-9+\\\u002F]{50,}={0,2}\u002F      \u002F\u002F Base64 blob\n\n    \u002F\u002F XOR-encoded strings (YARA 4.0+)\n    $xor1 = \"This program cannot\" xor       \u002F\u002F All single-byte XOR keys\n    $xor2 = \"config_url\" xor(0x01-0xFF)     \u002F\u002F Specific XOR range\n\n    \u002F\u002F Base64-encoded strings (YARA 4.0+)\n    $b64 = \"powershell\" base64 base64wide\n```\n\n### Condition Essentials\n\n```yara\ncondition:\n    \u002F\u002F File type guards (always lead with these)\n    uint16(0) == 0x5A4D                     \u002F\u002F PE (MZ header)\n    uint32(0) == 0x464C457F                 \u002F\u002F ELF\n    uint16(0) == 0x4B50                     \u002F\u002F ZIP\u002FDOCX\u002FXLSX (PK)\n\n    \u002F\u002F String matching\n    all of them                             \u002F\u002F Every string must match\n    any of them                             \u002F\u002F At least one\n    2 of ($s*)                              \u002F\u002F 2+ from $s group\n    3 of ($api*) and 1 of ($str*)           \u002F\u002F Mixed groups\n    #s1 > 5                                 \u002F\u002F $s1 appears 5+ times\n\n    \u002F\u002F Size + offset constraints\n    filesize \u003C 1MB\n    $mz at 0                                \u002F\u002F $mz must be at offset 0\n    $s1 in (0..1024)                        \u002F\u002F $s1 in first 1KB\n\n    \u002F\u002F PE module (import pe)\n    pe.imports(\"kernel32.dll\", \"VirtualAlloc\")\n    pe.number_of_sections > 6\n\n    \u002F\u002F Math module (import math)\n    math.entropy(0, filesize) > 7.0         \u002F\u002F High entropy (packed)\n\n    \u002F\u002F Typical combined condition\n    uint16(0) == 0x5A4D and filesize \u003C 2MB and\n    (2 of ($s*) or all of ($api*))\n```\n\n## 2. Writing Rules from Malware Samples\n\n### Step-by-Step: Sample to Rule\n\n```bash\n# Step 1: Extract strings from sample\nstrings -n 6 \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> > \u002Fworkspace\u002Frules\u002Fstrings_raw.txt\nstrings -n 6 -el \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> >> \u002Fworkspace\u002Frules\u002Fstrings_raw.txt  # Wide strings\n\n# Step 2: Identify unique strings (not in common binaries)\n# Look for: C2 URLs, mutex names, PDB paths, custom error messages,\n# registry keys, file paths, encryption keys, config markers\ngrep -iP '(http|ftp|\\.php|\\.aspx|mutex|pdb|\\\\\\\\Users|HKEY_|config|beacon|payload)' \\\n  \u002Fworkspace\u002Frules\u002Fstrings_raw.txt | sort -u > \u002Fworkspace\u002Frules\u002Fstrings_interesting.txt\n\n# Step 3: Extract hex patterns at key offsets\nxxd \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> | head -50  # File header\nxxd -s 0x400 -l 256 \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>  # Code section start\n\n# Step 4: Check PE imports (if PE file)\npython3 -c \"\nimport pefile\npe = pefile.PE('\u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>')\nfor entry in pe.DIRECTORY_ENTRY_IMPORT:\n    dll = entry.dll.decode()\n    for imp in entry.imports:\n        name = imp.name.decode() if imp.name else str(imp.ordinal)\n        print(f'{dll}:{name}')\n\" > \u002Fworkspace\u002Frules\u002Fimports.txt\n\n# Step 5: Check entropy per section\npython3 -c \"\nimport pefile, math\npe = pefile.PE('\u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE>')\nfor s in pe.sections:\n    name = s.Name.rstrip(b'\\x00').decode(errors='replace')\n    data = s.get_data()\n    if data:\n        ent = sum(-p*math.log2(p) for p in [data.count(bytes([b]))\u002Flen(data) for b in range(256)] if p > 0)\n        print(f'{name}: entropy={ent:.2f} size={len(data)}')\n\"\n```\n\n### Template: Rule from Behavioral Observations\n\n```yara\nrule APT_Backdoor_ObservedBehavior {\n    meta:\n        author      = \"Decepticon TI\"\n        date        = \"2025-01-01\"\n        description = \"Backdoor observed during engagement — drops to %TEMP%, \"\n                      \"contacts C2 over HTTPS, exfiltrates via DNS TXT\"\n        tlp         = \"AMBER\"\n\n    strings:\n        \u002F\u002F Observed C2 communication pattern\n        $c2_uri  = \"\u002Fapi\u002Fv1\u002Fcheck\" ascii\n        $c2_ua   = \"Mozilla\u002F5.0 (compatible; MSIE 10.0)\" ascii\n\n        \u002F\u002F Observed mutex (from dynamic analysis)\n        $mutex   = \"Global\\\\{8A4E2C-\" ascii\n\n        \u002F\u002F Observed file drops\n        $drop1   = \"\\\\AppData\\\\Local\\\\Temp\\\\svchost32.exe\" ascii wide\n        $drop2   = \"\\\\ProgramData\\\\Microsoft\\\\updater.dll\" ascii wide\n\n        \u002F\u002F Observed registry persistence\n        $reg     = \"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\" ascii wide\n\n        \u002F\u002F DNS exfiltration pattern (hex-encoded subdomain)\n        $dns_exf = \u002F[0-9a-f]{16,}\\.data\\.[a-z0-9\\-]+\\.(com|net|org)\u002F\n\n        \u002F\u002F Encryption routine bytes (from disassembly)\n        $crypto  = { 8B 45 ?? 33 45 ?? 89 45 ?? 8B 4D ?? 03 4D ?? }\n\n    condition:\n        uint16(0) == 0x5A4D and\n        filesize \u003C 3MB and\n        ($mutex or $crypto) and\n        2 of ($c2_*, $drop*, $reg, $dns_exf)\n}\n```\n\n## 3. Automated Rule Generation with yarGen\n\n```bash\n# Generate rule from single sample\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_output.yar \\\n  --excludegood\n\n# Generate rules from directory of related samples\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002Fcampaign_x\u002F \\\n  -o \u002Fworkspace\u002Frules\u002Fcampaign_x.yar \\\n  --excludegood \\\n  -a \"Decepticon TI\" \\\n  -r \"https:\u002F\u002Fengagement-reference\"\n\n# AI-assisted mode (v0.24.0+) — generates expanded string set with AI prompt\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_ai.yar \\\n  --ai\n\n# Inverse match — generate rule for goodware (detect clean files)\npython3 \u002Fopt\u002FyarGen\u002FyarGen.py \\\n  -m \u002Fworkspace\u002Fsamples\u002F\u003CSAMPLE> \\\n  -o \u002Fworkspace\u002Frules\u002Fyargen_output.yar \\\n  --inverse --excludegood\n\n# After generation: review and tighten the rule\n# yarGen over-selects strings — prune to 5-15 high-confidence indicators\n# Add file type checks (uint16(0) == 0x5A4D) and size constraints\n```\n\n### yarGen Output Review Checklist\n\n1. **Remove generic strings** — `\"Microsoft\"`, `\"Windows\"`, `\"kernel32.dll\"` add nothing\n2. **Keep unique artifacts** — PDB paths, mutex names, custom headers, C2 URIs\n3. **Add file type guard** — `uint16(0) == 0x5A4D` for PE, `uint32(0) == 0x464C457F` for ELF\n4. **Add size constraint** — `filesize \u003C 10MB` prevents scanning huge archives\n5. **Tighten condition** — change `all of them` to `N of ($s*)` to tolerate variants\n6. **Test against goodware** — scan `\u002Fusr\u002Fbin\u002F`, `C:\\Windows\\System32\\` for false positives\n\n## 4. Condition Optimization and Performance\n\n1. **Always lead with cheap checks**: `uint16(0) == 0x5A4D and filesize \u003C 5MB and ...`\n2. **Anchor strings to offsets**: `$mz at 0`, `$config in (filesize - 4096 .. filesize)`\n3. **Bound regex**: `\u002F.{0,1000}evil\u002F` causes backtracking; use `\u002Fevil[a-z]{0,20}\\.php\u002F`\n4. **Prefer hex over regex** for bytes: `{ 4D 5A [0-500] 50 45 }` > `\u002F\\x4D\\x5A.{0,500}\\x50\\x45\u002F`\n5. **Threshold matching**: `3 of ($s*)` instead of `all of them` — tolerates variant mutations\n6. **PE module for imports**: `pe.imports(\"ws2_32.dll\", \"connect\")` beats string-matching DLL names\n\n```bash\n# Test for false positives against goodware\nyara -r \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fusr\u002Fbin\u002F 2>\u002Fdev\u002Fnull | wc -l  # Target: 0\nyr scan --profile \u002Fworkspace\u002Frules\u002Fsuspect.yar \u002Fworkspace\u002Fsamples\u002F  # YARA-X profiling\n```\n\n## 5. TI Report-to-YARA Conversion\n\nUse the `ti-ioc-extraction` skill to extract IOCs from reports, then build YARA:\n- **Hashes** → `meta:` section (for reference\u002Fcorrelation, not detection)\n- **Domains\u002FURLs** → text strings with `ascii nocase`\n- **File paths** → text strings with `ascii wide` (escape backslashes)\n- **Snort\u002FSuricata content matches** → YARA text strings (e.g., `content:\"\u002Fgate.php\"` → `$uri = \"\u002Fgate.php\" ascii`)\n\n## 6. Retrohunting Workflows\n\n### VirusTotal Retrohunt\n\n```bash\n# Submit retrohunt job via API\nVT_API_KEY=\"\u003CAPI_KEY>\"\n\n# Upload rule\ncurl -s -X POST \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\" \\\n  -H \"x-apikey: $VT_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"data\": {\n      \"type\": \"retrohunt_job\",\n      \"attributes\": {\n        \"rules\": \"rule test { strings: $s = \\\"unique_marker\\\" condition: $s }\",\n        \"notification_email\": \"analyst@example.com\",\n        \"corpus\": \"main\",\n        \"time_range\": { \"start\": 1700000000, \"end\": 1710000000 }\n      }\n    }\n  }' > \u002Fworkspace\u002Fhunting\u002Fretrohunt_job.json\n\n# Check job status\nJOB_ID=$(python3 -c \"import json; print(json.load(open('\u002Fworkspace\u002Fhunting\u002Fretrohunt_job.json'))['data']['id'])\")\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\u002F$JOB_ID\" \\\n  -H \"x-apikey: $VT_API_KEY\" | python3 -m json.tool\n\n# Retrieve matches (after job completes — typically 2-3 hours)\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fretrohunt_jobs\u002F$JOB_ID\u002Fmatching_files?limit=40\" \\\n  -H \"x-apikey: $VT_API_KEY\" > \u002Fworkspace\u002Fhunting\u002Fretrohunt_matches.json\n```\n\n**VirusTotal Retrohunt Limits:**\n- Corpus: 500M+ files (~680TB), scanned in 2-3 hours\n- Hunting Pro: 12-month lookback | Standard: 3-month lookback\n- Max 300 rules per job, total rule text \u003C 1MB\n- Max 10,000 matches per job\n- LiveHunt (real-time): rules tested against every new upload\n\n### VirusTotal LiveHunt (Real-Time)\n\n```bash\n# Create a LiveHunt ruleset — rules tested against every new VT upload\ncurl -s -X POST \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fintelligence\u002Fhunting_rulesets\" \\\n  -H \"x-apikey: $VT_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"data\":{\"type\":\"hunting_ruleset\",\"attributes\":{\"name\":\"Campaign_X_Tracker\",\"enabled\":true,\"rules\":\"rule Campaign_X { strings: $c2 = \\\"evil-c2.example.com\\\" condition: uint16(0) == 0x5A4D and $c2 }\",\"notification_emails\":[\"analyst@example.com\"]}}}'\n```\n\n### ANY.RUN YARA Search\n\n```bash\n# Web interface: https:\u002F\u002Fyara.any.run\u002F\n# 1. Paste YARA rule into editor (syntax highlighting, multi-tab)\n# 2. Click \"Search\" — scans 2TB malware corpus\n# 3. Results link to sandbox sessions (interactive execution replay)\n# 4. Free tier: 20 YARA Search requests (shared with TI Lookup quota)\n\n# API submission\ncurl -s \"https:\u002F\u002Fapi.any.run\u002Fv1\u002Fyara\u002Fsearch\" \\\n  -H \"Authorization: API-Key \u003CANYRUN_API_KEY>\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"rule\": \"rule test { strings: $s = \\\"unique_marker\\\" ascii condition: $s }\"\n  }' > \u002Fworkspace\u002Fhunting\u002Fanyrun_yara_results.json\n\n# Results include sandbox session UUIDs — open for full analysis:\n# https:\u002F\u002Fapp.any.run\u002Ftasks\u002F\u003CUUID>\n```\n\n### Retrohunting End-to-End\n\n```bash\n# 1. Write rule from engagement sample (Section 2)\n# 2. Validate locally — must match known sample, must NOT match goodware\nyara \u002Fworkspace\u002Frules\u002Fcampaign.yar \u002Fworkspace\u002Fsamples\u002F\nyara \u002Fworkspace\u002Frules\u002Fcampaign.yar \u002Fusr\u002Fbin\u002F 2>\u002Fdev\u002Fnull  # Expect 0 matches\n\n# 3. Submit to VT Retrohunt (historical) + ANY.RUN YARA Search (sandbox corpus)\n# 4. Deploy as VT LiveHunt for ongoing monitoring\n# 5. Collect + deduplicate matches from both platforms\n# 6. Download new samples for deeper analysis\n```\n\n## 7. YARA-X Differences\n\nYARA-X (Rust rewrite) offers stricter parsing, better performance, and multi-line metadata (0.4.0+). Key commands:\n\n```bash\ncargo install yara-x          # Install\nyr check \u002Fworkspace\u002Frules\u002F*.yar  # Validate (catches bugs classic YARA ignores)\nyr scan \u002Fworkspace\u002Frules\u002F*.yar \u002Fworkspace\u002Fsamples\u002F  # Scan\n```\n\nIf classic YARA accepts a rule but YARA-X rejects it, fix the rule — the stricter parser catches real syntax bugs.\n\n## Tools & Resources\n\n| Tool | Purpose | Install\u002FURL |\n|---|---|---|\n| yara | Rule scanning engine | `apt install yara` |\n| yarac | Compile rules to binary | Ships with yara |\n| YARA-X | Rust rewrite — stricter, faster | `cargo install yara-x` |\n| yarGen | Auto-generate rules from samples | `github.com\u002FNeo23x0\u002FyarGen` |\n| yarGen-Go | Go rewrite of yarGen | `github.com\u002FNeo23x0\u002FyarGen-Go` |\n| yara-python | Python bindings | `pip install yara-python` |\n| VT Retrohunt | Scan 500M+ historical files | `virustotal.com` (paid) |\n| VT LiveHunt | Real-time rule matching on uploads | `virustotal.com` (paid) |\n| ANY.RUN YARA Search | Scan 2TB malware corpus | `yara.any.run` |\n| YARA rules repo (ANY.RUN) | Community detection rules | `github.com\u002Fanyrun\u002FYARA` |\n| awesome-yara | Curated rule\u002Ftool list | `github.com\u002FInQuest\u002Fawesome-yara` |\n\n## Detection Signatures\n\n| Rule Pattern | Detects | False Positive Risk |\n|---|---|---|\n| `uint16(0) == 0x5A4D and pe.imports(\"ntdll.dll\", \"NtCreateThreadEx\")` | Process injection via direct syscall | Low — legitimate use rare |\n| `$s xor(0x01-0xFF)` | Single-byte XOR-encoded strings | Medium — scan time increases |\n| `math.entropy(0, filesize) > 7.5` | Packed\u002Fencrypted payloads | Medium — compressed archives also match |\n| `pe.number_of_signatures == 0 and pe.timestamp > X` | Unsigned recent PE | High — many legitimate unsigned binaries |\n| `filesize \u003C 50KB and pe.imports(\"ws2_32.dll\")` | Small network-capable binary | Low — shellcode droppers are typically small |\n\n## Error Handling & Edge Cases\n\n| Problem | Cause | Solution |\n|---|---|---|\n| Rule compiles but matches nothing | Strings not present in target encoding | Add `ascii wide` to text strings; check endianness for hex |\n| Too many false positives | Overly generic strings | Add file type guard, size constraint, and tighten to `N of ($s*)` |\n| yarGen produces 100+ string rule | Default behavior — includes everything | Prune to 5-15 high-confidence strings; add manual conditions |\n| Retrohunt job times out | Rule too complex or regex too broad | Simplify regex; add `filesize \u003C` guard; split into multiple jobs |\n| YARA-X rejects valid YARA rule | Stricter parser | Fix deprecated syntax (e.g., unescaped special chars in regex) |\n| Hex pattern `??` matches too broadly | Wildcards without anchoring | Add surrounding fixed bytes; use `[N-M]` jumps instead |\n| PE module unavailable in sandbox | YARA compiled without PE module | Use `uint16(0) == 0x5A4D` as fallback; check `yara --help` for modules |\n| LiveHunt notifications delayed | VT processing backlog | Normal during high-volume periods; check dashboard |\n| Rule works locally but not on VT | Module version mismatch | Check VT supported YARA version and modules |\n\n## Decision Gate\n\n```\nIF you have a malware sample on disk\n  → Extract strings + imports → write rule manually (Section 2)\n  → Then run yarGen for additional string candidates (Section 3)\nIF you have a TI report with IOCs but no sample\n  → Extract IOCs (ti-ioc-extraction skill) → build string-based rule (Section 5)\nIF you need to find campaign variants in the wild\n  → Submit rule to VT Retrohunt (historical) + ANY.RUN YARA Search (Section 6)\nIF you need ongoing monitoring for new variants\n  → Deploy as VT LiveHunt rule (Section 6)\nIF rule produces false positives\n  → Add file type check, size constraint, raise string threshold (Section 4)\nIF yarGen output is too noisy\n  → Prune to 5-15 unique strings, add PE\u002FELF header check, test against goodware\nIF performance is poor on large corpus\n  → Lead condition with uint16\u002Ffilesize check; replace regex with hex patterns (Section 4)\nIF classic YARA accepts but YARA-X rejects\n  → Fix the rule — YARA-X catches real bugs; the stricter parser is correct\n```\n",{"name":5,"metadata":24,"description":7,"allowed-tools":29},{"tags":25,"subdomain":26,"when_to_use":27,"mitre_attack":28},"yara, hunting, threat-intelligence, retrohunt, virustotal, anyrun, malware-detection, yargen","analyst","yara, yara rule, yara-x, yargen, retrohunt, retrohunting, virustotal hunting, anyrun yara search, malware signature, malware hunting, yara condition, yara strings, threat hunting rules, livehunt","T1588.005","Bash Read Write","main","42b918525fb79065e730da3da997bffb33fcd414","packages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fanalyst\u002Fti-yara-hunting",0,"https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad","https:\u002F\u002Fgithub.com\u002F7ShIkI3","2026-07-22 19:02:27",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add 7ShIkI3\u002FDecepticon-x-DarkTriad --skill ti-yara-hunting",{"tool":43,"command":44},"bunx","bunx skills add 7ShIkI3\u002FDecepticon-x-DarkTriad --skill ti-yara-hunting",{"tool":46,"command":47},"pnpm","pnpm dlx skills add 7ShIkI3\u002FDecepticon-x-DarkTriad --skill ti-yara-hunting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fanalyst\u002Fti-yara-hunting\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M798TNHEBA4Y67TJJ7W0KBDD","wps-pixie-dust","WPS Pixie-Dust offline nonce attack (reaver -K \u002F pixiewps) and fallback online PIN brute (bully) to recover the AP's WPA PSK without capturing a handshake.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fwps-pixie-dust\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M798TH79VR8XM7AAMG0ZKSXX","wpa3-sae","WPA3-SAE transition-mode downgrade (DragonShift), SSID Confusion CVE-2023-52424, Dragonblood side-channels, and SAE captive-portal credential recovery against WPA3-Personal networks.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fwpa3-sae\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M798TD0E10ZHQN5X362M4HG9","wpa2-psk","WPA\u002FWPA2-PSK handshake capture via targeted deauth + PMKID (no deauth required) + offline hashcat cracking. The most common consumer\u002FSMB encryption mode in 2026.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fwpa2-psk\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M798T7HFR3NB9WJTK1FESVF9","wpa-enterprise-eap","WPA\u002FWPA2\u002FWPA3-Enterprise (802.1X\u002FEAP) rogue-RADIUS evil-twin for MSCHAPv2 capture, GTC downgrade, and PEAP relay. MSCHAPv2 capture equals a NetNTLM hash — the primary wireless on-ramp to Active Directory.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fwpa-enterprise-eap\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M798T38B4SV0T87VQK56KPHC","krack-fragattacks","KRACK key-reinstallation (CVE-2017-13077..13082) and FragAttacks fragmentation\u002Faggregation flaws (CVE-2020-24586..24588, CVE-2020-26139..26147) against legacy or embedded 802.11 supplicants with poor patch cadence.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fkrack-fragattacks\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M798SXTNF0RP1DXKQEWFVQ9H","evil-twin-karma","Evil-twin rogue AP with KARMA\u002FMana PNL-probe response, captive-portal credential capture, and post-association MITM for PSK\u002Fopen networks. Distinct from wpa-enterprise-eap which targets 802.1X.","https:\u002F\u002Fgithub.com\u002F7ShIkI3\u002FDecepticon-x-DarkTriad\u002Fblob\u002Fmain\u002Fpackages\u002Fdecepticon\u002Fdecepticon\u002Fskills\u002Fstandard\u002Fwireless\u002Fevil-twin-karma\u002FSKILL.md",[],[]]