paint-brush
Introduction to One Gadget: A Necessary Tool for Exploitation by@pwnbykenny
2,242 reads
2,242 reads

Introduction to One Gadget: A Necessary Tool for Exploitation

by pwnbykennyJanuary 10th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This post uses a concrete CTF problem to show you step-by-step how to find and execute a one gadget and eventually spawn a shell.

Coin Mentioned

Mention Thumbnail
featured image - Introduction to One Gadget: A Necessary Tool for Exploitation
pwnbykenny HackerNoon profile picture

1. Content

2. You definitely want to choose one gadget for exploitation

One gadget is a line of C code: execve(“/bin/sh”, 0, 0);. Apparently, this code spawns a shell. If you are able to find and run it in the memory, you get a shell! See? EASY and POWERFUL!Fortunately, it exists in libc. And libc is used in most programs! libc is a C library file. The one_gadget tool finds all the occurrences of the code in such files.

. It comes from this  > Pwn > [BJDCTF 2nd]one_gadget. Then we run it, it produces the following output:

If you disassemble the executable, you will find that the gift is actually the address of the libc function printf. It may change on each different execution. And you will also find that the executable requires you to input the address of a one gadget. The executable will execute the one gadget at the given address. Now let’s see how we are gonna execute a one gadget.

바카라사이트 바카라사이트 온라인바카라