Linux & KernelEnvironment: Linux x64 with caller-supplied pwntools 4.15.0 & pyelftools in isolated Python environmentMCP Tool: inspect_binary_layout

How to REA Offline ELF Layout: Sections, Relocations & Static Mitigations

Inspect ELF64/ELF32 object layouts, symbol tables, section headers, dynamic relocations, and static binary exploit mitigations without running disassemblers or launching the binary.

AI Overview Direct AnswerHow to REA: Offline ELF Layout & Static Mitigations Quickstart Summary

In this official REA guide for Offline ELF Layout & Static Mitigations, AI coding agents (Claude Code, Cursor, Windsurf) execute 'REA_PWNTOOLS_PYTHON=/path/to/venv/bin/python rea inspect-binary-layout ./target.elf --json' to safely extract file layout, symbols, and code logic without launching unverified binaries.

Investigation ScenarioReal-World Objective

The Problem & Target Artifact

CTF challenge binary or suspicious Linux executable audit: You need to determine compiler security mitigations (NX, Canary, PIE, RELRO), section offsets, and exported dynamic symbols before attaching live debuggers.

Target Artifact: Linux ELF executable (ET_EXEC), shared library (ET_DYN), or relocatable object (ET_REL).
AI PromptClaude Code / Cursor / Windsurf

Natural Language Agent Instructions

Copy and paste this prompt directly into your AI coding agent when REA is registered via Model Context Protocol (MCP):

Prompt Template:Select All to Copy
Use REA to inspect the binary layout of ./target.elf. Check for stack canaries, NX, and full RELRO, and list all undefined symbols in the dynamic symbol table.
ExecutionTerminal & MCP Tool Call

Run REA Analysis Command

Execute the following command in your terminal or inspect the MCP JSON-RPC call executed by your agent:

CLI Command Execution
REA_PWNTOOLS_PYTHON=/path/to/venv/bin/python rea inspect-binary-layout ./target.elf --json

What REA Extracts & Returns

ELF header validation: Machine (EM_X86_64), bits (64), endianness (little), image type (ET_EXEC/ET_DYN/ET_REL)
Section header table: .text, .rodata, .data, .bss, .got, .plt, .dynamic, and SHT_STRTAB linkage
Static mitigations: Canary presence, NX non-executable stack, PIE ASLR compatibility, RELRO (None/Partial/Full)
Dynamic symbol table (.dynsym) with undefined symbols (SHN_UNDEF) needing external shared libraries

Inspected Layout Evidence (JSON Output)

The verified findings and synthesized clean-room structures generated from this investigation:

Inspected Layout Evidence (JSON Output)
{
  "artifact": { "path": "/artifacts/target.elf", "sha256": "4a2b9...", "bytes": 16424 },
  "format": "elf",
  "architecture": { "machine": "EM_X86_64", "bits": 64, "byte_order": "little" },
  "image_type": "ET_DYN",
  "entry_point": { "reported_value": "0x1060", "meaning": "linked-virtual-address" },
  "mitigations": {
    "canary": true,
    "nx": true,
    "pie": true,
    "relro": "full"
  }
}
Internal MechanicsProduction Engineering

Under-The-Hood: SHT_STRTAB Links & Relocation Addend Integrity

REA parses ELF section headers through an isolated Python worker. It enforces declared SHT_STRTAB links, ensuring symbol and section names reside inside bounded string buffers. For relocations, REA supports signed REL/RELA addends and decodes packed RELR tables without assuming an active load base. Symbol values are preserved as hexadecimal strings without unsafe floating-point truncation.

Security Guardrails & Analysis Boundary Rules

Never executes target code: The Python worker operates strictly on raw bytes with a 32 MiB input cap.
RELR packed relocation tables retain original offsets as derived evidence without guessing implicit addends.
SHN_XINDEX extended section tables resolve through section zero with strict boundary validation.