yara-rule-writing-malware

yara-rule-writing-malware is a skill for Claude Code from akashrpatil/awesome-offensive-security-skills. It costs 52 tokens per session (1,183 once invoked), scanned A, original, Apache-2.0.

A guide to writing YARA rules, which are text and binary pattern descriptions used to identify malware files.

In plain words
What is it for?
It is for creating custom malware detection rules from strings, regular expressions, and hexadecimal code patterns.
Why use it?
It helps responders find related copies of a known malware sample across an environment after discovering one infection.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is - [`_shared/references/elite-chaining-strategy.md`](../_shared/references/elite-chaining-strategy.md) — Exploit chaining methodology and high-payout chain patte.

Part of the cyberskills-elite plugin — 191 skills shipped together

Good fit It is for creating custom malware detection rules from strings, regular expressions, and hexadecimal code patterns.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/akashrpatil/awesome-offensive-security-skills
agentmods
npx agentmods add skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware

Made for: Claude Code.

Or install cyberskills-elite, the plugin that ships this one along with the rest of its 191 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for yara-rule-writing-malware

README.md
[![agentmods](https://agentmods.dev/badge/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware/github.svg)](https://agentmods.dev/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware)
Your own site
<a href="https://agentmods.dev/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware"><img src="https://agentmods.dev/badge/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for yara-rule-writing-malware

Your own site · 80×15
<a href="https://agentmods.dev/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware"><img src="https://agentmods.dev/badge/skills/akashrpatil/awesome-offensive-security-skills/yara-rule-writing-malware.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,183 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01183
Opus 5 $0.00026 $0.00592
Sonnet 5 $0.00010 $0.00237
Haiku 4.5 $0.00005 $0.00118

Measured 9d ago against content hash 9e9190541eb1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

yara-rule-writing-malware scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/process.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/incident-response/threat-hunting/yara-rule-writing-malware/SKILL.md · 153 lines

How it starts

The opening of the file, as written. The whole thing — 153 lines — stays where its author put it; the contents beside it link to each section on GitHub.

YARA Rule Writing for Malware Detection

When to Use

  • When performing incident response and you need to scan the entire environment for indicators of compromise (IoCs) related to a specific malware family.
  • After extracting unique string patterns, mutexes, paths, or code blocks from a malware sample during static/dynamic analysis.

Prerequisites

  • Authorized scope and rules of engagement for the target environment
  • Appropriate tools installed on the attack/analysis platform
  • Understanding of the target technology stack and architecture
  • Documentation template ready for findings and evidence capture

Workflow

Phase 1: Understanding Basic YARA Structure

# Concept: Rule syntax rule Basic_Ransomware_Detection {
    meta:
        description = "Detects generic ransomware strings"
        author = "CyberSkills"
        date = "2024-05-10"
    
    strings:
        $s1 = "Your files have been encrypted" ascii wide nocase
        $s2 = "比特币" // Bitcoin in Chinese (UTF-8)
        $s3 = "vssadmin.exe Delete Shadows /All /Quiet" ascii wide
        
    condition:
        2 of them
}

Phase 2: Utilizing Hexadecimal Signatures

# rule Emotet_Hex_Pattern {
    meta:
        description = "Detects Emotet unpacking loop pattern"

    strings:
        // 8B 45 ?? 03 45 ?? 50 FF 15
        $hex_pattern = { 8B 45 ?? 03 45 ?? 50 FF 15 [4] }
        
    condition:
        $hex_pattern
}

Phase 3: Leveraging the PE Module (Windows Executables)

# import module import "pe"

rule Suspicious_Document_Icon {
    meta:
        description = "Executable disguised as PDF/Word doc"
        
    condition:
        uint16(0) == 0x5a4d and // MZ header
        pe.number_of_resources > 0 and 
        (
            pe.version_info["OriginalFilename"] contains ".pdf" or
            pe.version_info["OriginalFilename"] contains ".docx"
        )
}

Phase 4: Validating and Executing the Scan

# yara -r my_rules.yar /path/to/suspicious/files/

Read the full file on GitHub · 153 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 153 lines · 52 tokens per session scan A 9e9190541eb1

Subscribe to this mod's changes

yara-rule-writing-malware is a skill published in the GitHub repository akashrpatil/awesome-offensive-security-skills (5 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 52 tokens to every session and 1,183 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

writing-yara-rules-from-reversed-code

Turns reverse-engineering findings into durable YARA detections: selecting stable code constructs and constants over volatile strings, extracting opcode/byte patterns with wildcards, and validating rules for low false positives. Activates for requests to write a YARA rule from reversed code, create a detection…

meltedinhex/analyst-ai-pack · 76 tokens

scanning-samples-with-yara

Uses YARA to classify and triage samples at scale: applying rule sets, reading matches and string offsets, tuning for false positives, and organizing rules for malware family identification. Activates for requests to scan files with YARA, apply YARA rules, or classify samples by signature.

meltedinhex/analyst-ai-pack · 65 tokens

analyzing-malicious-pdf-with-peepdf

Perform static analysis of malicious PDF documents using peepdf, pdfid, and pdf-parser to extract embedded JavaScript, shellcode, and suspicious objects. Use when triaging a suspicious PDF attachment from a phishing email, analyzing a PDF-based exploit document, or building detection signatures for weaponized PDF…

mukul975/Anthropic-Cybersecurity-Skills · 73 tokens

analyzing-elf-binaries-on-linux

Statically analyzes Linux ELF malware: ELF header and sections, dynamic symbols and imports, segment permissions, embedded strings, and packing indicators to infer capability without execution. Activates for requests to analyze an ELF binary, Linux malware, or shared object.

meltedinhex/analyst-ai-pack · 59 tokens

analyzing-mach-o-binaries-on-macos

Statically analyzes macOS Mach-O malware: parsing the header and load commands, handling fat/universal binaries, reading linked dylibs and entitlements, and checking code signatures to infer capability and trust. Activates for requests to analyze a Mach-O binary, inspect macOS malware, or parse load commands and…

meltedinhex/analyst-ai-pack · 75 tokens

analyzing-malicious-lnk-files

Analyzes weaponized Windows shortcut (.lnk) files: parsing the shell link structure for the target command, arguments, icon, and working directory, and recovering hidden PowerShell/cmd payloads and embedded content used in phishing. Activates for requests to analyze a malicious LNK, parse a shortcut file, or extract a…

meltedinhex/analyst-ai-pack · 81 tokens