diff options
author | van Hauser <vh@thc.org> | 2019-06-20 12:22:46 +0200 |
---|---|---|
committer | van Hauser <vh@thc.org> | 2019-06-20 12:22:46 +0200 |
commit | d10ebd1a6837f9fc42886fd5debe5311784be75a (patch) | |
tree | 38a04cb84b2815af7b2f588cb0b1ee04edf0a0b4 /python_mutators/common.py | |
parent | 4e3d921f1a7016755721cec0141ae0978621669f (diff) | |
download | afl++-d10ebd1a6837f9fc42886fd5debe5311784be75a.tar.gz |
python mutator examples added
Diffstat (limited to 'python_mutators/common.py')
-rw-r--r-- | python_mutators/common.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/python_mutators/common.py b/python_mutators/common.py new file mode 100644 index 00000000..28b8ee80 --- /dev/null +++ b/python_mutators/common.py @@ -0,0 +1,37 @@ +#!/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) |