| 1 | ROPgadget Tool |
| 2 | ============== |
| 3 | |
| 4 | This tool lets you search your gadgets on your binaries to facilitate your ROP |
| 5 | exploitation. ROPgadget supports ELF/PE/Mach-O/Raw formats on x86, x64, ARM, |
| 6 | ARM64, PowerPC, SPARC, MIPS, RISC-V 64, and RISC-V Compressed architectures. |
| 7 | |
| 8 | Install |
| 9 | ------- |
| 10 | |
| 11 | The easiest way is installing ROPgadget from PyPi: |
| 12 | |
| 13 | $ sudo apt install python3-pip |
| 14 | $ sudo -H python3 -m pip install ROPgadget |
| 15 | $ ROPgadget --help |
| 16 | |
| 17 | Alternatively you can install ROPgadget from source. |
| 18 | You have to install [Capstone](http://www.capstone-engine.org/) first. |
| 19 | |
| 20 | For the Capstone's installation on nix machine: |
| 21 | |
| 22 | $ sudo apt install python3-pip |
| 23 | $ sudo -H python3 -m pip install capstone |
| 24 | |
| 25 | Capstone supports multi-platforms (windows, ios, android, cygwin...). For the cross-compilation, |
| 26 | please refer to the https://github.com/capstone-engine/capstone/blob/master/COMPILE.TXT file. |
| 27 | |
| 28 | After Capstone is installed, ROPgadget can be used as a standalone tool: |
| 29 | |
| 30 | $ python3 ROPgadget.py --help |
| 31 | |
| 32 | Or installed into the Python site-packages library, and executed from $PATH. |
| 33 | |
| 34 | $ sudo -H python3 setup.py install |
| 35 | $ ROPgadget --help |
| 36 | |
| 37 | Usage |
| 38 | ----- |
| 39 | |
| 40 | usage: ROPgadget.py [-h] [-v] [-c] [--binary <binary>] [--opcode <opcodes>] |
| 41 | [--string <string>] [--memstr <string>] [--depth <nbyte>] |
| 42 | [--only <key>] [--filter <key>] [--range <start-end>] |
| 43 | [--badbytes <byte>] [--rawArch <arch>] [--rawMode <mode>] |
| 44 | [--rawEndian <endian>] [--re <re>] [--offset <hexaddr>] |
| 45 | [--ropchain] [--thumb] [--console] [--norop] [--nojop] |
| 46 | [--callPreceded] [--nosys] [--multibr] [--all] [--noinstr] |
| 47 | [--dump] [--silent] [--align ALIGN] [--mipsrop <rtype>] |
| 48 | |
| 49 | description: |
| 50 | ROPgadget lets you search your gadgets on a binary. It supports several |
| 51 | file formats and architectures and uses the Capstone disassembler for |
| 52 | the search engine. |
| 53 | |
| 54 | formats supported: |
| 55 | - ELF |
| 56 | - PE |
| 57 | - Mach-O |
| 58 | - Raw |
| 59 | |
| 60 | architectures supported: |
| 61 | - x86 |
| 62 | - x86-64 |
| 63 | - ARM |
| 64 | - ARM64 |
| 65 | - MIPS |
| 66 | - PowerPC |
| 67 | - Sparc |
| 68 | - RISC-V 64 |
| 69 | - RISC-V Compressed |
| 70 | |
| 71 | optional arguments: |
| 72 | -h, --help show this help message and exit |
| 73 | -v, --version Display the ROPgadget's version |
| 74 | -c, --checkUpdate Checks if a new version is available |
| 75 | --binary <binary> Specify a binary filename to analyze |
| 76 | --opcode <opcodes> Search opcode in executable segment |
| 77 | --string <string> Search string in readable segment |
| 78 | --memstr <string> Search each byte in all readable segment |
| 79 | --depth <nbyte> Depth for search engine (default 10) |
| 80 | --only <key> Only show specific instructions |
| 81 | --filter <key> Suppress specific mnemonics |
| 82 | --range <start-end> Search between two addresses (0x...-0x...) |
| 83 | --badbytes <byte> Rejects specific bytes in the gadget's address |
| 84 | --rawArch <arch> Specify an arch for a raw file |
| 85 | x86|arm|arm64|sparc|mips|ppc|riscv |
| 86 | --rawMode <mode> Specify a mode for a raw file 32|64|arm|thumb |
| 87 | --rawEndian <endian> Specify an endianness for a raw file little|big |
| 88 | --re <re> Regular expression |
| 89 | --offset <hexaddr> Specify an offset for gadget addresses |
| 90 | --ropchain Enable the ROP chain generation |
| 91 | --thumb Use the thumb mode for the search engine (ARM only) |
| 92 | --console Use an interactive console for search engine |
| 93 | --norop Disable ROP search engine |
| 94 | --nojop Disable JOP search engine |
| 95 | --callPreceded Only show gadgets which are call-preceded |
| 96 | --nosys Disable SYS search engine |
| 97 | --multibr Enable multiple branch gadgets |
| 98 | --all Disables the removal of duplicate gadgets |
| 99 | --noinstr Disable the gadget instructions console printing |
| 100 | --dump Outputs the gadget bytes |
| 101 | --silent Disables printing of gadgets during analysis |
| 102 | --align ALIGN Align gadgets addresses (in bytes) |
| 103 | --mipsrop <rtype> MIPS useful gadgets finder |
| 104 | stackfinder|system|tails|lia0|registers |
| 105 | |
| 106 | examples: |
| 107 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 |
| 108 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --ropchain |
| 109 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --depth 3 |
| 110 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "main" |
| 111 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "m..n" |
| 112 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --opcode c9c3 |
| 113 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --only "mov|ret" |
| 114 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --only "mov|pop|xor|ret" |
| 115 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --filter "xchg|add|sub|cmov.*" |
| 116 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --norop --nosys |
| 117 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --range 0x08041000-0x08042000 |
| 118 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string main --range 0x080c9aaa-0x080c9aba |
| 119 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --memstr "/bin/sh" |
| 120 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --console |
| 121 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --badbytes "00|01-1f|7f|42" |
| 122 | ROPgadget.py --binary ./test-suite-binaries/Linux_lib64.so --offset 0xdeadbeef00000000 |
| 123 | ROPgadget.py --binary ./test-suite-binaries/elf-ARMv7-ls --depth 5 |
| 124 | ROPgadget.py --binary ./test-suite-binaries/elf-ARM64-bash --depth 5 |
| 125 | ROPgadget.py --binary ./test-suite-binaries/raw-x86.raw --rawArch=x86 --rawMode=32 |
| 126 | ROPgadget.py --binary ./test-suite-binaries/elf-Linux-RISCV_64 --depth 8 |
| 127 | |
| 128 | How can I contribute ? |
| 129 | ---------------------- |
| 130 | |
| 131 | - Add system gadgets for PPC, Sparc, ARM64 (Gadgets.addSYSGadgets()). |
| 132 | - Support RISC-V 32-bit. |
| 133 | - Handle bad bytes in data during ROP chain generation. |
| 134 | - Manage big endian in Mach-O format like the ELF class. |
| 135 | - Everything you think is cool :) |
| 136 | |
| 137 | Bugs/Patches/Contact |
| 138 | -------------------- |
| 139 | |
| 140 | Please, report bugs, submit pull requests, etc. on GitHub at https://github.com/JonathanSalwan/ROPgadget |
| 141 | |
| 142 | License |
| 143 | ------- |
| 144 | |
| 145 | See LICENSE_BSD.txt and the license header on all source files. |
| 146 | |
| 147 | Screenshots |
| 148 | ----------- |
| 149 | |
| 150 | <img src="http://shell-storm.org/project/ROPgadget/x64.png" alt="x64"></img> |
| 151 | |
| 152 | <img src="http://shell-storm.org/project/ROPgadget/arm.png" alt="ARM"></img> |
| 153 | |
| 154 | <img src="http://shell-storm.org/project/ROPgadget/sparc.png" alt="Sparc"></img> |
| 155 | |
| 156 | <img src="http://shell-storm.org/project/ROPgadget/mips.png" alt="MIPS"></img> |
| 157 | |
| 158 | <img src="http://shell-storm.org/project/ROPgadget/ppc.png" alt="PowerPC"></img> |
| 159 | |
| 160 | <img src="http://shell-storm.org/project/ROPgadget/ropchain.png" alt="ROP chain"></img> |