Skip to content

meltedinhex/analyst-ai-pack / skills/writing-yara-rules-from-reversed-code

writing-yara-rules-from-reversed-code

Verified

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 signature, or convert RE findings into hunting rules.

FileKindSize
LICENSEother340 B
SKILL.mdskill md3.3 KB
references/api-reference.mdmarkdown1.2 KB
scripts/analyst.pyscript2.1 KB

references/api-reference.md

View on GitHub
# API Reference: Writing YARA Rules from Reversed Code

## Overview

`scripts/analyst.py` scaffolds a structured YARA rule with `meta`, placeholder byte-pattern
strings, an optional API-hash constant (emitted little-endian), and a multi-anchor condition
with a PE prefilter. It emits text only and scans nothing.

## Dependencies

| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | text generation |

## External tools

| Tool | Purpose |
|------|---------|
| yara | Compile and test rules against the corpus |
| yara-python | Programmatic testing/automation |

## Core functions

### `scaffold(name, api_hash, author)`
Returns a YARA rule skeleton; if `api_hash` is given, adds a little-endian byte-pattern string
and includes it in the condition.

## Usage

```bash
python scripts/analyst.py scaffold --name family_xyz --hash 0xABCDEF12
yara -r rules/family_xyz.yar ./corpus
```

## Sources

- YARA documentation — https://yara.readthedocs.io/
- YARA style guide (writing maintainable, low-FP rules) —
  https://github.com/Neo23x0/YARA-Style-Guide
- Preference for code/constant anchors over volatile strings, established RE detection practice
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall