Skip to content
Back to skills

Recovering Injected Code And Shellcode

ASecurity

'Carves injected PE images and position-independent shellcode from a memory dump or

  • 22 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 11, 2026
securitypythonshellbashapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 11, 2026

npx -y skills add meltedinhex/analyst-ai-pack --skill recovering-injected-code-and-shellcode --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Recovering Injected Code And Shellcode?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Recovering Injected Code And Shellcode
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/meltedinhex-recovering-injected-code-and-shellcode/badge)](https://www.skillsdirectory.com/skills/meltedinhex-recovering-injected-code-and-shellcode)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: recovering-injected-code-and-shellcode
description: '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.'
domain: cybersecurity
subdomain: malware-analysis
tags:
  - malware-analysis
  - shellcode
  - memory-forensics
  - carving
  - dynamic-analysis
version: 1.0.0
author: analyst-ai-pack
license: Apache-2.0
mitre_attack:
  - T1055
  - T1620
  - T1027
d3fend:
  - D3-SDA
  - D3-DA
references:
  - '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/'
---

# Recovering Injected Code and Shellcode

## When to Use

- You have a carved memory region (from malfind/vaddump) and need to identify and extract the
  payload — an injected PE or raw shellcode.
- You need to locate likely shellcode entry points (egg hunters, GetPC stubs) before disassembly.

**Do not use** this to execute the payload — it prepares code for static disassembly/emulation in
a controlled tool, not for running.

## Prerequisites

- A carved binary region (raw bytes) from a memory image.

## Safety & Handling

- The carved region is live malicious code; store it password-protected and never execute it.

## Workflow

### Step 1: Identify payload type

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

Detects an embedded `MZ`/PE (with offset) versus raw shellcode, and reports the PE's architecture
if present.

### Step 2: Locate shellcode entry hints

Finds common position-independent code markers: GetPC stubs (`call $+5`/`fldz/fnstenv`), PEB
access (`fs:[30]`/`gs:[60]`), and API-hashing loops.

### Step 3: Extract for analysis

Carve the PE at its offset (or keep the raw shellcode) and hand it to a disassembler/emulator at
the detected base/entry.

### Step 4: Document

Record offsets, architecture, and entry hints for the downstream RE workflow.

## Validation

- An embedded PE is confirmed by `MZ` + valid `e_lfanew` → `PE\0\0`.
- Shellcode entry hints reference real PIC patterns, not arbitrary bytes.
- Architecture detection matches the PE Machine field (or PIC heuristics for raw shellcode).

## Pitfalls

- Assuming everything carved is a PE; much injected code is headerless shellcode.
- Wrong base address breaking relocations when loading a dumped PE — note it for rebuilding.
- Treating compressed/encrypted stages as final shellcode without a decode pass.

## References

- See [`references/api-reference.md`](references/api-reference.md) for the identifier.
- ATT&CK T1620 and T1055 (linked in frontmatter).

Files in this skill

  • LICENSE340 B
  • SKILL.md2.8 KB
  • references/api-reference.md1.2 KB
  • scripts/analyst.py2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.