meltedinhex/analyst-ai-pack / skills/defeating-control-flow-flattening
defeating-control-flow-flattening
VerifiedDefeats control-flow-flattening obfuscation by identifying the dispatcher/state- variable structure and reconstructing the original control flow so the logic becomes readable. Activates for requests to defeat control-flow flattening, deobfuscate an OLLVM-flattened function, or recover original control flow from a dispatcher loop.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 2.7 KB |
| references/api-reference.md | markdown | 1.3 KB |
| scripts/analyst.py | script | 2.3 KB |
references/api-reference.md
View on GitHub# API Reference: Defeating Control-Flow Flattening
## Overview
`scripts/analyst.py` consumes a function CFG (basic blocks with successors, in-degree, state-compare
flag, and next-state constants) and reconstructs the original control flow by identifying the
dispatcher and mapping each case's next-state to its successor. It parses JSON only and executes
nothing.
## Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | JSON, argparse, pathlib |
## Input format
```json
{
"state_var": "eax",
"entry": "A",
"blocks": [
{"id": "D", "succ": ["B","C"], "in_degree": 5, "state_compare": true},
{"id": "B", "succ": ["D"], "in_degree": 1, "next_state": "C"}
]
}
```
## Core functions
### `detect(path)`
Returns the dispatcher, case count, deflattened transitions, and unresolved blocks.
## Method
Dispatcher = highest in-degree block that compares the state variable; case blocks branch back to
it; each case's `next_state` constant gives the true successor.
## Usage
```bash
python scripts/analyst.py detect cfg.json
```
## Sources
- Obfuscator-LLVM control-flow flattening — https://github.com/obfuscator-llvm/obfuscator
- MITRE ATT&CK T1027 Obfuscated Files or Information — https://attack.mitre.org/techniques/T1027/
- Dispatcher/state-variable deflattening method from public deobfuscation research
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 |