diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-03-04 18:38:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 18:38:03 +0100 |
commit | e43473faefffb93c7b3013dc25c07044a7656e7f (patch) | |
tree | d386d4f2da9242c97685257529a656373d1dd02c /examples/custom_mutators/common.py | |
parent | 05a3418f8668cadd17e32fd89bfcf136faa61f52 (diff) | |
parent | 38e7dd2b9efbd9c6cda47774630a82660d3156b3 (diff) | |
download | afl++-e43473faefffb93c7b3013dc25c07044a7656e7f.tar.gz |
Merge pull request #221 from h1994st/master
Uniform Python and custom mutator API
Diffstat (limited to 'examples/custom_mutators/common.py')
-rw-r--r-- | examples/custom_mutators/common.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/custom_mutators/common.py b/examples/custom_mutators/common.py new file mode 100644 index 00000000..9a1ef0a3 --- /dev/null +++ b/examples/custom_mutators/common.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# encoding: utf-8 +''' +Module containing functions shared between multiple AFL modules + +@author: Christian Holler (:decoder) + +@license: + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. + +@contact: choller@mozilla.com +''' + +from __future__ import print_function +import random +import os +import re + + +def randel(l): + if not l: + return None + return l[random.randint(0, len(l)-1)] + + +def randel_pop(l): + if not l: + return None + return l.pop(random.randint(0, len(l)-1)) + + +def write_exc_example(data, exc): + exc_name = re.sub(r'[^a-zA-Z0-9]', '_', repr(exc)) + + if not os.path.exists(exc_name): + with open(exc_name, 'w') as f: + f.write(data) |