Skip to content

Add --arch, machine-readable output, byte bad-chars and symbol annotation (#19-#22)#25

Merged
ricardojrdez merged 1 commit into
masterfrom
features-19-22
Jun 23, 2026
Merged

Add --arch, machine-readable output, byte bad-chars and symbol annotation (#19-#22)#25
ricardojrdez merged 1 commit into
masterfrom
features-19-22

Conversation

@ricardojrdez

@ricardojrdez ricardojrdez commented Jun 23, 2026

Copy link
Copy Markdown
Member

Implements four enhancements from the backlog.

#19--arch slice selection for fat Mach-O

Select which slice of a fat/universal Mach-O to analyse (e.g. --arch x86_64, --arch i386). Without it, the first supported slice is used (unchanged). Clear errors for an unsupported (arm64) or absent slice. Threaded through BinaryMachO.

#20 — machine-readable output --output {text,json,csv}

Structured output for scripting/pwntools. Gadget.to_dict() provides a stable record (file, vaddr, gadget, instructions, bytes, count, symbol, op, dst, src, modifies). Works for plain gadgets, --op results and --ropchain (CSV adds a chain column). text remains the default and the non-exhaustive ropchain path stays lazy.

#21--badchar-bytes

Reject gadgets whose opcode bytes contain a forbidden byte (the existing --badchar still filters the address only). Useful when the payload itself travels through a byte-restricted sink.

#22--symbols

Annotate each gadget with the nearest symbol at or below its address (name+offset). Loaders gained get_symbols():

  • ELF: .symtab / .dynsym via pyelftools.
  • Mach-O: LC_SYMTAB, parsed from the file (macholib does not expand the nlist array).
  • PE: export table via pefile.

All symbol addresses are rebased by the same delta as --base.

Other

  • Comments/docstrings switched to American English spelling.

Testing

  • 78 tests pass on Python 3.11 and 3.13.
  • New coverage: byte bad-chars, symbol annotation + nearest-symbol resolution, JSON/CSV output, ELF symbol parsing (the in-memory ELF builder now emits an optional .symtab/.strtab, so no binary blobs are committed) and Mach-O slice selection (guarded to macOS / fat /bin/ls).
  • End-to-end verified on /bin/ls (Mach-O) and a 32-bit busybox (ELF).
  • README usage block updated.

Closes #19, closes #20, closes #21, closes #22.

Generated with Claude Code

…tion

Implements issues #19-#22:

- #19 --arch: select the architecture slice of a fat Mach-O binary
  (e.g. x86_64, i386); clear error for absent/unsupported slices. Threaded
  through Binary -> MachO.
- #20 --output {text,json,csv}: machine-readable output for gadgets and ROP
  chains. Gadget.to_dict() provides the record; text stays the default and
  the non-exhaustive ropchain path keeps its laziness.
- #21 --badchar-bytes: reject gadgets whose opcode bytes contain a forbidden
  byte (the existing --badchar still filters only the address).
- #22 --symbols: annotate each gadget with the nearest symbol at or below
  its address (name+offset). Loaders gained get_symbols(): ELF (.symtab/
  .dynsym), Mach-O (LC_SYMTAB, parsed from the file as macholib does not
  expand it) and PE (export table), all rebased by the same --base delta.

Also: switch comments/docstrings to American English spelling.

Tests: 78 pass (3.11/3.13). New coverage for byte bad-chars, symbol
annotation, JSON/CSV output, ELF symbol parsing (the in-memory ELF builder
now emits an optional .symtab/.strtab) and Mach-O slice selection (guarded
to macOS). README usage block updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ricardojrdez ricardojrdez merged commit 7cb3942 into master Jun 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant