[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EW7YS9CC2YX251A0QA78R4":3,"skill-same:01M6EW7YS9CC2YX251A0QA78R4":122},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":65,"commitSha":66,"skillDirectory":67,"forksCount":14,"repositoryHtmlUrl":68,"repositoryHomepageUrl":69,"ownerHtmlUrl":70,"ownerBlogUrl":6,"ownerDescription":71,"updatedAt":72,"install":73,"resources":86},"01M6EW7YS9CC2YX251A0QA78R4","performing-yara-rule-development-for-detection",null,"Develop precise YARA rules for malware detection by identifying unique byte patterns, strings, and behavioral indicators in executable files while minimizing false positives.","henriquescastilho\u002Fmy-claude","henriquescastilho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F153296945?v=4","01M6ESH7EXPXTH9CVQ4K16SRG8","Henrique Scheer","01M6ESH7JHEK2PTNNH4HEH787Z",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"development","rule","performing yara rule development for detection","detection","yara","malware","analysis","signature-development","yara-x","indicator-development","threat-hunting","cm","files","malware detection","patterns","pattern","false","de","cybersecurity","hunting","2026-11-10 10:12:30",false,"---\nname: performing-yara-rule-development-for-detection\ndescription: Develop precise YARA rules for malware detection by identifying unique\n  byte patterns, strings, and behavioral indicators in executable files while minimizing\n  false positives.\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":49,"author":52,"domain":42,"license":15,"version":53,"nist_csf":54,"subdomain":59,"description":7,"mitre_attack":60},[28,50,31,34,51,32,33],"malware-detection","pattern-matching","mahipal","1.0",[55,56,57,58],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[61,62,63,64],"T1027","T1055","T1140","T1497","main","7925716f065257435fdb12e97f7e52842147d5ad",".claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude","https:\u002F\u002Fclaude.com\u002Fclaude-code","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho","Software · Applied AI · Quantitative Modeling · Building with Claude.","2026-06-10 12:24:46",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add henriquescastilho\u002Fmy-claude --skill performing-yara-rule-development-for-detection",{"tool":79,"command":80},"bunx","bunx skills add henriquescastilho\u002Fmy-claude --skill performing-yara-rule-development-for-detection",{"tool":82,"command":83},"pnpm","pnpm dlx skills add henriquescastilho\u002Fmy-claude --skill performing-yara-rule-development-for-detection","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FSKILL.md",true,[87,93,98,104,108,112,118],{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"assets\u002Ftemplate.md","ASSET","资产文件",633,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fassets\u002Ftemplate.md",{"path":94,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002FLICENSE",{"path":99,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"references\u002Fapi-reference.md","REFERENCE","参考文档",1947,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fapi-reference.md",{"path":105,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":106,"sourceHtmlUrl":107},"references\u002Fstandards.md",1424,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fstandards.md",{"path":109,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":110,"sourceHtmlUrl":111},"references\u002Fworkflows.md",1764,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fworkflows.md",{"path":113,"resourceType":114,"resourceTypeDesc":115,"sizeBytes":116,"sourceHtmlUrl":117},"scripts\u002Fagent.py","SCRIPT","脚本",5704,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fscripts\u002Fagent.py",{"path":119,"resourceType":114,"resourceTypeDesc":115,"sizeBytes":120,"sourceHtmlUrl":121},"scripts\u002Fprocess.py",8731,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-yara-rule-development-for-detection\u002Fscripts\u002Fprocess.py",[123,163,172,181,203,228],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":144,"publishedAt":44},"01M6F0B6XPQ65AX2X0DWK8KT3E","markitdown","Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.","MIT","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[130,133,136,139],{"categoryNo":131,"categoryName":132,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":137,"categoryName":138,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格",{"categoryNo":140,"categoryName":141,"taxonomyType":142,"taxonomyTypeDesc":143},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[125,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,36,161,162],"docx","PDF","pptx","xlsx","documents","csv","ocr","Audio","Bash","markdown","convert","read","write","edit","html","images","youtube","with",{"skillNo":164,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":171,"publishedAt":44},"01M6F06SBHR9F0SDWE282Y8075","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fscientific_writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[167,168,169,170],{"categoryNo":131,"categoryName":132,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":137,"categoryName":138,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":140,"categoryName":141,"taxonomyType":142,"taxonomyTypeDesc":143},[125,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,36,161,162],{"skillNo":173,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":180,"publishedAt":44},"01M6F02D4R14EJAPBWVDF9J9VQ","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[176,177,178,179],{"categoryNo":131,"categoryName":132,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":137,"categoryName":138,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":140,"categoryName":141,"taxonomyType":142,"taxonomyTypeDesc":143},[125,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,36,161,162],{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":44},"01M6F000KS6YB4MKS774G4R8ND","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fzarr-python\u002FSKILL.md",[],[188,189,190,191,192,193,194,195,196,197,198,199,200,201,202],"python","zarr python","storage","integration","s3","gcs","cloud","dask","parallel","pipelines","arrays","numpy","scientific computing","scale","scientific",{"skillNo":204,"name":205,"nameZh":6,"description":206,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":207,"categories":208,"keywords":210,"publishedAt":44},"01M6EZZJWFXM1GR78KTW6J0DN8","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fwhat-if-oracle\u002FSKILL.md",[209],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[211,212,213,214,215,216,30,217,218,219,220,156,157,221,222,223,224,225,226,227],"oracle","what if oracle","go","run","ux","futures","explore","decision","branch","question","idea","exploration","options","stress-test","strategies","scenario","stress",{"skillNo":229,"name":230,"nameZh":6,"description":231,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":232,"categories":233,"keywords":244,"publishedAt":44},"01M6EZZCXAEB49RXGQCJX5E8GB","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fvenue-templates\u002FSKILL.md",[234,237,240,241],{"categoryNo":235,"categoryName":236,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":238,"categoryName":239,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":242,"categoryName":243,"taxonomyType":142,"taxonomyTypeDesc":143},"01JBSEEDCAT000000000000036","内容创作者",[245,246,247,248,249,250,251,252,153,253,156,157,158,254,255,256,257,258,202,259],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","access","proposals","Academic","requirements","formatting","journal","chi"]