Metadata-Version: 2.4
Name: pcap-fuzzer
Version: 0.5.0
Summary: Randomly edit packet fields in a PCAP file.
Author-email: François De Keersmaeker <francois.dekeersmaeker+github@proton.me>
Maintainer-email: François De Keersmaeker <francois.dekeersmaeker+github@proton.me>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/smart-home-network-security/pcap-fuzzer
Project-URL: Source, https://github.com/smart-home-network-security/pcap-fuzzer
Keywords: network,dns,unbound
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scapy==2.6.1
Dynamic: license-file

# pcap-fuzzer

[PyPI package page](https://pypi.org/project/pcap-fuzzer)

This program randomly edits packets from a PCAP file,
one field per edited packet.

The edited field will be chosen at random,
starting from the highest layer, and going down until it finds a supported protocol layer.

Example: a DNS packet will have one of its DNS fields edited,
and not one of the UDP or IP fields.


## Installation

```bash
pip install pcap-fuzzer
```

## Usage

Import statement:
```python
import pcap_fuzzer
```

`fuzz_pcaps` function doc:
```python
pcap_fuzzer.fuzz_pcaps(
    pcaps: Union[str, list]       # (List of) input PCAP files
    output: str,                  # [Optional] Output PCAP file path. Used only if a single input file is specified.
    random_range: int = 1,        # [Optional] Upper bound for random range (not included). Defaults to 1.
    packet_numbers: list = None,  # [Optional] List of indices, starting from 1, of packets to edit. If not specified, packets are randomly picked.
    dry_run: bool = False         # [Optional] If True, do not write output PCAP file(s).
) -> None
```

This function produces new, edited PCAP file(s).
If no output file is specified (for a single input file),
or if multiple input files are given,
the output file(s) will have the same name as the input file(s),
but with the suffix `.edit`,
and will be placed in a directory called `edited`,
in the same directory as the input files.
It will be created if it doesn't exist.

The program also produces CSV log files,
indicating which fields were edited for each packet.
The log files will be placed in a directory called `logs`,
in the same directory as the input files.
It will be created if it doesn't exist.


## Supported protocols (for now)

* Datalink Layer (2)
  * ARP
* Network Layer (3)
  * IPv4
  * IPv6
* Transport Layer (4)
  * TCP
  * UDP
  * ICMP
  * IGMP(v2 and v3)
* Application Layer (7)
  * HTTP
  * DNS
  * DHCP
  * SSDP
  * CoAP
