Files

1.2 KiB

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

python scripts/analyst.py identify region.bin

Sources