Commit graph

1 commit

Author SHA1 Message Date
trvon
a5488f210e
feat: attach ROP/exploit gadgets to binary buffer-overflow findings
Turn a detected binary stack-overflow into actionable exploit material:
each buffer-overflow finding now carries candidate exploitation primitives
discovered from the same binary.

- rop_gadgets module (fold::binary, r2-gated): classifyGadgets() is a pure,
  unit-tested classifier over (addr, opcode-text) gadget pairs into reg-control
  / syscall / stack-pivot / control-flow classes, arch-aware (AArch64 + x86-64);
  discoverExploitPrimitives() enumerates via r2 /Rj, keeps top-N per class, and
  adds "win" targets (jumpable high-value func/stub addresses — system/execve/
  puts/printf/... — resolved by name via extractCallTargetNames).
- r2_backend: extractRopGadgets wraps r2 /Rj (flattened opcode text), bounded by
  search.maxhits to keep large static binaries fast (~0.5s on a 900KB binary).
- report: ExploitContext gains a GadgetRef list; BinaryBBObserver::onBufferCopy
  fills input_channel (the sink) + buffer_offset (recovered capacity) +
  controlled_value; scanBinaryWithPcode attaches the gadget inventory once when
  any binary-buffer-overflow finding exists (no cost on clean binaries, graceful
  if r2 is absent). Serialized in JSON (write + read round-trip) and SARIF.

Scope: supply classified primitives, not auto-assembled chains; attached only
to buffer-overflow findings (no standalone subcommand). Opt-in security tooling
for authorized CTF/pentest use.

Validated: libbof_overflow BOF findings now carry exploit_context.gadgets
(reg-control x0-setup sequences, stack-pivots, printf win target) +
input_channel/buffer_offset. Unit: test_rop_gadgets (8 cases). meson test 75/75.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 08:58:16 -04:00