diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-12-08 22:43:05 +0100 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-12-08 22:43:05 +0100 |
commit | ad29eef2712f8d0b69c1acd79c6a5dfb4e2cc7f8 (patch) | |
tree | f74be06e8d1834ada6abe3daf40744e134cb9e3c /utils/custom_mutators/common.py | |
parent | c70b7ffd80ee95cdf3bf1276bfbd4a590e74d3f1 (diff) | |
parent | 6fb74342b8a3e7aa62e9e0cfe79bd84d9076a275 (diff) | |
download | afl++-ad29eef2712f8d0b69c1acd79c6a5dfb4e2cc7f8.tar.gz |
Merge branch 'dev' of github.com:AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'utils/custom_mutators/common.py')
-rw-r--r-- | utils/custom_mutators/common.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/utils/custom_mutators/common.py b/utils/custom_mutators/common.py new file mode 100644 index 00000000..9a1ef0a3 --- /dev/null +++ b/utils/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) |