Skip to content

meltedinhex/analyst-ai-pack / skills/analyzing-position-independent-code

analyzing-position-independent-code

Verified

Analyzes position-independent code and shellcode by identifying GetPC/PEB-walk techniques, API-hash resolution loops, and relocation-free addressing so the payload can be disassembled at the right base. Activates for requests to analyze position-independent code, identify PIC techniques, or understand how shellcode resolves APIs without imports.

FileKindSize
LICENSEother340 B
SKILL.mdskill md2.8 KB
references/api-reference.mdmarkdown1.1 KB
scripts/analyst.pyscript1.9 KB

references/api-reference.md

View on GitHub
# API Reference: Analyzing Position-Independent Code

## Overview

`scripts/analyst.py` identifies position-independent code techniques in a shellcode blob — GetPC
stubs, PEB access (x86/x64), API-hash loops, and stack-string construction — and infers the
architecture from the PEB-access form. It reads bytes statically and executes nothing.

## Dependencies

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

## Core functions

### `analyze(path)`
Returns detected techniques, inferred architecture, PEB-walk/API-hashing flags, and a PIC flag.

## Techniques detected

- GetPC: `call $+5` (`E8 00 00 00 00`), `fldz; fnstenv`.
- PEB: `fs:[30]` (x86), `gs:[60]` (x64).
- API hashing: `lodsb` + `ror 13`.
- Stack strings: `mov [esp+x], imm`.

## Usage

```bash
python scripts/analyst.py analyze shellcode.bin
```

## Sources

- PEB/LDR structures (winternl.h) — https://learn.microsoft.com/windows/win32/api/winternl/
- MITRE ATT&CK T1027.007 Dynamic API Resolution — https://attack.mitre.org/techniques/T1027/007/
- GetPC / PEB-walk / ror13 patterns 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: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated 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: 322kUpdated 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: 322kUpdated Claude CodeCodexVerifiedInstall