meltedinhex/analyst-ai-pack / skills/measuring-section-entropy-to-detect-packing
measuring-section-entropy-to-detect-packing
VerifiedDetects packing and encryption by measuring Shannon entropy across a binary's sections and regions: flagging high-entropy executable sections, entropy spikes, and size/raw-vs-virtual anomalies that indicate compression or encryption. Activates for requests to measure entropy, detect packing, or assess whether a sample is compressed/encrypted.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 3.1 KB |
| references/api-reference.md | markdown | 1.3 KB |
| scripts/analyst.py | script | 3.0 KB |
references/api-reference.md
View on GitHub# API Reference: Measuring Section Entropy to Detect Packing
## Overview
`scripts/analyst.py` computes whole-file Shannon entropy, sliding-window peak entropy, and (for PE
files, via `pefile`) per-section entropy with raw/virtual size comparison, flagging high-entropy
executable sections. It reads the inert file and never executes it.
## Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | math (entropy), file IO |
| pefile | >= 2023.2.7 | per-section analysis (optional) |
## Core functions
### `shannon(data)`
Shannon entropy in bits/byte (0–8).
### `window_stats(data, window)`
Returns the peak entropy and the fraction of windows above the packing threshold; a sustained
high fraction (not a single window) indicates packing when section data is unavailable.
### `pe_sections(path)`
Per-section entropy, size, executable flag, and a suspicious flag.
## Usage
```bash
python scripts/analyst.py entropy sample.exe
```
## Sources
- Shannon, "A Mathematical Theory of Communication" (entropy) —
https://doi.org/10.1002/j.1538-7305.1948.tb01338.x
- Microsoft PE/COFF specification (section characteristics) —
https://learn.microsoft.com/windows/win32/debug/pe-format
- Entropy > ~7.0 in executable sections as a packing heuristic, established practice
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |