Reverse Engineering Binaries
Use when the ask is to understand a binary, firmware blob, or opcode
stream. Use deep-exploitation after you have a crash or a primitive.
When to use
- "what is this ELF / PE / Mach-O"
- recover strings, imports, mitigations, or a function algorithm
- assemble / disassemble via
PWN::Plugins::Assembly or pwn-asm
Methodologies
- NIST SP 800-115: target analysis / static+dynamic review
- OWASP FSTM stages 1-6 when the file is firmware (then
hardware-and-firmware-testing)
- CWE-119 / CWE-676 / CWE-416 for sink notes
- MITRE ATT&CK Execution / Discovery labels in the write-up
Tooling
- File:
file, readelf -a, objdump -d, strings -n 8, nm, ldd.
- Mitigations:
checksec --file=BIN.
- RE:
radare2 / Cutter, Ghidra, IDA as installed.
- Dynamic:
strace, ltrace, gdb.
- PWN:
PWN::Plugins::Assembly (asm <-> opcodes, multi-arch),
BannedFunctionCallsC / UseAfterFree SAST on available source,
PWN::Plugins::Fuzz if you move to crash-finding.
PWN::Plugins::Assembly.opcodes_to_asm(opcodes: '90 90', arch: 'x86_64')
PWN::Plugins::Assembly.asm_to_opcodes(asm: 'nop', arch: 'x86_64')
Procedure
file + hashes. Note arch, linking, stripped or not.
checksec / readelf -l for NX, PIE, RELRO, canary, rpath.
strings + import table (readelf -d / objdump -T) for the
interesting surface (crypto, net, parser, system/strcpy).
- Locate the function (symbols, strings xrefs, entry). Disassemble.
- If packed, unpack first (UPX or a loader dump) - do not invent
control flow from a packed blob.
- Write notes: purpose, inputs, dangerous sinks, unanswered questions.
- Hand off to
deep-exploitation only when you have a sink + control.
Pitfalls
- Do not paste a 4k disassembly as the answer. Summarize, keep the
artefact on disk, read it back.
- Firmware without a known base address is not "fully reversed" after
one
strings.
pwn-asm is for opcode work, not a substitute for checksec.
Verification
Notes on disk (or in the final) include arch, mitigations, and at least
one concrete function or sink with evidence from the tools above.
1---2name: reverse-engineering-binaries3description: Triage a binary with checksec, disassembly, and PWN::Plugins::Assembly.4license: MIT5allowed-tools: [pwn, terminal]6metadata:7 source: https://skillmd.com/skills/0dayinc/reverse-engineering-binaries8 bundled: true9 references:10 - CWE-11911 - CWE-67612---1314# Reverse Engineering Binaries1516Use when the ask is to understand a binary, firmware blob, or opcode17stream. Use `deep-exploitation` after you have a crash or a primitive.1819## When to use2021- "what is this ELF / PE / Mach-O"22- recover strings, imports, mitigations, or a function algorithm23- assemble / disassemble via `PWN::Plugins::Assembly` or `pwn-asm`2425## Methodologies2627- NIST SP 800-115: target analysis / static+dynamic review28- OWASP FSTM stages 1-6 when the file is firmware (then29 `hardware-and-firmware-testing`)30- CWE-119 / CWE-676 / CWE-416 for sink notes31- MITRE ATT&CK Execution / Discovery labels in the write-up3233## Tooling3435- File: `file`, `readelf -a`, `objdump -d`, `strings -n 8`, `nm`, `ldd`.36- Mitigations: `checksec --file=BIN`.37- RE: `radare2` / Cutter, Ghidra, IDA as installed.38- Dynamic: `strace`, `ltrace`, gdb.39- PWN: `PWN::Plugins::Assembly` (asm <-> opcodes, multi-arch),40 `BannedFunctionCallsC` / `UseAfterFree` SAST on available source,41 `PWN::Plugins::Fuzz` if you move to crash-finding.4243```ruby44PWN::Plugins::Assembly.opcodes_to_asm(opcodes: '90 90', arch: 'x86_64')45PWN::Plugins::Assembly.asm_to_opcodes(asm: 'nop', arch: 'x86_64')46```4748## Procedure49501. `file` + hashes. Note arch, linking, stripped or not.512. `checksec` / `readelf -l` for NX, PIE, RELRO, canary, rpath.523. `strings` + import table (`readelf -d` / `objdump -T`) for the53 interesting surface (crypto, net, parser, `system`/`strcpy`).544. Locate the function (symbols, strings xrefs, entry). Disassemble.555. If packed, unpack first (UPX or a loader dump) - do not invent56 control flow from a packed blob.576. Write notes: purpose, inputs, dangerous sinks, unanswered questions.587. Hand off to `deep-exploitation` only when you have a sink + control.5960## Pitfalls6162- Do not paste a 4k disassembly as the answer. Summarize, keep the63 artefact on disk, read it back.64- Firmware without a known base address is not "fully reversed" after65 one `strings`.66- `pwn-asm` is for opcode work, not a substitute for `checksec`.6768## Verification6970Notes on disk (or in the final) include arch, mitigations, and at least71one concrete function or sink with evidence from the tools above.