> For the complete documentation index, see [llms.txt](https://ir0nstone.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ir0nstone.gitbook.io/notes/binexp/dynamic-binary-instrumentation.md).

# Dynamic Binary Instrumentation

## Overview

**Dynamic Binary Instrumentation** (DBI) is a technique for observing, analyzing, or modifying a program while it is running, without needing its source code.

This may not sound that useful, but believe me when I say it's incredibly helpful! The classic example of this is **fuzzing**. In large binaries with ridiculously complex code bases, sometimes fuzzing is the best approach, but fuzzers like AFL++ generally like the binary to be compiled in a special fuzzer-approved way. This is because, for fuzzers to be efficient, we want to keep track of which code paths the fuzzer went down and causes a crash at. In order for this to happen, we compile the binary with a bunch of fuzzer "flags" that trigger a "message" when code execution reaches them, so fuzzers can keep track of exactly what bugs they've found - but this is only possible if we have the source code!

This is where DBI comes in. Despite not having the source code, we can **inject** extra instructions to log memory accesses, track control flow, count instructions and more. This lets us keep track of **what** actually runs, but of course at the cost of performance.

Common frameworks include the incredibly powerful [Frida](https://frida.re) and the classic [Valgrind](https://valgrind.org/info/), which is many projects' go-to tool for identifying memory leaks and corruption.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://ir0nstone.gitbook.io/notes/binexp/dynamic-binary-instrumentation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
