The Python Fuzzer that the world deserves 🐍

Overview


pip3 install frelatage
Current release : 0.0.2


The Python Fuzzer that the world deserves

Installation    |    How it works    |    Features    |    Use Frelatage    |    Configuration

Frelatage is a coverage-based Python fuzzing library which can be used to fuzz python code. The development of Frelatage was inspired by various other fuzzers, including AFL/AFL++, Atheris and PyFuzzer.The main purpose of the project is to take advantage of the best features of these fuzzers and gather them together into a new tool in order to efficiently fuzz python applications.

DISCLAIMER : This project is at the alpha stage and can still cause many unexpected behaviors. Frelatage should not be used in a production environment at this time.

Requirements

Python 3

Installation

Install with pip (recommended)

pip3 install frelatage

Or build from source

Recommended for developers. It automatically clones the main branch from the frelatage repo, and installs from source.

# Automatically clone the Frelatage repository and install Frelatage from source
bash <(wget -q https://raw.githubusercontent.com/Rog3rSm1th/Frelatage/main/scripts/autoinstall.sh -O -)

How it works

The idea behind the design of Frelatage is the usage of a genetic algorithm to generate mutations that will cover as much code as possible. The functioning of a fuzzing cycle can be roughly summarized with this diagram :

graph TB

    m1(Mutation 1) --&gt; |input| function(Fuzzed function)
    m2(Mutation 2) --&gt; |input| function(Fuzzed function)
    mplus(Mutation ...) --&gt; |input| function(Fuzzed function)
    mn(Mutation n) --&gt; |input| function(Fuzzed function)
    
    function --&gt; generate_reports(Generate reports)
    generate_reports --&gt; rank_reports(Rank reports)  
    rank_reports --&gt; select(Select n best reports)
    
    select --&gt; |mutate| nm1(Mutation 1) &amp; nm2(Mutation 2) &amp; nmplus(Mutation ...) &amp; nmn(Mutation n)
    
    subgraph Cycle mutations
    direction LR
    m1
    m2
    mplus
    mn
    end
    
    subgraph Next cycle mutations
    direction LR
    nm1
    nm2
    nmplus
    nmn
    end
     
    style function fill:#5388e8,stroke:white,stroke-width:4px

Features

Fuzzing different argument types:

  • String
  • Int
  • Float
  • List
  • Tuple
  • Dictionary

File fuzzing

Frelatage allows to fuzz a function by passing a file as input.

Use Frelatage

Fuzz a classical parameter

import frelatage
import my_vulnerable_library

def MyFunctionFuzz(data):
  my_vulnerable_library.parse(data)

input = frelatage.Input(value="initial_value")
f = frelatage.Fuzzer(MyFunctionFuzz, [input])
f.fuzz()

Fuzz a file parameter

Frelatage gives you the possibility to fuzz file type input parameters. To initialize the value of these files, you must create as many files in the input folder as there are arguments of type file. These files must be named as follows: the first file argument must be named 0, the second 1, and so on.

In case we have only one input file, we can initialize it like this:

echo "initial value" > ./in/0

And then run the fuzzer:

import frelatage
import my_vulnerable_library

def MyFunctionFuzz(data):
  my_vulnerable_library.load_file(data)

input = frelatage.Input(file=True)
f = frelatage.Fuzzer(MyFunctionFuzz, [input])
f.fuzz()

Fuzz with a dictionary

You can copy one or more dictionaries located here in the directory dedicated to dictionaries (./dict by default).

Reports

Each crash is saved in the output folder (./out by default), in a folder named : id<crash ID>,err<error type>.

The report directory is in the following form:

    β”œβ”€β”€ out
    β”‚   β”œβ”€β”€ id<crash ID>,err<error type>
    β”‚       β”œβ”€β”€ input
    β”‚       β”œβ”€β”€ 0
    β”‚       └── ...
    β”‚   β”œβ”€β”€ ...

Read a crash report

Inputs passed to a function are serialized using the pickle module before being saved in the <report_folder>/input file. It is therefore necessary to deserialize it to be able to read the contents of the file. This action can be performed with this script.

./read_report.py input

Configuration

There are two ways to set up Frelatage:

Using the environment variables

ENV Variable Description Possible Values Default Value
FRELATAGE_DICTIONARY_ENABLE Enable the use of mutations based on dictionary elements 1 to enable, 0 otherwise 1
FRELATAGE_TIMEOUT_DELAY Delay in seconds after which a function will return a TimeoutError 1 - 20 2
FRELATAGE_INPUT_FILE_TMP_DIR Temporary folder where input files are stored absolute path to a folder, e.g. /tmp/custom_dir /tmp/frelatage
FRELATAGE_INPUT_MAX_LEN Maximum size of an input variable in bytes 4 - 1000000 4094
FRELATAGE_MAX_THREADS Maximum number of simultaneous threads 8 - 50 8
FRELATAGE_DICTIONARY_DIR Default directory for dictionaries. It needs to be a relative path (to the path of the fuzzing file) relative path to a folder, e.g. ./dict ./dict

A configuration example :

export FRELATAGE_DICTIONARY_ENABLE=1 &&
export FRELATAGE_TIMEOUT_DELAY=2 &&
export FRELATAGE_INPUT_FILE_TMP_DIR="/tmp/frelatage" &&
export FRELATAGE_INPUT_MAX_LEN=4096 &&
export FRELATAGE_MAX_THREADS=8 &&
export FRELATAGE_DICTIONARY_DIR="./dict" &&
python3 fuzzer.py

Passing arguments to the fuzzer

import frelatage 

def myfunction(input1_string, input2_int):
    pass

input1 = frelatage.Input(value="initial_value")
input2 = frelatage.Input(value=2)

f = frelatage.Fuzzer(
    # The method you want to fuzz
    method=myfunction,
    # The initial arguments
    arguments=[input1, input2],
    # Number of threads
    threads_count=8,
    # Exceptions that will be taken into account
    exceptions_whitelist=(OSError),
    # Exceptions that will not be taken into account
    exceptions_blacklist=(),
    # Directory where the error reports will be stored
    output_directory="./out",
    # Directory containing the initial input files
    input_directory="./in",
    # Enable or disable silent mode
    silent=False
)
f.fuzz()

Risks

Please keep in mind that, similarly to many other computationally-intensive tasks, fuzzing may put strain on your hardware and on the OS. In particular:

  • Your CPU will run hot and will need adequate cooling. In most cases, if cooling is insufficient or stops working properly, CPU speeds will be automatically throttled. That said, especially when fuzzing on less suitable hardware (laptops, smartphones, etc), it's not entirely impossible for something to blow up.

  • Targeted programs may end up erratically grabbing gigabytes of memory or filling up disk space with junk files. Frelatage tries to enforce basic memory limits, but can't prevent each and every possible mishap. The bottom line is that you shouldn't be fuzzing on systems where the prospect of data loss is not an acceptable risk.

  • Fuzzing involves billions of reads and writes to the filesystem. On modern systems, this will be usually heavily cached, resulting in fairly modest "physical" I/O - but there are many factors that may alter this equation. It is your responsibility to monitor for potential trouble; with very heavy I/O, the lifespan of many HDDs and SSDs may be reduced.

    A good way to monitor disk I/O on Linux is the 'iostat' command:

    $ iostat -d 3 -x -k [...optional disk ID...]

Contact

for any remark, suggestion, bug report, or if you found a bug using Frelatage, you can contact me at [email protected] or on twitter @Rog3rSm1th

Comments
  • Use all of corpus in frelatage input

    Use all of corpus in frelatage input

    If we have thousands or more corpus, can we use all of corpus in the input directory instead of define filenames manually in frelatage.Input(file=True, value="filename") ?

    enhancement 
    opened by CityOfLight77 1
  • Numpy used but not included in poetry.lock file

    Numpy used but not included in poetry.lock file

    Just started this up and getting the following error:

    Traceback (most recent call last):
      File "/Users/test2.py", line 11, in <module>
        import frelatage
      File "/Users/username/.pyenv/versions/3.10.1/lib/python3.10/site-packages/frelatage/__init__.py", line 6, in <module>
        from frelatage.queue.queue import Queue
      File "/Users/username/.pyenv/versions/3.10.1/lib/python3.10/site-packages/frelatage/queue/queue.py", line 2, in <module>
        import numpy as np
    ModuleNotFoundError: No module named 'numpy'
    

    and I looked in the poetry.lock file and did not see numpy listed.

    opened by MSAdministrator 0
  • Error when loading input files from a subdirectory

    Error when loading input files from a subdirectory

    When loading an input file from a subdirectory of the input directory, we have a bug.

    For example:

    my_file = frelatage.Input("./subdir/myfile")
    

    Tries reates a temporary file in /tmp/frelatage/0/0/subdir/myfile when it should copy the file to /tmp/frelatage/0/0/myfile.

    bug 
    opened by Rog3rSm1th 0
  • Dev/rog3rsm1th

    Dev/rog3rsm1th

    • Implement the load_corpus function to load several files at once into a corpus, fixes #13
    • Make the input folder parameter an environment variable (FRELATAGE_INPUT_DIR).
    • Load the version number from the package informations.
    opened by Rog3rSm1th 0
  • Bug when passing the same file to two arguments

    Bug when passing the same file to two arguments

    When passing the same file to two arguments, there is a collision in the reports folder.

    For example:

    import frelatage 
    from PIL import Image
    
    def fuzz_gif(input_file1, input_file2):
        Image.open(input_file)
        Image.open(input_file)
    
    gif_file = frelatage.Input(file=True, value="image.gif")
    
    f = frelatage.Fuzzer(fuzz_gif, [[gif_file], [gif_file]])
    f.fuzz()
    

    In the reports, both image.gif will be written in the same file, making it impossible to reproduce the bug. The structure of the report folders should therefore be modified in this way:

    β”œβ”€β”€ out
        β”‚   β”œβ”€β”€ id:<crash ID>,err:<error type>,err_pos:<error>,err_file:<error file>,err_pos:<err_pos>
        β”‚       β”œβ”€β”€ input
        β”‚       β”œβ”€β”€ 0
        β”‚           β”œβ”€β”€ image.gif
        β”‚       β”œβ”€β”€ 1
        β”‚           β”œβ”€β”€ image.gif
    
    bug 
    opened by Rog3rSm1th 0
  • Use more specifics report's names to simplify the bug reproduction

    Use more specifics report's names to simplify the bug reproduction

    Currently the reports name only contain the type of the triggered error. It would be interesting to add the instruction where the bug was triggered, as well as the file where the bug crash occured in order to facilitate its reproduction.

    enhancement 
    opened by Rog3rSm1th 0
  • More minimalistic interface

    More minimalistic interface

    Currently the interface is quite large and does not fit well on small terminals. It needs to be reworked in order to obtain a more minimalist and slim interface. It would be possible to take inspiration from the interfaces of other fuzzers such as AFL/AFL++ or WinAFL.

    enhancement 
    opened by Rog3rSm1th 0
  • Allow the use of several values in the corpus

    Allow the use of several values in the corpus

    For now it is only possible to use one value for the corpus. It should be possible to pass several values in the corpus.

    For example for the classical arguments:

    inp = frelatage.Input(value=["value1", "value2", "value3"])
    

    For the argument of type "file":

      β”œβ”€β”€ in
      β”‚    β”œβ”€β”€ 0
      β”‚        β”œβ”€β”€ file1
      β”‚        β”œβ”€β”€ file2
      β”‚        └── ...
      β”‚    β”œβ”€β”€ 1
      β”‚    β”œβ”€β”€ ...
    
    enhancement 
    opened by Rog3rSm1th 0
  • Dev/rog3rsm1th

    Dev/rog3rsm1th

    New features:

    • Adds the possibility to enable or disable dictionnary mutations.
    • Implements silent mode.
    • Checks ENV variables values before launching the fuzzer.
    • Fixes #2
    opened by Rog3rSm1th 0
  • Improve interface

    Improve interface

    Different aspects of the interface need to be improved:

    • The name of the fuzzed function must be displayed.
    • the use of curses "breaks" the terminal display when exiting the program, this must be corrected.
    • A message should be displayed at the end of the fuzzing, with the reason why the program stopped (user-induced or not) as well as general statistics about the fuzzing.
    enhancement 
    opened by Rog3rSm1th 0
  • Use dictionary in Fuzzer

    Use dictionary in Fuzzer

    Although we can use dictionary, I didn't see option in frelatage.Fuzzer() to load specific dictionary for a fuzzing campaign.

    What security and non-security issues we can found during fuzzing with Frelatage?

    And if I have N cores, how many threads should I use?

    opened by CityOfLight77 0
  • Fix curses error when the window is too small

    Fix curses error when the window is too small

    when you run Frelatage with a terminal that is too small, or when you resize the terminal during execution, you get an error related to curses: _curses.error: addwstr() returned ERR

    bug 
    opened by Rog3rSm1th 0
  • Implement multithreading

    Implement multithreading

    Currently threads are launched one after the other, it is therefore necessary to implement multithreading to increase the performance and speed of fuzzing.

    enhancement 
    opened by Rog3rSm1th 0
Releases(v0.1.0)
  • v0.1.0(May 31, 2022)

    What's changed?

    • πŸŽ‰ Frelatage goes from Alpha to Beta with version 0.1.0 πŸŽ‰
    • The interface has been reworked
    • Many bugs have been fixed
    • The source code is now formatted to meet PEP8 standards and typing and verified using MyPy
    • Infinite fuzzing is now possible, #23
    Source code(tar.gz)
    Source code(zip)
  • v0.0.6(Mar 22, 2022)

    What's changed?

    • Ignores warnings during fuzzing process
    • Improves integer fuzzing by adding new magic values.
    • Adds timeout delay in the interface.
    • Implements load_corpus to load several files at once into a corpus. #13
    • Allows to load input files from subdirectories. #16
    • Make the input folder parameter an environment variable.
    • Minor interface fixes and version standardization (__version__)
    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Mar 14, 2022)

  • v0.0.3(Mar 10, 2022)

    What's changed?

    • The interface has been reworked to fit more easily into smaller terminals.
    • Possibility to use a corpus to fuzz more efficiently.
    • Implementation of a queue system to test the elements of the corpus one after the other.
    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Mar 8, 2022)

    What's changed?

    • The interface now displays the name of the fuzzed function, and the cursor is now hidden.
    • A detailed report is displayed at the end of the fuzzing.
    • The value of the environment variables is checked before the fuzzer is launched.
    • Implementation of a silent mode.
    Source code(tar.gz)
    Source code(zip)
Owner
Rog3r
Fuzzing / OSINT / Low level stuffs
Rog3r
Wannier & vASP Postprocessing module

WASPP module Wannier90 & vASP Postprocessing module with functionalities I needed during my PhD. Being updated Version: 0.5 Main functions: Wannier90

IriΓ‘n SΓ‘nchez RamΓ­rez 4 Dec 27, 2022
Software for visualization of RTStruct structures on CT images

This script is responsible for the operation of the program, it is responsible for both creating the GUI and the process of processing images from dicom files. The program is based on the use of the

Adam Piszczek 0 Jun 29, 2022
A companion web application to connect stash to deovr

stash-vr-companion This is a companion web application to connect stash to deovr. Stash is a self hosted web application to manage your porn collectio

19 Sep 29, 2022
Block fingerprinting for the beacon chain, for client identification & client diversity metrics

blockprint This is a repository for discussion and development of tools for Ethereum block fingerprinting. The primary aim is to measure beacon chain

Sigma Prime 49 Dec 08, 2022
Nuclei - Burp Extension allows to run nuclei scanner directly from burp and transforms json results into the issues

Nuclei - Burp Extension Simple extension that allows to run nuclei scanner directly from burp and transforms json results into the issues. Installatio

106 Dec 22, 2022
Check a discord message and give it a percentage of scamminess

scamChecker Check a discord message and give it a percentage of scamminess Run the bot, and run the command !scamCheck and it will return a percentage

3 Sep 22, 2022
Alfred 4 Workflow to search through your maintained/watched/starred GitHub repositories.

Alfred 4 Workflow to search through your maintained/watched/starred GitHub repositories. Setup This workflow requires a number of Python modules. Thes

Bᴇʀɴᴅ Sα΄„Κœα΄Κ€Ι’α΄‡Κ€s 1 Oct 14, 2022
A Gura parser implementation for Python

Gura parser This repository contains the implementation of a Gura format parser in Python. Installation pip install gura-parser Usage import gura gur

JWare Solutions 19 Jan 25, 2022
A comprensive software collection for nmea manipulation

nmeatoolkit A comprensive software collection for nmea manipulation; it includes a library and a collections of command line tools. Library pipes: con

Davide Gessa 1 Sep 14, 2022
uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.

uMap project About uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site. Because we think that the more OSM wil

771 Dec 29, 2022
Developed a website to analyze and generate report of students based on the curriculum that represents student’s academic performance.

Developed a website to analyze and generate report of students based on the curriculum that represents student’s academic performance. We have developed the system such that, it will automatically pa

VIJETA CHAVHAN 3 Nov 08, 2022
A brainfuck-based game oriented language written in python.

GF.py STILL WIP Gamefuck.py is a programming language based off brainfuck. It is oriented towards game development, and as such has many commands spec

Xenon 1 Feb 23, 2022
πŸ™ŒKart of 210+ projects based on machine learning, deep learning, computer vision, natural language processing and all. Show your support by ✨ this repository.

ML-ProjectKart πŸ“Œ Repository This kart showcases the finest collection of all projects based on machine learning, deep learning, computer vision, natu

Prathima Kadari 203 Dec 28, 2022
A dog facts python module

A dog facts python module

Fayas Noushad 3 Nov 28, 2021
Find functions without canary check (or similar)

Ghidra Check Protector Which non-trivial functions don't reference the stack canary checker (or other, user-defined function)? Place your cursor to th

buherator 3 Jan 17, 2022
Replay Felica Exchange For Python

FelicaReplay Replay Felica Exchange Description Standalone Replay Module Usage Save FelicaRelay (=2.0) output to file, then python replay.py [FILE].

3 Jul 14, 2022
CNKD - Minimalistic Windows ransomware written in Python

CNKD Minimalistic Windows ransomware written in Python (Still a work in progress

Alex 2 May 27, 2022
Canim1 - Simple python tool to search for packages without m1 wheels in poetry lockfiles

canim1 Usage Clone the repo. Run poetry install. Then you can use the tool: ❯ po

Korijn van Golen 1 Jan 25, 2022
Today I Commit (1일 1컀밋) μ±Œλ¦°μ§€ μ•Œλ¦Ό 봇

Today I Commit Challenge 1일1컀밋 μ±Œλ¦°μ§€λ₯Ό μœ„ν•œ μ•Œλ¦Ό 봇 config.py github_token = "github private access key" slack_token = "slack authorization token" channel = "

sunho 4 Nov 08, 2021
ABT aka Animated Background Tool is a windows only python program that makes it that you can have animated background.

ABT ABT aka Animated Background Tool is a windows only python program that makes it that you can have animated background. 𝓑𝓔𝓐𝓓 π“œπ“”, An Important

Yeeterboi4 2 Jul 16, 2022