본문으로 건너뛰기
Skillpedia
에이전트35k · #8340

performing-yara-rule-development-for-detection

하는 일

이 도구는 악성 소프트웨어(악성코드)를 식별하는 규칙을 만드는 데 도움을 줍니다. 파일을 분석해 특정 악성코드에 고유한 텍스트나 바이트 순서 같은 패턴을 찾아, 탐지를 돕고 잘못된 양성을 피합니다.

사용하는 경우

  • ✓디지털 위협에 대한 방어를 구축할 때.
  • ✓악성코드의 유형을 분류할 때.
  • ✓위협 인텔리전스를 탐지 규칙으로 바꾸는 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-yara-rule-development-for-detection/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“문자열 'evil_command'를 사용하고 IP '192.168.1.100'에 연결하는 악성코드를 탐지하는 YARA 규칙을 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 프로그램 코드에서 독특한 텍스트나 바이트 순서를 찾습니다. 이 결과를 사용해 다른 컴퓨터에서도 그 특정 프로그램을 식별할 수 있는 ‘시그니처’(YARA 규칙)를 만듭니다.

기술 내용 (원본 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 규칙이란 무엇인가요?

파일에서 발견되는 패턴을 설명하는 디지털 서명과 같습니다. 악성 소프트웨어를 식별하고 분류하는 데 사용됩니다.

‘잘못된 양성(false positives)’이란 무엇인가요?

보안 규칙이 실제로는 무해한 소프트웨어를 악성으로 잘못 표시하는 경우입니다.

‘언패킹된 악성코드 아티팩트’를 분석하는 것이 왜 중요한가요?

악성코드는 종종 자신을 위장합니다(‘패킹’). 패킹이 풀린 후의 코드를 분석하면 진짜 고유한 특성이 드러나, 탐지를 더 정확하게 만듭니다.

상세 정보

작성자의 원본 설명

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
업데이트
2026. 8. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬