googleprojectzero/Jackalope

Input files for grammar mode

heinreich1 opened this issue · 1 comments

Hi,

Is there any documentation regarding preparing input files when fuzzing in grammar mode?
I'm trying to play with the sample grammar but I get errors like those:
Incorrectly encoded grammar sample Location : GrammarFuzzer::OutputFilter()

Am I missing something? Thanks :)

Hi! At this time, there is no (easy) way to prepare input files manually. Instead, it is expected to start with an empty input corpus and let the grammar itself generate the initial set of samples. If you ran a session with a grammar before, and you want to run a session later using the same grammar, then you can re-use the samples generated earlier (located in out_directory/samples) as the input samples.

If you want the grammar to generate specific type of samples for the initial corpus (as opposed to just letting it run with the full grammar) you can

  • comment out rules you don't want
  • the fuzzer run and generate the samples according to the remaining rules
  • stop the fuzzer
  • uncomment the rest of the rules
  • resume the fuzzing session or start a new one using generated samples as input

Some context behind such design: parsing samples into their grammar representation is much harder than generating them and in fact there is no guaranteed unique way to parse a sample given a context-free grammar.