Skip to content
Extraits de code Groupes Projets
Valider 8fbd46f2 rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

Argument output is now optional and defaults to None

parent 2e87e452
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -29,7 +29,7 @@ import pcap_fuzzer
```python
pcap_fuzzer.fuzz_pcaps(
pcaps: Union[str, list] # (List of) input PCAP files
output: str, # Output PCAP file path. Used only if a single input file is specified.
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).
......
......@@ -49,7 +49,7 @@ def must_edit_packet(i: int, packet_numbers: list, random_range: int) -> bool:
return is_specified or is_random
def fuzz_pcaps(pcaps: Union[str, list], output: str, random_range: int = 1, packet_numbers: list = None, dry_run: bool = False) -> None:
def fuzz_pcaps(pcaps: Union[str, list], output: str = None, random_range: int = 1, packet_numbers: list = None, dry_run: bool = False) -> None:
"""
Main functionality of the program:
(Randomly) edit packet fields in a (list of) PCAP file(s).
......@@ -117,7 +117,6 @@ def fuzz_pcaps(pcaps: Union[str, list], output: str, random_range: int = 1, pack
i += 1
# Write output PCAP file
output_pcap = ""
if output is not None and len(pcaps) == 1:
output_pcap = output
else:
......@@ -150,7 +149,7 @@ if __name__ == "__main__":
# Positional arguments: input PCAP file(s)
parser.add_argument("input_pcaps", metavar="pcap", type=str, nargs="+", help="Input PCAP file(s).")
# Optional flag: -o / --output
parser.add_argument("-o", "--output", type=str, help="Output PCAP (and CSV) file path. Used only if a single input file is specified. Default: edited/<input_pcap>.edit.pcap")
parser.add_argument("-o", "--output", type=str, default=None, help="Output PCAP (and CSV) file path. Used only if a single input file is specified. Default: edited/<input_pcap>.edit.pcap")
# Optional flag: -r / --random-range
parser.add_argument("-r", "--random-range", type=strictly_positive_int, default=1,
help="Upper bound for random range (not included). Must be a strictly positive integer. Default: 1 (edit each packet).")
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='pcap_fuzzer',
version='0.3.0',
version='0.4.0',
author='François De Keersmaeker',
author_email='francois.dekeersmaeker@uclouvain.be',
description='Randomly edit packet fields in a PCAP file.',
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter