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
pip install dff-py
Requirements
- Python 3.9 or higher
- Linux or macOS
Linux
sudo sysctl -w kernel.shmmax=104857600
sudo sysctl -w kernel.shmall=256000
macOS
sudo sysctl -w kern.sysv.shmmax=104857600
sudo sysctl -w kern.sysv.shmall=256000
Usage
Example Client
import sys
import hashlib
from pathlib import Path
from dff import Client
def process_sha(method: str, inputs: list[bytes]) -> bytes:
"""Process function for SHA256 hashing.
Args:
method: The fuzzing method (should be "sha")
inputs: List of byte arrays to hash
Returns:
SHA256 hash of the first input
Raises:
ValueError: If method is not "sha" or no inputs provided
"""
if method != "sha":
raise ValueError(f"Unknown method: {method}")
if not inputs:
raise ValueError("No inputs provided")
return hashlib.sha256(inputs[0]).digest()
def main() -> None:
"""Main entry point."""
client = Client("python", process_sha)
try:
client.connect()
client.run()
except KeyboardInterrupt:
print("\nShutdown requested")
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
finally:
client.close()
if __name__ == "__main__":
main()
Example Server
import sys
import random
from pathlib import Path
from dff import Server
def data_provider() -> list[bytes]:
"""Generate random data for fuzzing.
Returns:
List containing a single random byte array
"""
MIN_SIZE = 1 * 1024 * 1024 # 1 MB
MAX_SIZE = 4 * 1024 * 1024 # 4 MB
# Use a deterministic seed that increments
if not hasattr(data_provider, "seed_counter"):
data_provider.seed_counter = 1
seed = data_provider.seed_counter
data_provider.seed_counter += 1
# Generate random data with deterministic seed
random.seed(seed)
size = random.randint(MIN_SIZE, MAX_SIZE)
data = random.randbytes(size)
return [data]
def main() -> None:
"""Main entry point."""
server = Server("sha")
try:
server.run(data_provider)
except KeyboardInterrupt:
print("\nShutdown requested")
except Exception as e:
print(f"Server error: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()
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
dff_py-0.1.1.tar.gz
(8.9 kB
view details)
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.1.tar.gz.
File metadata
- Download URL: dff_py-0.1.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbf57b8eaa07dc55b041c8c35d4730ab7b5f81ea0889cd9c8ef2752745e3713a
|
|
| MD5 |
b2bf8fe50c2e5580aae6edf73d5ebc58
|
|
| BLAKE2b-256 |
99594532acb444ee49bef2288688b1174ed68433c361ecaae512bd025e190848
|
File details
Details for the file dff_py-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dff_py-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
7bd2f9822213e02b4f253213c8213c54475c29933e76c7d015f55b0d97e7da1d
|
|
| MD5 |
98ca1a8216bfe90521930e39b5401f7a
|
|
| BLAKE2b-256 |
00410a8ef86755adf6a6e080f208c9e3f12b86e829b6fbab579106fbc0a1c4db
|