[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ED6WTRPX3DXG5SZMAMJTTT":3,"skill-same:01M7ED6WTRPX3DXG5SZMAMJTTT":82},{"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":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7ED6WTRPX3DXG5SZMAMJTTT","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.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\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":24,"author":32,"domain":33,"license":15,"version":34,"nist_csf":35,"subdomain":40,"description":7,"mitre_attack":41},[25,26,27,28,29,30,31],"yara","malware-detection","signature-development","threat-hunting","pattern-matching","yara-x","indicator-development","mahipal","cybersecurity","1.0",[36,37,38,39],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[42,43,44,45],"T1027","T1055","T1140","T1497","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","03-逆向工程\u002Fperforming-yara-rule-development-for-detection",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-yara-rule-development-for-detection",{"tool":60,"command":61},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-yara-rule-development-for-detection",{"tool":63,"command":64},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-yara-rule-development-for-detection","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fperforming-yara-rule-development-for-detection\u002FSKILL.md",true,[68,74,78],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fapi-reference.md","REFERENCE","参考文档",1947,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fapi-reference.md",{"path":75,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fstandards.md",1424,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fstandards.md",{"path":79,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fworkflows.md",1764,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fperforming-yara-rule-development-for-detection\u002Freferences\u002Fworkflows.md",[83,92,97,104,111,118],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":91},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":93,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":91},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":91},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":91},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":91},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":91},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]