मुख्य सामग्री पर जाएँ
Skillpedia
एजेंट35k · #8340

performing-yara-rule-development-for-detection

यह क्या करती है

यह टूल malware (हानिकारक सॉफ्टवेयर) को पहचानने के लिए rules बनाने में मदद करता है। यह फ़ाइलों का विश्लेषण करके ऐसे खास पैटर्न ढूंढता है, जैसे text या byte sequence, जो किसी malware की पहचान हों, ताकि उसका पता चल सके और गलत पहचान (false positives) से बचा जा सके।

कब इस्तेमाल करें

  • ✓डिजिटल खतरों से बचाव की व्यवस्था बनाते समय।
  • ✓अलग-अलग तरह के malware को वर्गीकृत करते समय।
  • ✓threat intelligence को detection rules में बदलते समय।

Skill का लिंक

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-yara-rule-development-for-detection/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-yara-rule-development-for-detection/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“एक YARA rule बनाओ जो 'evil_command' string इस्तेमाल करने वाले और IP '192.168.1.100' से जुड़ने वाले malware का पता लगाए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह टूल किसी प्रोग्राम के code में खास text या byte sequence ढूंढता है। इन्हीं के आधार पर यह एक 'signature' (YARA rule) बनाता है, जिससे दूसरे कंप्यूटरों पर वही प्रोग्राम पहचाना जा सके।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Performing YARA Rule Development for Detection

Overview

YARA 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.

When to Use

  • When conducting security assessments that involve performing yara rule development for detection
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • Python 3.9+ with yara-python library
  • YARA 4.5+ or YARA-X 0.10+
  • PE analysis tools (pefile, pestudio)
  • Hex editor for identifying unique byte patterns
  • Access to malware samples (VirusTotal, MalwareBazaar)
  • Understanding of PE file format, strings, and import tables

Key Concepts

Rule Structure

Every YARA rule consists of three sections: meta (optional descriptive metadata), strings (pattern definitions), and condition (matching logic). String types include text strings (ASCII/wide/nocase), hex patterns with wildcards and jumps, and regular expressions. Conditions combine string matches with file properties using boolean operators.

String Selection Strategy

Effective 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.

Performance Optimization

YARA 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.

Workflow

Step 1: Analyze Sample for Unique Patterns

#!/usr/bin/env python3
"""Extract candidate strings and byte patterns for YARA rule creation."""
import pefile
import re
import sys
from collections import Counter


def extract_strings(filepath, min_length=6):
    """Extract ASCII and wide strings from binary."""
    with open(filepath, 'rb') as f:
        data = f.read()

    # ASCII strings
    ascii_strings = re.findall(
        rb'[\x20-\x7e]{' + str(min_length).encode() + rb',}', data
    )

    # Wide (UTF-16LE) strings
    wide_strings = re.findall(
        rb'(?:[\x20-\x7e]\x00){' + str(min_length).encode() + rb',}', data
    )

    return {
        'ascii': [s.decode('ascii') for s in ascii_strings],
        'wide': [s.decode('utf-16-le') for s in wide_strings],
    }


def analyze_pe_imports(filepath):
    """Extract import table for API-based detection."""
    try:
        pe = pefile.PE(filepath)
    except pefile.PEFormatError:
        return []

    imports = []
    if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):
        for entry in pe.DIRECTORY_ENTRY_IMPORT:
            dll_name = entry.dll.decode('utf-8', errors='replace')
            for imp in entry.imports:
                if imp.name:
                    func_name = imp.name.decode('utf-8', errors='replace')
                    imports.append(f"{dll_name}!{func_name}")
    return imports


def find_unique_byte_patterns(filepath, pattern_length=16):
    """Find unique byte sequences suitable for YARA hex patterns."""
    with open(filepath, 'rb') as f:
        data = f.read()

    try:
        pe = pefile.PE(filepath)
        # Focus on code section
        for section in pe.sections:
            if section.Characteristics & 0x20000000:  # IMAGE_SCN_MEM_EXECUTE
                code_start = section.PointerToRawData
                code_end = code_start + section.SizeOfRawData
                code_data = data[code_start:code_end]
                break
        else:
            code_data = data

…
अक्सर पूछे जाने वाले सवाल

YARA rules क्या होते हैं?

YARA rules डिजिटल signature की तरह होते हैं, जो फ़ाइलों में मिलने वाले पैटर्न का वर्णन करते हैं। इनसे हानिकारक सॉफ्टवेयर को पहचाना और वर्गीकृत किया जाता है।

'false positives' क्या होते हैं?

False positive तब होता है जब कोई security rule किसी हानिरहित सॉफ्टवेयर को गलती से malicious मान लेता है।

'unpacked malware artifacts' का विश्लेषण क्यों ज़रूरी है?

Malware अक्सर खुद को छिपाता है ('packed' होता है)। Unpack होने के बाद उसका code देखने से उसकी असली और अनोखी पहचान सामने आती है, जिससे detection ज़्यादा सटीक होता है।

जानकारी

लेखक का मूल विवरण

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.

repo: mukul975/Anthropic-Cybersecurity-Skills

लोकप्रियता

GitHub स्टार
35k
रैंकिंग में स्थान
#8340
लाइसेंस
Apache-2.0
अपडेट की गई
31/8/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills