Skip to main content

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


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.8.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dff_py-0.1.8-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file dff_py-0.1.8.tar.gz.

File metadata

  • Download URL: dff_py-0.1.8.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for dff_py-0.1.8.tar.gz
Algorithm Hash digest
SHA256 9d71288ec2bf67bc3e472f67e691efe9f4843da4b5b9e8cd72e63a201122e35d
MD5 027b5c22cf01f1a94f9265342171305b
BLAKE2b-256 36b9d5e74600a7b77bb934f2250ae6b2d3c7f3ba1fed3069227e78c8de672c2d

See more details on using hashes here.

File details

Details for the file dff_py-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: dff_py-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for dff_py-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d634769a8e7f47bcf44713b27a077460dedb55a506c1dde65db63ecd3f53ef
MD5 a64ad3690d836a461801e5d811d244ee
BLAKE2b-256 99b03022e3d2d750d6f4d53ab59c3d77715fd97c75bf9d8f101efc8f9333e854

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page