Created
September 17, 2018 21:09
-
-
Save kbeckmann/c26606b23777fad6798e25d0c446a53c to your computer and use it in GitHub Desktop.
afl-fuzz harness suitable for afl-launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$ AFL_USE_ASAN=1 afl-clang-fast fuzzer.c -o fuzzer | |
$ afl-launch -i in_dir -o out_dir -m none -n $(nproc --all) -- ./fuzzer @@ | |
$ afl-whatsup -s out_dir | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define BUF_SIZE 1024*1024 | |
static uint8_t buffer[BUF_SIZE]; | |
#ifndef __AFL_LOOP | |
#define __AFL_LOOP(x) 1 | |
#endif | |
int main(int argc, char *argv[]) | |
{ | |
size_t len; | |
while (__AFL_LOOP(10000)) { | |
FILE *fp = fopen(argv[1], "rb"); | |
len = fread(buffer, 1, BUF_SIZE, fp); | |
fuzz(buffer, len); | |
fclose(fp); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment