From 760416c1a0a4e3f3261dfee01c3fe11101c4b4ff Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 5 Sep 2019 10:10:25 +0200 Subject: small adjustments for custom mutator --- custom_mutators/simple_mutator.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'custom_mutators/simple_mutator.c') diff --git a/custom_mutators/simple_mutator.c b/custom_mutators/simple_mutator.c index 5c40d462..bf655679 100644 --- a/custom_mutators/simple_mutator.c +++ b/custom_mutators/simple_mutator.c @@ -3,9 +3,10 @@ Written by Khaled Yakdan - This a simple mutator that assumes that the generates messages starting with one - of the three strings GET, PUT, or DEL followed by a payload. The mutator randomly - selects a commend and mutates the payload of the seed provided as input. + This a simple mutator that assumes that the generates messages starting with + one of the three strings GET, PUT, or DEL followed by a payload. The mutator + randomly selects a commend and mutates the payload of the seed provided as + input. */ #include @@ -13,28 +14,36 @@ #include static const char *commands[] = { - "GET", - "PUT", - "DEL", + + "GET", + "PUT", + "DEL", + }; static size_t data_size = 100; -size_t afl_custom_mutator (uint8_t *data, size_t size, uint8_t* mutated_out, size_t max_size, unsigned int seed) { +size_t afl_custom_mutator(uint8_t *data, size_t size, uint8_t *mutated_out, + size_t max_size, unsigned int seed) { // Seed the PRNG srand(seed); - // Make sure that the packet size does not exceed the maximum size expected by the fuzzer + // Make sure that the packet size does not exceed the maximum size expected by + // the fuzzer size_t mutated_size = data_size <= max_size ? data_size : max_size; // Randomly select a command string to add as a header to the packet memcpy(mutated_out, commands[rand() % 3], 3); // Mutate the payload of the packet - for (int i = 3 ; i < mutated_size ; i++) { + for (int i = 3; i < mutated_size; i++) { + mutated_out[i] = (data[i] + rand() % 10) & 0xff; + } return mutated_size; + } + -- cgit 1.4.1