aboutsummaryrefslogtreecommitdiff
path: root/docs/custom_mutators.md
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2020-12-08 22:43:05 +0100
committerAndrea Fioraldi <andreafioraldi@gmail.com>2020-12-08 22:43:05 +0100
commitad29eef2712f8d0b69c1acd79c6a5dfb4e2cc7f8 (patch)
treef74be06e8d1834ada6abe3daf40744e134cb9e3c /docs/custom_mutators.md
parentc70b7ffd80ee95cdf3bf1276bfbd4a590e74d3f1 (diff)
parent6fb74342b8a3e7aa62e9e0cfe79bd84d9076a275 (diff)
downloadafl++-ad29eef2712f8d0b69c1acd79c6a5dfb4e2cc7f8.tar.gz
Merge branch 'dev' of github.com:AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'docs/custom_mutators.md')
-rw-r--r--docs/custom_mutators.md41
1 files changed, 28 insertions, 13 deletions
diff --git a/docs/custom_mutators.md b/docs/custom_mutators.md
index 2516e511..a2c544e3 100644
--- a/docs/custom_mutators.md
+++ b/docs/custom_mutators.md
@@ -34,6 +34,7 @@ C/C++:
void *afl_custom_init(afl_state_t *afl, unsigned int seed);
unsigned int afl_custom_fuzz_count(void *data, const unsigned char *buf, size_t buf_size);
size_t afl_custom_fuzz(void *data, unsigned char *buf, size_t buf_size, unsigned char **out_buf, unsigned char *add_buf, size_t add_buf_size, size_t max_size);
+const char *afl_custom_describe(void *data, size_t max_description_len);
size_t afl_custom_post_process(void *data, unsigned char *buf, size_t buf_size, unsigned char **out_buf);
int afl_custom_init_trim(void *data, unsigned char *buf, size_t buf_size);
size_t afl_custom_trim(void *data, unsigned char **out_buf);
@@ -57,6 +58,9 @@ def fuzz_count(buf, add_buf, max_size):
def fuzz(buf, add_buf, max_size):
return mutated_out
+def describe(max_description_length):
+ return "description_of_current_mutation"
+
def post_process(buf):
return out_buf
@@ -102,7 +106,7 @@ def introspection():
of fuzzing attempts with this input based on a few factors.
If however the custom mutator wants to set this number instead on how often
it is called for a specific queue entry, use this function.
- This function in mostly useful if **not** `AFL_CUSTOM_MUTATOR_ONLY` is used.
+ This function is most useful if `AFL_CUSTOM_MUTATOR_ONLY` is **not** used.
- `fuzz` (optional):
@@ -110,12 +114,19 @@ def introspection():
additional test case.
Note that this function is optional - but it makes sense to use it.
You would only skip this if `post_process` is used to fix checksums etc.
- so you are using it e.g. as a post processing library.
+ so if you are using it e.g. as a post processing library.
+
+- `describe` (optional):
+
+ When this function is called, it shall describe the current testcase,
+ generated by the last mutation. This will be called, for example,
+ to name the written testcase file after a crash occurred.
+ Using it can help to reproduce crashing mutations.
- `havoc_mutation` and `havoc_mutation_probability` (optional):
`havoc_mutation` performs a single custom mutation on a given input. This
- mutation is stacked with the other mutations in havoc. The other method,
+ mutation is stacked with other mutations in havoc. The other method,
`havoc_mutation_probability`, returns the probability that `havoc_mutation`
is called in havoc. By default, it is 6%.
@@ -130,6 +141,9 @@ def introspection():
`post_process` function. This function is then transforming the data into the
format expected by the API before executing the target.
+ This can return any python object that implements the buffer protocol and
+ supports PyBUF_SIMPLE. These include bytes, bytearray, etc.
+
- `queue_new_entry` (optional):
This methods is called after adding a new test case to the queue.
@@ -168,7 +182,7 @@ trimmed input. Here's a quick API description:
on this input (e.g. if your input has n elements and you want to remove them
one by one, return n, if you do a binary search, return log(n), and so on).
- If your trimming algorithm doesn't allow you to determine the amount of
+ If your trimming algorithm doesn't allow to determine the amount of
(remaining) steps easily (esp. while running), then you can alternatively
return 1 here and always return 0 in `post_trim` until you are finished and
no steps remain. In that case, returning 1 in `post_trim` will end the
@@ -210,19 +224,20 @@ Optionally, the following environment variables are supported:
- `AFL_PYTHON_ONLY`
- Deprecated and removed, use `AFL_CUSTOM_MUTATOR_ONLY` instead
- trimming can cause the same test breakage like havoc and splice.
+ Deprecated and removed, use `AFL_CUSTOM_MUTATOR_ONLY` instead.
- `AFL_DEBUG`
- When combined with `AFL_NO_UI`, this causes the C trimming code to emit additional messages about the performance and actions of your custom trimmer. Use this to see if it works :)
+ When combined with `AFL_NO_UI`, this causes the C trimming code to emit
+ additional messages about the performance and actions of your custom
+ trimmer. Use this to see if it works :)
## 3) Usage
### Prerequisite
-For Python mutator, the python 3 or 2 development package is required. On
-Debian/Ubuntu/Kali this can be done:
+For Python mutators, the python 3 or 2 development package is required. On
+Debian/Ubuntu/Kali it can be installed like this:
```bash
sudo apt install python3-dev
@@ -240,13 +255,13 @@ In case your setup is different, set the necessary variables like this:
### Custom Mutator Preparation
-For C/C++ mutator, the source code must be compiled as a shared object:
+For C/C++ mutators, the source code must be compiled as a shared object:
```bash
gcc -shared -Wall -O3 example.c -o example.so
```
Note that if you specify multiple custom mutators, the corresponding functions will
be called in the order in which they are specified. e.g first `post_process` function of
-`example_first.so` will be called and then that of `example_second.so`
+`example_first.so` will be called and then that of `example_second.so`.
### Run
@@ -265,8 +280,8 @@ afl-fuzz /path/to/program
## 4) Example
-Please see [example.c](../examples/custom_mutators/example.c) and
-[example.py](../examples/custom_mutators/example.py)
+Please see [example.c](../utils/custom_mutators/example.c) and
+[example.py](../utils/custom_mutators/example.py)
## 5) Other Resources