-
Notifications
You must be signed in to change notification settings - Fork 53
/
linux_source_harness.cpp
40 lines (34 loc) · 1.28 KB
/
linux_source_harness.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* {NAME}_{function_name}_harness.cpp
*
* Automatically generated fuzzer harness for `{function_name}` in `{NAME}`. Make sure to add in implementation
* for any other necessary functionality to make this work.
*
* Make sure the target binary/shared object is in the same directory!
*
* To build for AFL, optimal for black-box and file-based fuzzing:
*
* $ clang {NAME}_{function_name}_harness.cpp -no-pie -o {NAME}_{function_name}_harness -ldl
*
* # check out more binary fuzzing strategies at https://aflplus.plus/docs/binaryonly_fuzzing/
* $ afl-fuzz -Q -m none -i <SEEDS> -o out/ -- ./{NAME}_{function_name}_harness
*
* To build for libFuzzer, optimal for generative buffer fuzzing:
*
* $ clang -DLIBFUZZER -g -fsanitize=fuzzer,address {NAME}_{function_name}_harness -no-pie -o {NAME}_{function_name}_harness -ldl
* $ ./{NAME}_{function_name}_harness
*
*/
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
/* DEPENDENCIES HERE */
#define FUZZER_BUF 1024 * 1024
static uint8_t fuzzBuffer[FUZZER_BUF];
int main(int argc, char** argv)
{
ssize_t read_bytes = read(stdin, fuzzBuffer, FUZZER_BUF);
// setup and initialization calls
// free memory and close file handles
}