# One gadget

A `one gadget` is an `execve("/bin/sh")` command that is directly present in gLIBC. Using this gadget it's possible to execute an arbitrary code with a single gadget.&#x20;

## Finding one gadget

It's possible to retrieve all one gadget of a libc using the tool [one\_gadget](https://github.com/david942j/one_gadget) :&#x20;

```bash
# one_gadget /tmp/libc.so.6 
0x13ea3b execl("/bin/sh", eax)
constraints:
  ebp is the GOT address of libc
  eax == NULL

0x13ea3c execl("/bin/sh", [esp])
constraints:
  ebp is the GOT address of libc
  [esp] == NULL
```

{% hint style="warning" %}
For most of `one gadget` some requirements have to be met in order to execute the gadget.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/one-gadget.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
