Farouk Faiz 2dcdaaa89f
Intial support to Python bindings for the libafl crate (#429)
* Add libafl py module

* Hardcoded baby_fuzzer

* Trait abstraction: MapObserver
Send type name as a param as it's needed for extracting the rust struct from the PyObject

* Fix merge

* Impl traits for python wrappers

* Add PythonExecutor
Not buildable version

* Executor trait bindings

* Monitor trait bindings

* EventManager trait bindings

* Fix warnings

* Add corpus trait bindings

* Use corpus trait bindings

* Rand trait bindings

* Remove python feature from default

* Add cfg attribute

* Fix fmt

* No std box

* Fix clippy

* turn OwnedInProcessExecutor in a simple type alias

* remove crate-type from libafl's Cargo.toml

* Add python baby_fuzzer

* Fix doc

* Maturin doc

* multiple map observer

* fmt

* build pylibafl with nightly

* macro for map element type

* Update py baby_fuzzer & fmt

* Mutator bindings

* fmt

* merge conflicts

* StdMutationalStage bindings
Not working: Cannot pass mutator to new method because not clonable

* Stage bindings

* StagesOwnedList bindings
Not working: Stage not clonable

* Unsafe transmute copy fix

* Use Stage bindings in baby_fuzzer

* fmt

* fmt

* Fix doc

* fix merge

* Remove x86_64 feature from pylibafl

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2022-02-14 11:41:39 +01:00

803 B

How to use python bindings

First time setup

# Create environment variable
python -m venv .env 
# Install maturin
pip install maturin

Build bindings

# Activate virtual environment
source .env/bin/activate
# Build python module
maturin develop

This is going to install pylibafl python module.

Use bindings

Example: Running baby_fuzzer in fuzzers/baby_fuzzer/baby_fuzzer.py

First, make sure the python virtual environment is activated. If not, run source .env/bin/activate . Running pip freeze at this point should display the following (versions may differ):

maturin==0.12.6
pylibafl==0.7.0
toml==0.10.2

Then simply run

python PATH_TO_BABY_FUZZER/baby_fuzzer.py

The crashes' directory will be created in the directory from which you ran the command.