Giter Site home page Giter Site logo

gym_fuzz1ng's Introduction

gym-fuzz1ng

OpenAI Gym[0] environment for binary fuzzing of a variety of libraries (libpng for now), executables, as well as simpler examples.

The environment's engine is based on american fuzzy lop[1] (afl) and capable of thousands of executions per seconds for moderaltely sized executables.

The action space is the following:

Box(low=0, high=DICT_SIZE-1, shape=(INPUT_SIZE,), dtype='int32')

DICT_SIZE and INPUT_SIZE depend on the environnment and the underlying program to fuzz:

  • DICT_SIZE is the size of the dictionnary used to fuzz the program. EOF is represented by DICT_SIZE-1 and accessible by the eof() method on the environment.
  • INPUT_SIZE is the input submitted for fuzzing it is fixed for each environment and represents a maximal size for inputs to fuzz; smaller inputs can be represented using EOF.

The environment simulates the following game:

  • each action submits a full input for fuzzing and returns the number of unique transitions executed as reward.
  • if no new coverage is discovered by an input, the game is ended.

(It is possible to simply call step independently of whether the game is done or not if you're just interested in easily executing binaries and retrieving the associated coverage from Python. See also step_raw[2]).

The observation space is the following:

Box(low=0, high=255, shape=(256, 256), dtype='int32')

To compute coverage, the underlying excecution engine assigns a random integer in [0, 255] to each simple block in the targeted binary. The coverage is then represented by a 256x256 matrix of int8 representing the number of time a transition was executed (note that this differs from how afl computes coverage). Since int8 are used for efficiency, the number of transitions can only be within [0, 255] and wraps otherwise. This coverage matrix for the last step execution is exactly what is returned as observation.

Installation

# Note that running setup.py bdist_wheel takes a bit a time as it builds our
# afl mod as well as the available targets.
pip install .

# You may need to run the following commands as well as superuser.
echo core >/proc/sys/kernel/core_pattern

# You can then test that everything works by running our dummy example.
python dummy_simple_bits.py

Available environments

FuzzLibPNGEnv

Fuzzing environment for libpng-1.6.34 (recent).

  • action_space: Box(low=0, high=283, shape=(1024,)) dictionary composed of magic tokens, all 255 bytes and EOF. Maximum input size is 1024.

FuzzSimpleBits-v0

Fuzzing environment for the simple_bits executable (see code).

  • action_space: Box(low=0, high=256, shape=(64,)) dictionary composed all 256 bytes and EOF. Maximum input size is 64.

FuzzSimpleLoop-v0

Fuzzing environment for the simple_loop executable (see code).

  • action_space: Box(low=0, high=256, shape=(8,)) dictionary composed all 256 bytes and EOF. Maximum input size is 8.

FuzzChecksum_{2,4,8}_{2,4,8}-v0

Fuzzing environment for the checksum_k_n executable (see code).

  • action_space: Box(low=0, high=256, shape=(8,)) dictionary composed all 256 bytes and EOF. Maximum input size is 72.

gym_fuzz1ng's People

Contributors

papipig avatar stan-stripe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.