본문으로 건너뛰기
Skillpedia
보안35k · #8322

performing-threat-hunting-with-yara-rules

하는 일

이 도구는 특별한 규칙(YARA라고 함)을 사용해 컴퓨터 안이나 이미 저장된 파일에서 악성, 의심, 위험한 파일과 코드를 검색합니다. 숨겨진 위협을 찾는 데 도움을 줍니다.

사용하는 경우

  • ✓여러 파일에서 새롭고 알려지지 않은 바이러스를 능동적으로 찾고 싶을 때.
  • ✓격리되었거나 테스트 환경에서 가져온 파일을 분석할 때.
  • ✓보안 인텔리전스를 사용해 의심스러운 파일이 알려진 위협과 일치하는지 확인하는 경우.

스킬 링크

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

AI에게 요청하는 예시

“YARA 규칙을 사용해 '다운로드' 폴더의 파일에서 위협을 찾아 주세요.”

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

작동 방식

악성 파일이나 코드의 모습을 설명하는 ‘규칙’을 작성합니다. 그다음 도구가 이 규칙을 사용해 파일을 스캔하고, 규칙과 일치하는 것을 찾으면 알려 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Performing Threat Hunting with YARA Rules

Scan files, directories, and memory dumps using YARA rules to identify malware families, suspicious patterns, and IOC matches.

When to Use

  • Proactively hunting for unknown malware variants across network shares, endpoints, and email attachments
  • Scanning quarantine directories or sandbox outputs for malware family classification
  • Searching process memory dumps for injected code or in-memory-only payloads
  • Validating threat intelligence IOCs against a large corpus of collected samples
  • Triaging incident response artifacts to identify known malware families quickly
  • Building automated detection pipelines that scan new files on ingestion

Do not use for real-time endpoint protection (use EDR agents instead); YARA scanning is best suited for batch hunting, triage, and post-collection analysis where scan latency is acceptable.

Prerequisites

  • YARA 4.x installed (apt install yara on Debian/Ubuntu, brew install yara on macOS)
  • Python 3.8+ with yara-python (pip install yara-python)
  • yarGen for automated rule generation (git clone https://github.com/Neo23x0/yarGen)
  • Sample malware corpus or suspicious files for scanning (from malware zoos, VT, or incident artifacts)
  • Optional: pefile for PE header analysis, malduck for memory carving
  • Threat intel YARA rule sets (e.g., YARA-Rules community repository, Florian Roth signature-base)

Workflow

Step 1: Install YARA and Python Bindings

# Linux
sudo apt update && sudo apt install -y yara

# Python bindings
pip install yara-python

# Verify installation
yara --version
python3 -c "import yara; print(yara.YARA_VERSION)"

Step 2: Write a Basic YARA Rule

Create rules that match on strings, hex patterns, and file metadata:

// File: rules/emotet_loader.yar
rule Emotet_Loader_2026 {
    meta:
        author = "Threat Intel Team"
        description = "Detects Emotet first-stage loader DLL"
        date = "2026-01-20"
        reference = "https://attack.mitre.org/software/S0367/"
        mitre_attack = "T1059.001, T1055.001"
        severity = "critical"

    strings:
        // Emotet export function name patterns
        $export1 = "DllRegisterServer" ascii
        $export2 = "RunDLL" ascii nocase

        // Obfuscated string decryption routine
        $decrypt_loop = { 8B 45 ?? 33 45 ?? 89 45 ?? 8B 4D ?? 03 4D ?? }

        // PowerShell download cradle in embedded script
        $ps_cradle = /powershell[^\n]{0,50}-e(nc|ncodedcommand)/i

        // Known C2 URI patterns
        $uri1 = "/wp-content/uploads/" ascii
        $uri2 = "/wp-admin/css/" ascii
        $uri3 = "/wp-includes/" ascii

        // PE characteristics
        $mz = "MZ" at 0

    condition:
        $mz and
        filesize < 2MB and
        (
            ($export1 and $decrypt_loop) or
            ($ps_cradle and any of ($uri*)) or
            (2 of ($uri*) and $decrypt_loop)
        )
}

Step 3: Write Advanced Rules with Modules

Use YARA modules for PE header inspection and math-based entropy checks:

import "pe"
import "math"

rule Suspicious_Packed_Executable {
    meta:
        author = "Threat Hunting Team"
        description = "Detects PE files with high entropy sections indicating packing or encryption"
        severity = "medium"

    condition:
        pe.is_pe and
        pe.number_of_sections > 0 and
        for any section in pe.sections : (
            math.entropy(section.offset, section.size) > 7.2 and
            section.size > 1024
        ) and
        pe.imports("kernel32.dll", "VirtualAlloc") and
        pe.imports("kernel32.dll", "VirtualProtect")
}

rule Suspicious_UPX_Modified {
    meta:
        description = "Detects UPX-packed binaries with tampered section names"
        severity = "medium"

    strings:
        $upx_magic = { 55 50 58 21 }  // UPX!

    condition:
        pe.is_pe and
        $upx_magic and
        not (
            pe.sections[0].name == "UPX0" and
            pe.sections[1].name == "UPX1"
        )
}

Step 4: Scan Files and Directories with yara-python

import yara
import os
import json
from datetime import datetime
from pathlib import Path

def compile_rules(rule_paths):
    """Compile YARA rules from one or more .yar files."""
    rule_files = {}
    for i, path in enumerate(rule_paths):
        namespace = Path(path).stem
        rule_files[namespace] = path
    return yara.compile(filepaths=rule_files)


…
자주 묻는 질문

YARA 규칙이란 무엇인가요?

파일이나 코드의 특정 패턴을 설명하는 레시피와 같습니다. 도구에 무엇을 찾을지 알려 주며, 텍스트 문자열, 16진수 패턴, 파일 특성 등이 있습니다.

이것을 사용하려면 프로그래머여야 하나요?

경험 많은 프로그래머일 필요는 없습니다. 도구를 설치하고 단계를 따라 YARA 규칙을 만들거나 사용해야 하지만, 핵심은 찾고 싶은 것을 설명하는 것입니다.

이것이 백신을 대체하나요?

아니요. 이 도구는 이미 가지고 있거나 수집한 파일에서 위협을 능동적으로 찾는(위협 헌팅) 데 더 적합하며, 새로운 감염으로부터 실시간으로 컴퓨터를 보호하는 것은 아닙니다.

상세 정보

작성자의 원본 설명

Use YARA pattern-matching rules to hunt for malware, suspicious files, and indicators of compromise across filesystems and memory dumps. Covers rule authoring, yara-python scanning, and integration with threat intel feeds. '

repo: mukul975/Anthropic-Cybersecurity-Skills

인기도

GitHub 스타
35k
순위
#8322
라이선스
Apache-2.0
업데이트
2026. 8. 31.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬