JonathanSalwan / ROPgadget

This tool lets you search your gadgets on your binaries to facilitate your ROP exploitation. ROPgadget supports ELF, PE and Mach-O format on x86, x64, ARM, ARM64, PowerPC, SPARC, MIPS, RISC-V 64, and RISC-V Compressed architectures.
Other
3.96k stars 557 forks source link

Can't find the 'pop ecx' instruction #166

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, I tried using ROPgadget v6.3 on a test file with a buffer overflow and I keep getting a "Can't find the 'pop ecx' instruction" message when I try to generate the ropchain.

Anyone else has a similar problem?

Here's my code, compiled as "gcc -static test.c -o test" test.txt

Here's the ROPgadget output, using the command-line input: ROPgadget --binary test --ropchain> ropS Gadgets information >> ropS.txt

Here's ROP chain output

ROP chain generation

SweetVishnya commented 3 years ago

ROPgadget chains gadgets quite straightforward. It searches for exact pop ecx ; ret that is not contained in your binary. ROPgadget is mostly about searching gadgets. You can check out more advanced ROP chain generating tools. These tools can be found in Section 17 (Experimental tools comparison) in this paper.

SweetVishnya commented 3 years ago

Also, you'd better start with overflow via memcpy. If overflow is performed via strcpy, you should consider bad chars ('\0' which stops copying). Most open source ROP chain generation tools partially implement bad chars support. They remove gadgets with bad chars in addresses, but leave them in values loaded from stack. For instance, string "/bin/sh\x00".