Skip to content

Instantly share code, notes, and snippets.

@kbeckmann
Created September 17, 2018 21:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kbeckmann/c26606b23777fad6798e25d0c446a53c to your computer and use it in GitHub Desktop.
afl-fuzz harness suitable for afl-launch
/*
$ 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