[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AAJAY156B8M8JB75MR5JRF":3,"skill-same:01M7AAJAY156B8M8JB75MR5JRF":102},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":14,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7AAJAY156B8M8JB75MR5JRF","performing-yara-rule-development-for-detection",null,"Develops precise YARA and YARA-X rules for malware detection by identifying unique strings, byte sequences, PE header traits, and behavioral indicators in unpacked malware artifacts while minimizing false positives. Use when building detection signatures for threat hunting, classifying malware families, or authoring rules from IOCs such as C2 URLs, mutex names, and encryption constants.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: performing-yara-rule-development-for-detection\ndescription: Develops precise YARA and YARA-X rules for malware detection by identifying\n  unique strings, byte sequences, PE header traits, and behavioral indicators in\n  unpacked malware artifacts while minimizing false positives. Use when building\n  detection signatures for threat hunting, classifying malware families, or authoring\n  rules from IOCs such as C2 URLs, mutex names, and encryption constants.\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- yara\n- malware-detection\n- signature-development\n- threat-hunting\n- pattern-matching\n- yara-x\n- indicator-development\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmitre_attack:\n- T1027\n- T1055\n- T1140\n- T1497\n---\n# Performing YARA Rule Development for Detection\n\n## Overview\n\nYARA is the pattern matching swiss knife for malware researchers, enabling identification and classification of malware based on textual or binary patterns. Effective YARA rules combine unique string patterns, byte sequences, PE header characteristics, import table analysis, and conditional logic to detect malware families while avoiding false positives. Modern YARA-X (rewritten in Rust, stable since June 2025) brings improved performance and new modules. Rules should target unpacked malware artifacts like hardcoded stack strings, C2 URLs, mutex names, encryption constants, and unique code sequences rather than packer signatures.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing yara rule development for detection\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Python 3.9+ with `yara-python` library\n- YARA 4.5+ or YARA-X 0.10+\n- PE analysis tools (`pefile`, `pestudio`)\n- Hex editor for identifying unique byte patterns\n- Access to malware samples (VirusTotal, MalwareBazaar)\n- Understanding of PE file format, strings, and import tables\n\n## Key Concepts\n\n### Rule Structure\n\nEvery YARA rule consists of three sections: `meta` (optional descriptive metadata), `strings` (pattern definitions), and `condition` (matching logic). String types include text strings (ASCII\u002Fwide\u002Fnocase), hex patterns with wildcards and jumps, and regular expressions. Conditions combine string matches with file properties using boolean operators.\n\n### String Selection Strategy\n\nEffective rules target patterns that are unique to the malware family and survive recompilation. Hardcoded stack strings are excellent choices because compilers embed them consistently. C2 domain patterns, custom encryption routines, unique error messages, and specific API call sequences provide stable detection anchors. Avoid compiler-generated boilerplate and common library strings.\n\n### Performance Optimization\n\nYARA evaluates conditions short-circuit style. Place the most discriminating and cheapest-to-evaluate conditions first. Use `filesize` limits to skip irrelevant files quickly. Minimize regex usage in favor of hex patterns. Use `private` rules as building blocks for complex detection logic without generating standalone matches.\n\n## Workflow\n\n### Step 1: Analyze Sample for Unique Patterns\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Extract candidate strings and byte patterns for YARA rule creation.\"\"\"\nimport pefile\nimport re\nimport sys\nfrom collections import Counter\n\n\ndef extract_strings(filepath, min_length=6):\n    \"\"\"Extract ASCII and wide strings from binary.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    # ASCII strings\n    ascii_strings = re.findall(\n        rb'[\\x20-\\x7e]{' + str(min_length).encode() + rb',}', data\n    )\n\n    # Wide (UTF-16LE) strings\n    wide_strings = re.findall(\n        rb'(?:[\\x20-\\x7e]\\x00){' + str(min_length).encode() + rb',}', data\n    )\n\n    return {\n        'ascii': [s.decode('ascii') for s in ascii_strings],\n        'wide': [s.decode('utf-16-le') for s in wide_strings],\n    }\n\n\ndef analyze_pe_imports(filepath):\n    \"\"\"Extract import table for API-based detection.\"\"\"\n    try:\n        pe = pefile.PE(filepath)\n    except pefile.PEFormatError:\n        return []\n\n    imports = []\n    if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n        for entry in pe.DIRECTORY_ENTRY_IMPORT:\n            dll_name = entry.dll.decode('utf-8', errors='replace')\n            for imp in entry.imports:\n                if imp.name:\n                    func_name = imp.name.decode('utf-8', errors='replace')\n                    imports.append(f\"{dll_name}!{func_name}\")\n    return imports\n\n\ndef find_unique_byte_patterns(filepath, pattern_length=16):\n    \"\"\"Find unique byte sequences suitable for YARA hex patterns.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    try:\n        pe = pefile.PE(filepath)\n        # Focus on code section\n        for section in pe.sections:\n            if section.Characteristics & 0x20000000:  # IMAGE_SCN_MEM_EXECUTE\n                code_start = section.PointerToRawData\n                code_end = code_start + section.SizeOfRawData\n                code_data = data[code_start:code_end]\n                break\n        else:\n            code_data = data\n    except Exception:\n        code_data = data\n\n    # Find byte patterns that appear exactly once\n    patterns = []\n    for i in range(0, len(code_data) - pattern_length, 4):\n        pattern = code_data[i:i+pattern_length]\n        if pattern.count(b'\\x00') \u003C pattern_length \u002F\u002F 3:  # Skip null-heavy\n            hex_pattern = ' '.join(f'{b:02X}' for b in pattern)\n            patterns.append(hex_pattern)\n\n    # Count frequency and return unique ones\n    freq = Counter(patterns)\n    unique = [p for p, count in freq.items() if count == 1]\n\n    return unique[:20]  # Top 20 candidates\n\n\ndef suggest_rule_strings(filepath):\n    \"\"\"Suggest strings and patterns for YARA rule.\"\"\"\n    print(f\"[+] Analyzing: {filepath}\")\n\n    # Extract strings\n    strings = extract_strings(filepath)\n\n    # Filter for suspicious\u002Funique strings\n    suspicious_keywords = [\n        'http', 'https', 'cmd', 'powershell', 'mutex', 'pipe',\n        'password', 'credential', 'inject', 'hook', 'debug',\n        'sandbox', 'virtual', 'vmware', 'vbox',\n    ]\n\n    print(\"\\n[+] Suspicious ASCII strings:\")\n    for s in strings['ascii']:\n        if any(kw in s.lower() for kw in suspicious_keywords):\n            print(f\"  $ = \\\"{s}\\\" ascii\")\n\n    print(\"\\n[+] Suspicious wide strings:\")\n    for s in strings['wide']:\n        if any(kw in s.lower() for kw in suspicious_keywords):\n            print(f\"  $ = \\\"{s}\\\" wide\")\n\n    # Import analysis\n    imports = analyze_pe_imports(filepath)\n    suspicious_apis = [\n        'VirtualAlloc', 'VirtualProtect', 'WriteProcessMemory',\n        'CreateRemoteThread', 'NtUnmapViewOfSection', 'RtlMoveMemory',\n        'OpenProcess', 'CreateToolhelp32Snapshot',\n        'InternetOpenA', 'HttpSendRequestA',\n        'CryptEncrypt', 'CryptDecrypt',\n    ]\n\n    print(\"\\n[+] Suspicious imports:\")\n    for imp in imports:\n        func = imp.split('!')[-1]\n        if func in suspicious_apis:\n            print(f\"  {imp}\")\n\n    # Byte patterns\n    print(\"\\n[+] Candidate hex patterns:\")\n    patterns = find_unique_byte_patterns(filepath)\n    for p in patterns[:5]:\n        print(f\"  $hex = {{ {p} }}\")\n\n\nif __name__ == \"__main__\":\n    if len(sys.argv) \u003C 2:\n        print(f\"Usage: {sys.argv[0]} \u003Csample_path>\")\n        sys.exit(1)\n    suggest_rule_strings(sys.argv[1])\n```\n\n### Step 2: Write and Test YARA Rules\n\n```python\nimport yara\nimport os\n\ndef create_yara_rule(rule_name, meta, strings, condition):\n    \"\"\"Generate a YARA rule from components.\"\"\"\n    meta_str = \"\\n\".join(f'        {k} = \"{v}\"' for k, v in meta.items())\n    strings_str = \"\\n\".join(f\"        {s}\" for s in strings)\n\n    rule = f\"\"\"rule {rule_name} {{\n    meta:\n{meta_str}\n\n    strings:\n{strings_str}\n\n    condition:\n        {condition}\n}}\"\"\"\n    return rule\n\n\ndef test_yara_rule(rule_text, test_dir):\n    \"\"\"Compile and test YARA rule against sample directory.\"\"\"\n    try:\n        rules = yara.compile(source=rule_text)\n    except yara.SyntaxError as e:\n        print(f\"[-] YARA syntax error: {e}\")\n        return None\n\n    results = {\"matches\": [], \"no_match\": []}\n\n    for filename in os.listdir(test_dir):\n        filepath = os.path.join(test_dir, filename)\n        if not os.path.isfile(filepath):\n            continue\n\n        matches = rules.match(filepath)\n        if matches:\n            results[\"matches\"].append({\n                \"file\": filename,\n                \"rules\": [m.rule for m in matches],\n            })\n        else:\n            results[\"no_match\"].append(filename)\n\n    print(f\"[+] Matches: {len(results['matches'])}\")\n    print(f\"[-] No match: {len(results['no_match'])}\")\n    return results\n\n\n# Example: Create a rule for a hypothetical malware family\nexample_rule = create_yara_rule(\n    rule_name=\"MalwareFamily_Variant_A\",\n    meta={\n        \"description\": \"Detects MalwareFamily Variant A\",\n        \"author\": \"Malware Analysis Team\",\n        \"date\": \"2025-01-01\",\n        \"hash\": \"abc123...\",\n        \"tlp\": \"WHITE\",\n    },\n    strings=[\n        '$mutex = \"Global\\\\\\\\UniqueM4lwareMutex\" ascii wide',\n        '$c2_pattern = \u002Fhttps?:\\\\\u002F\\\\\u002F[a-z]{5,10}\\\\.(xyz|top|buzz)\\\\\u002Fgate\\\\.php\u002F',\n        '$api1 = \"VirtualAllocEx\" ascii',\n        '$api2 = \"WriteProcessMemory\" ascii',\n        '$api3 = \"CreateRemoteThread\" ascii',\n        '$hex_decrypt = { 8B 45 ?? 33 C1 89 45 ?? 83 C1 04 }',\n        '$pdb = \"C:\\\\\\\\Users\\\\\\\\\" ascii',\n    ],\n    condition=(\n        'uint16(0) == 0x5A4D and filesize \u003C 2MB and '\n        '($mutex or $c2_pattern) and '\n        '2 of ($api*) and '\n        '$hex_decrypt'\n    ),\n)\n\nprint(example_rule)\n```\n\n### Step 3: Performance Testing and Optimization\n\n```python\nimport time\n\ndef benchmark_rule(rule_text, scan_directory, iterations=3):\n    \"\"\"Benchmark YARA rule scan performance.\"\"\"\n    rules = yara.compile(source=rule_text)\n\n    files = []\n    for root, _, filenames in os.walk(scan_directory):\n        for f in filenames:\n            files.append(os.path.join(root, f))\n\n    print(f\"[+] Benchmarking against {len(files)} files \"\n          f\"({iterations} iterations)\")\n\n    times = []\n    for i in range(iterations):\n        start = time.perf_counter()\n        matches = 0\n        for filepath in files:\n            try:\n                result = rules.match(filepath)\n                if result:\n                    matches += 1\n            except Exception:\n                pass\n        elapsed = time.perf_counter() - start\n        times.append(elapsed)\n        print(f\"  Iteration {i+1}: {elapsed:.3f}s ({matches} matches)\")\n\n    avg_time = sum(times) \u002F len(times)\n    files_per_sec = len(files) \u002F avg_time\n    print(f\"\\n[+] Average: {avg_time:.3f}s ({files_per_sec:.0f} files\u002Fsec)\")\n    return avg_time\n```\n\n## Validation Criteria\n\n- YARA rules compile without syntax errors\n- Rules detect target malware family samples with zero false negatives\n- False positive rate below 0.1% when scanned against clean file corpus\n- Rule performance allows scanning 1000+ files per second\n- Rules survive minor malware modifications (recompilation, string changes)\n- Metadata includes hash, author, date, description, and TLP marking\n\n## References\n\n- [YARA Official Documentation](https:\u002F\u002Fvirustotal.github.io\u002Fyara\u002F)\n- [YARA-X Rewrite in Rust](https:\u002F\u002Fgithub.com\u002FVirusTotal\u002Fyara-x)\n- [Yara-Rules Community Repository](https:\u002F\u002Fgithub.com\u002FYara-Rules\u002Frules)\n- [ReversingLabs - Writing Detailed YARA Rules](https:\u002F\u002Fwww.reversinglabs.com\u002Fblog\u002Fwriting-detailed-yara-rules-for-malware-detection)\n- [YARA Rule Crafting Deep Dive](https:\u002F\u002Fcyberthreatintelligencenetwork.com\u002Findex.php\u002F2024\u002F09\u002F11\u002Fyara-rule-crafting-a-deep-dive-into-signature-based-threat-hunting-strategies\u002F)\n","# Performing YARA Rule Development for Detection\n\n## Overview\n\nYARA is the pattern matching swiss knife for malware researchers, enabling identification and classification of malware based on textual or binary patterns. Effective YARA rules combine unique string patterns, byte sequences, PE header characteristics, import table analysis, and conditional logic to detect malware families while avoiding false positives. Modern YARA-X (rewritten in Rust, stable since June 2025) brings improved performance and new modules. Rules should target unpacked malware artifacts like hardcoded stack strings, C2 URLs, mutex names, encryption constants, and unique code sequences rather than packer signatures.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing yara rule development for detection\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Python 3.9+ with `yara-python` library\n- YARA 4.5+ or YARA-X 0.10+\n- PE analysis tools (`pefile`, `pestudio`)\n- Hex editor for identifying unique byte patterns\n- Access to malware samples (VirusTotal, MalwareBazaar)\n- Understanding of PE file format, strings, and import tables\n\n## Key Concepts\n\n### Rule Structure\n\nEvery YARA rule consists of three sections: `meta` (optional descriptive metadata), `strings` (pattern definitions), and `condition` (matching logic). String types include text strings (ASCII\u002Fwide\u002Fnocase), hex patterns with wildcards and jumps, and regular expressions. Conditions combine string matches with file properties using boolean operators.\n\n### String Selection Strategy\n\nEffective rules target patterns that are unique to the malware family and survive recompilation. Hardcoded stack strings are excellent choices because compilers embed them consistently. C2 domain patterns, custom encryption routines, unique error messages, and specific API call sequences provide stable detection anchors. Avoid compiler-generated boilerplate and common library strings.\n\n### Performance Optimization\n\nYARA evaluates conditions short-circuit style. Place the most discriminating and cheapest-to-evaluate conditions first. Use `filesize` limits to skip irrelevant files quickly. Minimize regex usage in favor of hex patterns. Use `private` rules as building blocks for complex detection logic without generating standalone matches.\n\n## Workflow\n\n### Step 1: Analyze Sample for Unique Patterns\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Extract candidate strings and byte patterns for YARA rule creation.\"\"\"\nimport pefile\nimport re\nimport sys\nfrom collections import Counter\n\n\ndef extract_strings(filepath, min_length=6):\n    \"\"\"Extract ASCII and wide strings from binary.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    # ASCII strings\n    ascii_strings = re.findall(\n        rb'[\\x20-\\x7e]{' + str(min_length).encode() + rb',}', data\n    )\n\n    # Wide (UTF-16LE) strings\n    wide_strings = re.findall(\n        rb'(?:[\\x20-\\x7e]\\x00){' + str(min_length).encode() + rb',}', data\n    )\n\n    return {\n        'ascii': [s.decode('ascii') for s in ascii_strings],\n        'wide': [s.decode('utf-16-le') for s in wide_strings],\n    }\n\n\ndef analyze_pe_imports(filepath):\n    \"\"\"Extract import table for API-based detection.\"\"\"\n    try:\n        pe = pefile.PE(filepath)\n    except pefile.PEFormatError:\n        return []\n\n    imports = []\n    if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n        for entry in pe.DIRECTORY_ENTRY_IMPORT:\n            dll_name = entry.dll.decode('utf-8', errors='replace')\n            for imp in entry.imports:\n                if imp.name:\n                    func_name = imp.name.decode('utf-8', errors='replace')\n                    imports.append(f\"{dll_name}!{func_name}\")\n    return imports\n\n\ndef find_unique_byte_patterns(filepath, pattern_length=16):\n    \"\"\"Find unique byte sequences suitable for YARA hex patterns.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    try:\n        pe = pefile.PE(filepath)\n        # Focus on code section\n        for section in pe.sections:\n            if section.Characteristics & 0x20000000:  # IMAGE_SCN_MEM_EXECUTE\n                code_start = section.PointerToRawData\n                code_end = code_start + section.SizeOfRawData\n                code_data = data[code_start:code_end]\n                break\n        else:\n            code_data = data\n    except Exception:\n        code_data = data\n\n    # Find byte patterns that appear exactly once\n    patterns = []\n    for i in range(0, len(code_data) - pattern_length, 4):\n        pattern = code_data[i:i+pattern_length]\n        if pattern.count(b'\\x00') \u003C pattern_length \u002F\u002F 3:  # Skip null-heavy\n            hex_pattern = ' '.join(f'{b:02X}' for b in pattern)\n            patterns.append(hex_pattern)\n\n    # Count frequency and return unique ones\n    freq = Counter(patterns)\n    unique = [p for p, count in freq.items() if count == 1]\n\n    return unique[:20]  # Top 20 candidates\n\n\ndef suggest_rule_strings(filepath):\n    \"\"\"Suggest strings and patterns for YARA rule.\"\"\"\n    print(f\"[+] Analyzing: {filepath}\")\n\n    # Extract strings\n    strings = extract_strings(filepath)\n\n    # Filter for suspicious\u002Funique strings\n    suspicious_keywords = [\n        'http', 'https', 'cmd', 'powershell', 'mutex', 'pipe',\n        'password', 'credential', 'inject', 'hook', 'debug',\n        'sandbox', 'virtual', 'vmware', 'vbox',\n    ]\n\n    print(\"\\n[+] Suspicious ASCII strings:\")\n    for s in strings['ascii']:\n        if any(kw in s.lower() for kw in suspicious_keywords):\n            print(f\"  $ = \\\"{s}\\\" ascii\")\n\n    print(\"\\n[+] Suspicious wide strings:\")\n    for s in strings['wide']:\n        if any(kw in s.lower() for kw in suspicious_keywords):\n            print(f\"  $ = \\\"{s}\\\" wide\")\n\n    # Import analysis\n    imports = analyze_pe_imports(filepath)\n    suspicious_apis = [\n        'VirtualAlloc', 'VirtualProtect', 'WriteProcessMemory',\n        'CreateRemoteThread', 'NtUnmapViewOfSection', 'RtlMoveMemory',\n        'OpenProcess', 'CreateToolhelp32Snapshot',\n        'InternetOpenA', 'HttpSendRequestA',\n        'CryptEncrypt', 'CryptDecrypt',\n    ]\n\n    print(\"\\n[+] Suspicious imports:\")\n    for imp in imports:\n        func = imp.split('!')[-1]\n        if func in suspicious_apis:\n            print(f\"  {imp}\")\n\n    # Byte patterns\n    print(\"\\n[+] Candidate hex patterns:\")\n    patterns = find_unique_byte_patterns(filepath)\n    for p in patterns[:5]:\n        print(f\"  $hex = {{ {p} }}\")\n\n\nif __name__ == \"__main__\":\n    if len(sys.argv) \u003C 2:\n        print(f\"Usage: {sys.argv[0]} \u003Csample_path>\")\n        sys.exit(1)\n    suggest_rule_strings(sys.argv[1])\n```\n\n### Step 2: Write and Test YARA Rules\n\n```python\nimport yara\nimport os\n\ndef create_yara_rule(rule_name, meta, strings, condition):\n    \"\"\"Generate a YARA rule from components.\"\"\"\n    meta_str = \"\\n\".join(f'        {k} = \"{v}\"' for k, v in meta.items())\n    strings_str = \"\\n\".join(f\"        {s}\" for s in strings)\n\n    rule = f\"\"\"rule {rule_name} {{\n    meta:\n{meta_str}\n\n    strings:\n{strings_str}\n\n    condition:\n        {condition}\n}}\"\"\"\n    return rule\n\n\ndef test_yara_rule(rule_text, test_dir):\n    \"\"\"Compile and test YARA rule against sample directory.\"\"\"\n    try:\n        rules = yara.compile(source=rule_text)\n    except yara.SyntaxError as e:\n        print(f\"[-] YARA syntax error: {e}\")\n        return None\n\n    results = {\"matches\": [], \"no_match\": []}\n\n    for filename in os.listdir(test_dir):\n        filepath = os.path.join(test_dir, filename)\n        if not os.path.isfile(filepath):\n            continue\n\n        matches = rules.match(filepath)\n        if matches:\n            results[\"matches\"].append({\n                \"file\": filename,\n                \"rules\": [m.rule for m in matches],\n            })\n        else:\n            results[\"no_match\"].append(filename)\n\n    print(f\"[+] Matches: {len(results['matches'])}\")\n    print(f\"[-] No match: {len(results['no_match'])}\")\n    return results\n\n\n# Example: Create a rule for a hypothetical malware family\nexample_rule = create_yara_rule(\n    rule_name=\"MalwareFamily_Variant_A\",\n    meta={\n        \"description\": \"Detects MalwareFamily Variant A\",\n        \"author\": \"Malware Analysis Team\",\n        \"date\": \"2025-01-01\",\n        \"hash\": \"abc123...\",\n        \"tlp\": \"WHITE\",\n    },\n    strings=[\n        '$mutex = \"Global\\\\\\\\UniqueM4lwareMutex\" ascii wide',\n        '$c2_pattern = \u002Fhttps?:\\\\\u002F\\\\\u002F[a-z]{5,10}\\\\.(xyz|top|buzz)\\\\\u002Fgate\\\\.php\u002F',\n        '$api1 = \"VirtualAllocEx\" ascii',\n        '$api2 = \"WriteProcessMemory\" ascii',\n        '$api3 = \"CreateRemoteThread\" ascii',\n        '$hex_decrypt = { 8B 45 ?? 33 C1 89 45 ?? 83 C1 04 }',\n        '$pdb = \"C:\\\\\\\\Users\\\\\\\\\" ascii',\n    ],\n    condition=(\n        'uint16(0) == 0x5A4D and filesize \u003C 2MB and '\n        '($mutex or $c2_pattern) and '\n        '2 of ($api*) and '\n        '$hex_decrypt'\n    ),\n)\n\nprint(example_rule)\n```\n\n### Step 3: Performance Testing and Optimization\n\n```python\nimport time\n\ndef benchmark_rule(rule_text, scan_directory, iterations=3):\n    \"\"\"Benchmark YARA rule scan performance.\"\"\"\n    rules = yara.compile(source=rule_text)\n\n    files = []\n    for root, _, filenames in os.walk(scan_directory):\n        for f in filenames:\n            files.append(os.path.join(root, f))\n\n    print(f\"[+] Benchmarking against {len(files)} files \"\n          f\"({iterations} iterations)\")\n\n    times = []\n    for i in range(iterations):\n        start = time.perf_counter()\n        matches = 0\n        for filepath in files:\n            try:\n                result = rules.match(filepath)\n                if result:\n                    matches += 1\n            except Exception:\n                pass\n        elapsed = time.perf_counter() - start\n        times.append(elapsed)\n        print(f\"  Iteration {i+1}: {elapsed:.3f}s ({matches} matches)\")\n\n    avg_time = sum(times) \u002F len(times)\n    files_per_sec = len(files) \u002F avg_time\n    print(f\"\\n[+] Average: {avg_time:.3f}s ({files_per_sec:.0f} files\u002Fsec)\")\n    return avg_time\n```\n\n## Validation Criteria\n\n- YARA rules compile without syntax errors\n- Rules detect target malware family samples with zero false negatives\n- False positive rate below 0.1% when scanned against clean file corpus\n- Rule performance allows scanning 1000+ files per second\n- Rules survive minor malware modifications (recompilation, string changes)\n- Metadata includes hash, author, date, description, and TLP marking\n\n## References\n\n- [YARA Official Documentation](https:\u002F\u002Fvirustotal.github.io\u002Fyara\u002F)\n- [YARA-X Rewrite in Rust](https:\u002F\u002Fgithub.com\u002FVirusTotal\u002Fyara-x)\n- [Yara-Rules Community Repository](https:\u002F\u002Fgithub.com\u002FYara-Rules\u002Frules)\n- [ReversingLabs - Writing Detailed YARA Rules](https:\u002F\u002Fwww.reversinglabs.com\u002Fblog\u002Fwriting-detailed-yara-rules-for-malware-detection)\n- [YARA Rule Crafting Deep Dive](https:\u002F\u002Fcyberthreatintelligencenetwork.com\u002Findex.php\u002F2024\u002F09\u002F11\u002Fyara-rule-crafting-a-deep-dive-into-signature-based-threat-hunting-strategies\u002F)\n",{"name":5,"tags":25,"author":33,"domain":34,"license":15,"version":35,"nist_csf":36,"subdomain":41,"description":7,"mitre_attack":42},[26,27,28,29,30,31,32],"yara","malware-detection","signature-development","threat-hunting","pattern-matching","yara-x","indicator-development","mahipal","cybersecurity","1.0",[37,38,39,40],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[43,44,45,46],"T1027","T1055","T1140","T1497","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add NeelakshSaxena\u002FVayu --skill performing-yara-rule-development-for-detection",{"tool":60,"command":61},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill performing-yara-rule-development-for-detection",{"tool":63,"command":64},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill performing-yara-rule-development-for-detection","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FSKILL.md",true,[68,74,78,84,88,92,98],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"assets\u002Ftemplate.md","ASSET","资产文件",633,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fassets\u002Ftemplate.md",{"path":75,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fapi-reference.md","REFERENCE","参考文档",1947,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fapi-reference.md",{"path":85,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Fstandards.md",1424,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fstandards.md",{"path":89,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fworkflows.md",1764,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fworkflows.md",{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"scripts\u002Fagent.py","SCRIPT","脚本",5704,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fscripts\u002Fagent.py",{"path":99,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":100,"sourceHtmlUrl":101},"scripts\u002Fprocess.py",8731,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fscripts\u002Fprocess.py",[103,110,117,124,131,138],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":20},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]