diff options
author | hexcoder <hexcoder-@users.noreply.github.com> | 2021-05-31 19:18:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 19:18:24 +0200 |
commit | 97a1f89881878db9bd6b4cd666b3447a63818dcf (patch) | |
tree | 46e844356f7cf88c08f9f9907caa11656a24f416 /custom_mutators/examples/common.py | |
parent | b246de789105750558f3d6f884ba61e54cb98441 (diff) | |
parent | 1a2da67ed0505c9ac0aa1048ba3d607f3c1aa639 (diff) | |
download | afl++-97a1f89881878db9bd6b4cd666b3447a63818dcf.tar.gz |
Merge branch 'dev' into going_atomic
Diffstat (limited to 'custom_mutators/examples/common.py')
-rw-r--r-- | custom_mutators/examples/common.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/custom_mutators/examples/common.py b/custom_mutators/examples/common.py new file mode 100644 index 00000000..44a5056a --- /dev/null +++ b/custom_mutators/examples/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) |