Skip to content

meltedinhex/analyst-ai-pack / skills/recovering-injected-code-and-shellcode

recovering-injected-code-and-shellcode

Verified

Carves injected PE images and position-independent shellcode from a memory dump or carved region, identifies the payload type, and prepares it for disassembly or emulation. Activates for requests to recover injected code, carve shellcode from memory, or reconstruct a dumped payload for analysis.

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

references/api-reference.md

View on GitHub
# API Reference: Recovering Injected Code and Shellcode

## Overview

`scripts/analyst.py` triages a carved memory region: it locates embedded MZ/PE headers (validating
`e_lfanew` → `PE\0\0` and reading the Machine field) and scans for position-independent code
markers. It reads bytes statically and executes nothing.

## Dependencies

| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | struct, JSON, file IO |

## Core functions

### `identify(path)`
Returns embedded PE offsets/architecture, shellcode hint flags, and whether the region is likely
raw shellcode.

### `_pe_at(data, off)`
Validates an MZ/PE header at an offset and returns its architecture.

## PIC markers detected

- GetPC stubs (`call $+5`, `fnstenv`)
- PEB access (`fs:[30]` x86, `gs:[60]` x64)
- API-hashing loops (`lodsb` + `ror 13`)

## Usage

```bash
python scripts/analyst.py identify region.bin
```

## Sources

- MITRE ATT&CK T1620 Reflective Code Loading — https://attack.mitre.org/techniques/T1620/
- MITRE ATT&CK T1055 Process Injection — https://attack.mitre.org/techniques/T1055/
- PE/COFF specification (e_lfanew, Machine values); ror13 API-hash pattern from public shellcode research
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: 319kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 319kUpdated 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: 319kUpdated 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: 319kUpdated Claude CodeCodexVerifiedInstall