OneGadget: The best tool for finding one gadget RCE
OneGadget
When playing ctf pwn challenges we usually need the one-gadget RCE (remote code execution), which leads to call execve(‘/bin/sh’, NULL, NULL).
This gem provides such gadgets finder, no need to use objdump or IDA-pro every time like a fool
To use this tool, type one_gadget /path/to/libc in the command line and enjoy the magic.

Installation
$ gem install one_gadget
OneGadget uses symbolic execution to find the constraints of gadgets to be successful.
Usage
[pastacode lang=”markup” message=”” highlight=”” provider=”manual” manual=”%24%20one_gadget%0A%23%20Usage%3A%20one_gadget%20%5Bfile%5D%20%5Boptions%5D%0A%23%20%20%20%20%20-b%2C%20–build-id%20BuildID%20%20%20%20%20%20%20%20%20%20%20BuildID%5Bsha1%5D%20of%20libc.%0A%23%20%20%20%20%20-f%2C%20–%5Bno-%5Dforce-file%20%20%20%20%20%20%20%20%20%20%20%20Force%20search%20gadgets%20in%20file%20instead%20of%20build%20id%20first.%0A%23%20%20%20%20%20-l%2C%20–level%20OUTPUT_LEVEL%20%20%20%20%20%20%20%20%20The%20output%20level.%0A%23%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20OneGadget%20automatically%20selects%20gadgets%20with%20higher%20successful%20probability.%0A%23%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Increase%20this%20level%20to%20ask%20OneGadget%20show%20more%20gadgets%20it%20found.%0A%23%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Default%3A%200%0A%23%20%20%20%20%20-r%2C%20–%5Bno-%5Draw%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Output%20gadgets%20offset%20only%2C%20split%20with%20one%20space.%0A%23%20%20%20%20%20-s%2C%20–script%20exploit-script%20%20%20%20%20%20Run%20exploit%20script%20with%20all%20possible%20gadgets.%0A%23%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20The%20script%20will%20be%20run%20as%20’exploit-script%20%24offset’.%0A%23%20%20%20%20%20%20%20%20%20–info%20BuildID%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Show%20version%20information%20given%20BuildID.%0A%23%20%20%20%20%20%20%20%20%20–version%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Current%20gem%20version.”/]
[pastacode lang=”markup” message=”” highlight=”” provider=”manual” manual=”%24%20one_gadget%20%2Flib%2Fx86_64-linux-gnu%2Flibc.so.6%0A%23%200x4f2c5%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x40%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20rcx%20%3D%3D%20NULL%0A%23%0A%23%200x4f322%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x40%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x40%5D%20%3D%3D%20NULL%0A%23%0A%23%200x10a38c%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x70%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x70%5D%20%3D%3D%20NULL”/]
Given BuildID
[pastacode lang=”markup” message=”” highlight=”” provider=”manual” manual=”%24%20one_gadget%20-b%20aad7dbe330f23ea00ca63daf793b766b51aceb5d%0A%23%200×45526%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x30%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20rax%20%3D%3D%20NULL%0A%23%0A%23%200x4557a%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x30%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x30%5D%20%3D%3D%20NULL%0A%23%0A%23%200xf1651%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x40%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x40%5D%20%3D%3D%20NULL%0A%23%0A%23%200xf24cb%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x60%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x60%5D%20%3D%3D%20NULL”/]

Show All Gadgets
Sometimes one_gadget finds too many gadgets to show them in one screen, by default gadgets would be filtered automatically according to the difficulty of constraints.
Use option --level 1 to show all gadgets found instead of only those with higher probabilities.
[pastacode lang=”markup” message=”” highlight=”” provider=”manual” manual=”%24%20one_gadget%20%2Flib%2Fx86_64-linux-gnu%2Flibc.so.6%20–level%201%0A%23%200x4f2c5%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x40%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20rcx%20%3D%3D%20NULL%0A%23%0A%23%200x4f322%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x40%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x40%5D%20%3D%3D%20NULL%0A%23%0A%23%200xe569f%20execve(%22%2Fbin%2Fsh%22%2C%20r14%2C%20r12)%0A%23%20constraints%3A%0A%23%20%20%20%5Br14%5D%20%3D%3D%20NULL%20%7C%7C%20r14%20%3D%3D%20NULL%0A%23%20%20%20%5Br12%5D%20%3D%3D%20NULL%20%7C%7C%20r12%20%3D%3D%20NULL%0A%23%0A%23%200xe5858%20execve(%22%2Fbin%2Fsh%22%2C%20%5Brbp-0x88%5D%2C%20%5Brbp-0x70%5D)%0A%23%20constraints%3A%0A%23%20%20%20%5B%5Brbp-0x88%5D%5D%20%3D%3D%20NULL%20%7C%7C%20%5Brbp-0x88%5D%20%3D%3D%20NULL%0A%23%20%20%20%5B%5Brbp-0x70%5D%5D%20%3D%3D%20NULL%20%7C%7C%20%5Brbp-0x70%5D%20%3D%3D%20NULL%0A%23%0A%23%200xe585f%20execve(%22%2Fbin%2Fsh%22%2C%20r10%2C%20%5Brbp-0x70%5D)%0A%23%20constraints%3A%0A%23%20%20%20%5Br10%5D%20%3D%3D%20NULL%20%7C%7C%20r10%20%3D%3D%20NULL%0A%23%20%20%20%5B%5Brbp-0x70%5D%5D%20%3D%3D%20NULL%20%7C%7C%20%5Brbp-0x70%5D%20%3D%3D%20NULL%0A%23%0A%23%200xe5863%20execve(%22%2Fbin%2Fsh%22%2C%20r10%2C%20rdx)%0A%23%20constraints%3A%0A%23%20%20%20%5Br10%5D%20%3D%3D%20NULL%20%7C%7C%20r10%20%3D%3D%20NULL%0A%23%20%20%20%5Brdx%5D%20%3D%3D%20NULL%20%7C%7C%20rdx%20%3D%3D%20NULL%0A%23%0A%23%200x10a38c%20execve(%22%2Fbin%2Fsh%22%2C%20rsp%2B0x70%2C%20environ)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsp%2B0x70%5D%20%3D%3D%20NULL%0A%23%0A%23%200x10a398%20execve(%22%2Fbin%2Fsh%22%2C%20rsi%2C%20%5Brax%5D)%0A%23%20constraints%3A%0A%23%20%20%20%5Brsi%5D%20%3D%3D%20NULL%20%7C%7C%20rsi%20%3D%3D%20NULL%0A%23%20%20%20%5B%5Brax%5D%5D%20%3D%3D%20NULL%20%7C%7C%20%5Brax%5D%20%3D%3D%20NULL”/]
More…
Copyright (c) 2017 david942j
Support Our Threat Intelligence
If you find our technology report and cybersecurity news helpful, consider supporting our work.