This repository contains a collection of simple depth-limited grammar fuzzers implemented in C. The repository contains two classes of fuzzers:
- Generic fuzzers: fuzzers directly implemented in C, that take a defined grammar structure as input
- Compiled fuzzers: python scripts that generate grammar-specific C fuzzer code, given a JSON grammar
- Control over the maximum expansion depth.
- Seeded output parity, ie. produce the same output for a given seed.
A makefile is provided in each class's directory, which builds to a build/ directory in the class subdirectory. General compilation is:
make [iterative|recursive] grammar=[name]Intermediate source files (prefixed with _) are removed after each build, comment out rm build/_* in the makefile to preserve. See makefile contents for more detail.
Grammars are sourced from the grammars/ directory in the base directory. Grammars are expected to be provided in the .json format - see provided examples for details.
See https://github.com/antlr/grammars-v4/ for conversion tools from ANTLR grammars to the .json format used here.
All generated executables take a required seed argument and an optional max depth (default=10) argument:
gi_fuzz-tinyc 7 128The compute_cost() method (and all its dependencies) in gramutils.py are the work of https://github.com/vrthra/.