|
| 1 | +# Concepts |
| 2 | + |
| 3 | +Before we dive into a specific target, we need to introduce the concept of a _kAFL Agent_ that will used at the next step of the tutorial |
| 4 | + |
| 5 | +We assume you are already familiar with fuzzing vocabulary ([Google's fuzzing glossary](https://github.com/google/fuzzing/blob/master/docs/glossary.md) can be helpful here). |
| 6 | + |
| 7 | +## kAFL Agent |
| 8 | + |
| 9 | +The term _kAFL Agent_ simply refers to the implementation of a fuzzing harness in the guest. |
| 10 | + |
| 11 | +The _Agent_ is responsible for both instrumenting and overseeing a specific portion of the SUT (_System Under Test_) through a set of [hypercalls](../reference/hypercall_api.md). |
| 12 | + |
| 13 | +Considering that these hypercalls constitues a communication channel with the external virtual machine environment, the term _agent_ has been employed, akin to a guest agent. |
| 14 | + |
| 15 | +```{mermaid} |
| 16 | +graph LR |
| 17 | + fuzzer["kAFL Fuzzer"] <--> QEMU["QEMU/KVM"] |
| 18 | + subgraph Virtual Machine |
| 19 | + Agent["kAFL Agent"] <-- Instruments --> SUT["Software Under Test"] |
| 20 | + end |
| 21 | + QEMU <-- Hypercalls --> Agent |
| 22 | +``` |
| 23 | + |
| 24 | +```{code-block} C |
| 25 | +--- |
| 26 | +caption: Example of a simplified kAFL Agent fuzzing a target function called `target()` |
| 27 | +--- |
| 28 | +// 🤝 kAFL handshake |
| 29 | +kAFL_hypercall(HYPERCALL_KAFL_ACQUIRE, 0); |
| 30 | +kAFL_hypercall(HYPERCALL_KAFL_RELEASE, 0); |
| 31 | +// allocate kAFL payload buffer |
| 32 | +kAFL_payload *payload_buffer = malloc(PAYLOAD_SIZE); |
| 33 | +// kAFL configuration, filters, etc... |
| 34 | +// 🟢 Enable feedback collection |
| 35 | +kAFL_hypercall(KAFL_HYPERCALL_ACQUIRE); |
| 36 | +// ⚡call target func ... |
| 37 | +target(payload_buffer->data, payload_buffer->size); |
| 38 | +// ⚪ Disable feedback collection |
| 39 | +kAFL_hypercall(KAFL_HYPERCALL_RELEASE); |
| 40 | +``` |
| 41 | + |
| 42 | +## Pick a Target ! |
| 43 | + |
| 44 | +Now you are ready to configure one of our pre-baked kAFL targets, and start the fuzzer ! |
| 45 | + |
| 46 | +- ➡️ Continue by [fuzzing the Linux Kernel](./fuzzing_linux_kernel.md) |
| 47 | +- ➡️ Continue by [fuzzing Windows programs](./windows/index.md) |
0 commit comments