$ show JonathanSalwan/ROPgadget
ROPgadget is a Python CLI security tool that statically scans executable binaries for ROP, JOP, and SYS gadgets. It discovers architecture-specific byte patterns (x86/x64, ARM/ARM64, MIPS, PowerPC, SPARC, RISC-V), disassembles candidate regions with Capstone, and outputs address/instruction listings. It supports ELF, PE, Mach-O, raw, and universal/fat binaries, and offers filtering by mnemonic, regex, bad bytes, address ranges, and call-preceded gadgets. For x86/x64 ELF targets it can also generate a Python exploit script that chains gadgets into a ROP payload.
The LLM identified 4 files worth highlighting for reuse:
Parses ELF headers and section tables using ctypes Structure definitions and exposes a uniform loader interface (getExecSections, getDataSections, getArch, getEndian, getFormat) shared with the PE, Mach-O, raw, and universal loaders. The loader contract isolates binary-format specifics from gadget search logic and could be extracted for use in other binary-analysis tools by implementing the same accessor methods.
Contains per-architecture tables of byte-pattern regexes for ROP/JOP/SYS gadgets and the Capstone disassembly glue that validates and expands matches. This decouples architecture knowledge from the core search pipeline, making the gadget-detection logic data-driven and reusable as a standalone library for other binary-analysis or exploitation tooling.
Implements post-discovery filtering as composable predicates: mnemonic/regex filtering, address-range restriction, bad-byte exclusion, and call-preceded gadget selection. The bad-byte filtering and regex-processing logic are self-contained enough to be reused in payload generators or other security tooling that needs to constrain byte sequences.
Automates ROP chain construction for x86/x64 ELF binaries by searching for write-what-where gadgets, pop-register sequences, xor/inc/add operations, and syscall gadgets, then emits a Python payload script with address packing and padding. This solves a non-trivial constraint-search problem and has clear reuse value for CTF tools and exploit-development frameworks.