AFLplusplus / Grammar-Mutator

A grammar-based custom mutator for AFL++
Apache License 2.0
229 stars 17 forks source link

Idea list #11

Open vanhauser-thc opened 4 years ago

vanhauser-thc commented 4 years ago

Let's collect some ideas on how to improve the grammar mutator. I am not an expert on this, so some ideas might be not possible, no sense or even makes things worse.

Also: document for a mutation which mutation strategies were used, and if it results in a new path, crash or hang, document these away somewhere (fopen("a")... fwrite() ... fclose() would be fine enough), and learn which types are more effective than others, and then try to improve them. maybe weighting, maybe changing how unsuccessful techniques work, etc. (and of course this feature with an #ifdef TESTING or something like that.

pinging @h1994st @andreafioraldi @eqv for more ideas

eqv commented 4 years ago

+1 for gathering statistics on the mutators! If I had the time to change a few things about nautlius2, it would be the follwing:

h1994st commented 4 years ago

+1 for gathering statistics on the mutators

I also listed some enhancements in TODO.md

@eqv A follow-up question to your second bullet point: do you mean to add support of scripting language while specifying the grammar? Like the python-based grammar in nautilus?

eqv commented 4 years ago

No, that stuff is ok and useful in some cases (e.g. to generate XML ), but I was thinking more like:

//assume we have a fuction call rule like this:
//$FunctionCall -> $FunctionName "(" $Args ")"
generate("FunctionCall", lambda ctx: ctx.function_call("foo", "3,"+ctx.generate("Args")  ) ) 

in which case we would have a special generator that generates foo(3, $(random args here) ) Similar generates could be used to generate sensible loops, etc.

h1994st commented 4 years ago

I see. Thanks for your explanation! This looks pretty useful.

andreafioraldi commented 4 years ago

and learn which types are more effective than others, and then try to improve them. maybe weighting, maybe changing how unsuccessful techniques wor

Basically grammar MOpt.

andreafioraldi commented 4 years ago

Use the dictionary with the grammar (-x + LTO AUTODICT feature)

We can try to take a testcase and replace terminal nodes with the dictionary tokens when they are compatible (regex needed).

vanhauser-thc commented 4 years ago

Use the dictionary with the grammar (-x + LTO AUTODICT feature)

We can try to take a testcase and replace terminal nodes with the dictionary tokens when they are compatible (regex needed).

yes. we need a way to hand over the dictionary to the mutator though. but that is a minor thing, @domenukk thought about passing afl structure in a stable way to mutators already.

h1994st commented 4 years ago

Use the dictionary with the grammar (-x + LTO AUTODICT feature)

We can try to take a testcase and replace terminal nodes with the dictionary tokens when they are compatible (regex needed).

yes. we need a way to hand over the dictionary to the mutator though. but that is a minor thing, @domenukk thought about passing afl structure in a stable way to mutators already.

Passing afl structure to the mutators will enhance the capability of the custom mutator a lot.

domenukk commented 4 years ago

Or, alternatively, we could expose functions to the custom mutators. This could be a bit more overhead during development, but would mean the mutators can easily be plugged into other fuzzers, like libafl? Else the state struct virtually becomes the api. Both ways are fine though.