Skip to content

meltedinhex/analyst-ai-pack / skills/reverse-engineering-shellcode

reverse-engineering-shellcode

Unverified

Analyzes position-independent shellcode: disassembling raw bytes at the right architecture, recognizing PEB-walk API resolution and egg hunters, and emulating execution to recover behavior and payloads. Activates for requests to analyze shellcode, disassemble raw position-independent code, or emulate a shellcode blob.

FileKindSize
LICENSEother340 B
SKILL.mdskill md3.4 KB
references/api-reference.mdmarkdown1.2 KB
scripts/analyst.pyscript3.2 KB

references/api-reference.md

View on GitHub
# API Reference: Reverse Engineering Shellcode

## Overview

`scripts/analyst.py` disassembles raw shellcode with Capstone and emulates it with Unicorn under
a bounded instruction count, capturing executed addresses. Both operate inside the
disassembler/emulator; the shellcode never runs as a real process.

## Dependencies

| Package | Version | Purpose |
|---------|---------|---------|
| capstone | >= 5.0 | Linear disassembly of x86/x64 bytes |
| unicorn | >= 2.0 | CPU emulation for self-decoding stubs |

## Core functions

### `disasm(data, arch, base, limit)`
Returns disassembled instructions (address, mnemonic, operands) at the chosen architecture.

### `emulate(data, arch, base, max_insns)`
Maps memory, writes the blob, hooks each instruction, and runs with a bounded count; returns
executed-instruction stats and the stop address.

## Usage

```bash
pip install capstone unicorn
python scripts/analyst.py disasm shellcode.bin --arch x64 --base 0x140000000
python scripts/analyst.py emulate shellcode.bin --arch x64
```

## Sources

- Capstone disassembly framework — https://www.capstone-engine.org/
- Unicorn CPU emulator — https://www.unicorn-engine.org/
- PEB-walk API resolution in Windows shellcode (kernel32 export hashing), standard technique
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: 318kUpdated Claude CodeCodexUnverifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 318kUpdated Claude CodeCodexUnverifiedInstall
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: 318kUpdated Claude CodeCodexUnverifiedInstall
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: 318kUpdated Claude CodeCodexUnverifiedInstall