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/python_mutators/example.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/python_mutators/example.py')
-rw-r--r-- | examples/python_mutators/example.py | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/examples/python_mutators/example.py b/examples/python_mutators/example.py deleted file mode 100644 index d32a7eb2..00000000 --- a/examples/python_mutators/example.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -''' -Example Python Module for AFLFuzz - -@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 -''' - -import random - -def init(seed): - ''' - Called once when AFLFuzz starts up. Used to seed our RNG. - - @type seed: int - @param seed: A 32-bit random value - ''' - random.seed(seed) - return 0 - -def fuzz(buf, add_buf): - ''' - Called per fuzzing iteration. - - @type buf: bytearray - @param buf: The buffer that should be mutated. - - @type add_buf: bytearray - @param add_buf: A second buffer that can be used as mutation source. - - @rtype: bytearray - @return: A new bytearray containing the mutated data - ''' - ret = bytearray(buf) - # Do something interesting with ret - - return ret - -# Uncomment and implement the following methods if you want to use a custom -# trimming algorithm. See also the documentation for a better API description. - -# def init_trim(buf): -# ''' -# Called per trimming iteration. -# -# @type buf: bytearray -# @param buf: The buffer that should be trimmed. -# -# @rtype: int -# @return: The maximum number of trimming steps. -# ''' -# global ... -# -# # Initialize global variables -# -# # Figure out how many trimming steps are possible. -# # If this is not possible for your trimming, you can -# # return 1 instead and always return 0 in post_trim -# # until you are done (then you return 1). -# -# return steps -# -# def trim(): -# ''' -# Called per trimming iteration. -# -# @rtype: bytearray -# @return: A new bytearray containing the trimmed data. -# ''' -# global ... -# -# # Implement the actual trimming here -# -# return bytearray(...) -# -# def post_trim(success): -# ''' -# Called after each trimming operation. -# -# @type success: bool -# @param success: Indicates if the last trim operation was successful. -# -# @rtype: int -# @return: The next trim index (0 to max number of steps) where max -# number of steps indicates the trimming is done. -# ''' -# global ... -# -# if not success: -# # Restore last known successful input, determine next index -# else: -# # Just determine the next index, based on what was successfully -# # removed in the last step -# -# return next_index |