A simple differential fuzzing framework
Project description
DFF Python Implementation
A Python implementation of the DFF (Differential Fuzzing Framework) that uses Unix domain sockets and System V shared memory for high-performance IPC.
Installation
From PyPI (once published)
pip install dff-py
From Source
cd python
pip install -e .
Requirements
- Python 3.8 or higher
- Linux or macOS (Windows is not supported due to Unix domain sockets and System V shared memory)
- System configured for 100 MiB shared memory segments (see main README)
Usage
Client
from dff import Client
def process_func(method: str, inputs: list[bytes]) -> bytes:
"""Process function that handles fuzzing inputs."""
if method != "sha":
raise ValueError(f"Unknown method: {method}")
# Process the first input (matching Go/Java behavior)
import hashlib
return hashlib.sha256(inputs[0]).digest()
# Create and run client
client = Client("python", process_func)
client.connect()
client.run()
Server
from dff import Server
def provider() -> list[bytes]:
"""Generate fuzzing inputs."""
import random
size = random.randint(1024, 4096)
data = bytes(random.randint(0, 255) for _ in range(size))
return [data]
# Create and run server
server = Server("sha")
server.run(provider)
Examples
See the examples/python/ directory for complete working examples:
client.py- SHA256 hashing client implementationserver.py- Fuzzing server with random data provider
Running the Examples
Start the server:
./examples/python/server.py
In another terminal, start one or more clients:
./examples/python/client.py
./examples/python/client.py python2
./examples/golang/client/client golang
The server will detect any differences in the outputs from different clients.
Architecture
The framework uses:
- Unix domain sockets for control messages and coordination
- System V shared memory for efficient data transfer
- Multiple client support for differential testing
Protocol
- Client connects to server via Unix socket at
/tmp/dff - Client sends its name
- Server responds with:
- Input shared memory ID (4 bytes, big-endian)
- Output shared memory ID (4 bytes, big-endian)
- Method name (up to 64 bytes)
- For each fuzzing iteration:
- Server writes input data to shared memory
- Server sends message with input count and sizes
- Client processes data and writes result to output shared memory
- Client sends result size back to server
- Server compares results across clients
Performance
The Python implementation is functional but slower than compiled language implementations (Go, Rust) due to:
- Python's Global Interpreter Lock (GIL)
- Interpreter overhead
- Dynamic typing
For better performance, consider:
- Using PyPy instead of CPython
- Implementing compute-heavy processing in C extensions
- Running multiple client instances
Development
Running Tests
cd python
pip install -e .[dev]
pytest
Code Quality
# Format code
black dff/
# Lint
ruff dff/
# Type checking
mypy dff/
License
MIT License - see the LICENSE file in the root directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dff_py-0.1.0.tar.gz.
File metadata
- Download URL: dff_py-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
520fdc5c7ee40f5135722332d6129f4a48cf584e3dbebc8388896938bad0eff4
|
|
| MD5 |
a082cc2248f46a41af23a3a164a685e5
|
|
| BLAKE2b-256 |
9171236ce5522c74942bc84cf60a3a70433d699fbb60e39365793a5995f203a3
|
File details
Details for the file dff_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dff_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2781462fedab6559c148e34fe3c5076feea10fed56643f037111136ae541754
|
|
| MD5 |
ab0df65101958270c68444afb4bdeb7b
|
|
| BLAKE2b-256 |
52eceb15525e5a6c3cb947c1db56fa0002aed6846fe4b31b7fb91c8c00cc3214
|