diff options
author | van Hauser <vh@thc.org> | 2020-11-18 21:25:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 21:25:35 +0100 |
commit | 4d9eb9bda147a26fc8cbe885b6193cf0c94c6314 (patch) | |
tree | c7a903633c7d1b0b5e373535188fd3a458a7f329 /custom_mutators/libfuzzer/FuzzerMutate.cpp | |
parent | 4c59c5234aec0469e4dd02561dbd84387bd53155 (diff) | |
parent | cd0a25be5e9b05a2ab6a11592cd95e7f653bf42d (diff) | |
download | afl++-4d9eb9bda147a26fc8cbe885b6193cf0c94c6314.tar.gz |
Merge pull request #607 from AFLplusplus/dev
push to stable
Diffstat (limited to 'custom_mutators/libfuzzer/FuzzerMutate.cpp')
-rw-r--r-- | custom_mutators/libfuzzer/FuzzerMutate.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/custom_mutators/libfuzzer/FuzzerMutate.cpp b/custom_mutators/libfuzzer/FuzzerMutate.cpp index eebae39b..edfe0455 100644 --- a/custom_mutators/libfuzzer/FuzzerMutate.cpp +++ b/custom_mutators/libfuzzer/FuzzerMutate.cpp @@ -14,6 +14,8 @@ #include "FuzzerMutate.h" #include "FuzzerOptions.h" #include "FuzzerTracePC.h" +#include <random> +#include <chrono> namespace fuzzer { @@ -100,15 +102,17 @@ size_t MutationDispatcher::Mutate_CustomCrossOver(uint8_t *Data, size_t Size, } + size_t MutationDispatcher::Mutate_ShuffleBytes(uint8_t *Data, size_t Size, size_t MaxSize) { - if (Size > MaxSize || Size == 0) return 0; size_t ShuffleAmount = Rand(std::min(Size, (size_t)8)) + 1; // [1,8] and <= Size. size_t ShuffleStart = Rand(Size - ShuffleAmount); assert(ShuffleStart + ShuffleAmount <= Size); - std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, Rand); + unsigned num = std::chrono::system_clock::now().time_since_epoch().count(); + std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, std::default_random_engine(num)); + //std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, Rand); return Size; } @@ -609,8 +613,24 @@ void MutationDispatcher::PrintRecommendedDictionary() { } +const char *MutationDispatcher::WriteMutationSequence() { + + static std::string buf; + buf = ""; + + for (size_t i = 0; i < CurrentMutatorSequence.size(); i++) { + + buf = buf + " " + CurrentMutatorSequence[i].Name; + + } + + return buf.c_str(); + +} + void MutationDispatcher::PrintMutationSequence(bool Verbose) { + return; Printf("MS: %zd ", CurrentMutatorSequence.size()); size_t EntriesToPrint = Verbose ? CurrentMutatorSequence.size() |