overwrite token mutator

This commit is contained in:
vanhauser-thc 2021-02-04 21:47:00 +01:00
parent 2440aaedfc
commit 1bce5ad8cf
2 changed files with 26 additions and 4 deletions

View File

@ -510,6 +510,28 @@ where
mem_move(input.bytes_mut(), token, 0, off, len);
Ok(MutationResult::Mutated)
}
// Overwrite with a dictionary token
pub fn mutation_tokenreplace<M, C, I, R>(
mutator: &mut M,
rand: &mut R,
_: &C,
input: &mut I,
) -> Result<MutationResult, AflError>
where
M: HasMaxSize,
I: Input + HasBytesVec,
R: Rand,
{
if mutator.tokens.size() > len || !len { return Ok(MutationResult::Skipped); }
let token = &mutator.tokens[rand.below(token.size())];
let token_len = token.size();
let size = input.bytes().len();
let off rand.below((mutator.max_size() - token_len) as u64)) as usize;
mem_move(input.bytes_mut(), token, 0, off, len);
Ok(MutationResult::Mutated)
}
*/
pub fn mutation_bytesinsert<M, C, I, R>(

View File

@ -288,10 +288,10 @@ where
scheduled.add_mutation(mutation_bytescopy);
scheduled.add_mutation(mutation_bytesswap);
// TODO dictionary and custom dictionary (redqueen etc.)
/*scheduled.add_mutation(mutation_bitflip);
scheduled.add_mutation(mutation_bitflip);
scheduled.add_mutation(mutation_bitflip);*/
/*scheduled.add_mutation(mutation_tokeninsert);
scheduled.add_mutation(mutation_tokenreplace);*/
// TODO: custom dictionary (redqueen etc.)
scheduled.add_mutation(mutation_splice);