traffic-taffy 0.3.6__py3-none-any.whl → 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- traffic_taffy/cache_info.py +0 -6
- traffic_taffy/compare.py +154 -250
- traffic_taffy/comparison.py +26 -0
- traffic_taffy/dissection.py +383 -0
- traffic_taffy/dissectmany.py +20 -18
- traffic_taffy/dissector.py +128 -476
- traffic_taffy/dissector_engine/__init__.py +35 -0
- traffic_taffy/dissector_engine/dpkt.py +98 -0
- traffic_taffy/dissector_engine/scapy.py +98 -0
- traffic_taffy/graph.py +23 -90
- traffic_taffy/graphdata.py +35 -20
- traffic_taffy/output/__init__.py +118 -0
- traffic_taffy/output/console.py +72 -0
- traffic_taffy/output/fsdb.py +50 -0
- traffic_taffy/output/memory.py +51 -0
- traffic_taffy/pcap_splitter.py +17 -36
- traffic_taffy/tools/cache_info.py +65 -0
- traffic_taffy/tools/compare.py +110 -0
- traffic_taffy/tools/dissect.py +77 -0
- traffic_taffy/tools/explore.py +686 -0
- traffic_taffy/tools/graph.py +85 -0
- {traffic_taffy-0.3.6.dist-info → traffic_taffy-0.4.1.dist-info}/METADATA +1 -1
- traffic_taffy-0.4.1.dist-info/RECORD +29 -0
- traffic_taffy-0.4.1.dist-info/entry_points.txt +6 -0
- pcap_compare/cache_info.py +0 -46
- pcap_compare/compare.py +0 -288
- pcap_compare/dissectmany.py +0 -21
- pcap_compare/dissector.py +0 -512
- pcap_compare/dissectorresults.py +0 -21
- pcap_compare/graph.py +0 -210
- traffic_taffy/explore.py +0 -221
- traffic_taffy-0.3.6.dist-info/RECORD +0 -22
- traffic_taffy-0.3.6.dist-info/entry_points.txt +0 -5
- {pcap_compare → traffic_taffy/tools}/__init__.py +0 -0
- {traffic_taffy-0.3.6.dist-info → traffic_taffy-0.4.1.dist-info}/WHEEL +0 -0
- {traffic_taffy-0.3.6.dist-info → traffic_taffy-0.4.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
"""Read a PCAP file and graph it or parts of it"""
|
2
|
+
|
3
|
+
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
|
4
|
+
from traffic_taffy.graph import PcapGraph
|
5
|
+
from traffic_taffy.dissector import (
|
6
|
+
dissector_add_parseargs,
|
7
|
+
limitor_add_parseargs,
|
8
|
+
check_dissector_level,
|
9
|
+
)
|
10
|
+
import logging
|
11
|
+
|
12
|
+
|
13
|
+
def parse_args():
|
14
|
+
"Parse the command line arguments."
|
15
|
+
parser = ArgumentParser(
|
16
|
+
formatter_class=ArgumentDefaultsHelpFormatter,
|
17
|
+
description=__doc__,
|
18
|
+
epilog="Exmaple Usage: ",
|
19
|
+
)
|
20
|
+
|
21
|
+
parser.add_argument(
|
22
|
+
"-o",
|
23
|
+
"--output-file",
|
24
|
+
default=None,
|
25
|
+
type=str,
|
26
|
+
help="Where to save the output (png)",
|
27
|
+
)
|
28
|
+
|
29
|
+
parser.add_argument(
|
30
|
+
"-p",
|
31
|
+
"--by-percentage",
|
32
|
+
action="store_true",
|
33
|
+
help="Graph by percentage of traffic rather than by value",
|
34
|
+
)
|
35
|
+
|
36
|
+
parser.add_argument(
|
37
|
+
"-i",
|
38
|
+
"--interactive",
|
39
|
+
action="store_true",
|
40
|
+
help="Prompt repeatedly for graph data to create",
|
41
|
+
)
|
42
|
+
|
43
|
+
parser.add_argument(
|
44
|
+
"--log-level",
|
45
|
+
"--ll",
|
46
|
+
default="info",
|
47
|
+
help="Define verbosity level (debug, info, warning, error, fotal, critical).",
|
48
|
+
)
|
49
|
+
|
50
|
+
dissector_add_parseargs(parser)
|
51
|
+
limitor_add_parseargs(parser)
|
52
|
+
|
53
|
+
parser.add_argument("input_file", type=str, help="PCAP file to graph", nargs="+")
|
54
|
+
|
55
|
+
args = parser.parse_args()
|
56
|
+
log_level = args.log_level.upper()
|
57
|
+
logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
|
58
|
+
logging.getLogger("matplotlib.font_manager").setLevel(logging.ERROR)
|
59
|
+
return args
|
60
|
+
|
61
|
+
|
62
|
+
def main():
|
63
|
+
args = parse_args()
|
64
|
+
|
65
|
+
check_dissector_level(args.dissection_level)
|
66
|
+
|
67
|
+
pc = PcapGraph(
|
68
|
+
args.input_file,
|
69
|
+
args.output_file,
|
70
|
+
maximum_count=args.packet_count,
|
71
|
+
minimum_count=args.minimum_count,
|
72
|
+
bin_size=args.bin_size,
|
73
|
+
match_string=args.match_string,
|
74
|
+
match_value=args.match_value,
|
75
|
+
cache_pcap_results=args.cache_pcap_results,
|
76
|
+
dissector_level=args.dissection_level,
|
77
|
+
interactive=args.interactive,
|
78
|
+
by_percentage=args.by_percentage,
|
79
|
+
ignore_list=args.ignore_list,
|
80
|
+
)
|
81
|
+
pc.graph_it()
|
82
|
+
|
83
|
+
|
84
|
+
if __name__ == "__main__":
|
85
|
+
main()
|
@@ -0,0 +1,29 @@
|
|
1
|
+
traffic_taffy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
traffic_taffy/cache_info.py,sha256=tmPmMJFhz74FDxLoqnQgki5qsUtoJBzkzk3w0ZAen0c,1369
|
3
|
+
traffic_taffy/compare.py,sha256=RumWfKrJimdJ3s00gVcnFPEY_yeETpWhzg4l9JuPVHI,10103
|
4
|
+
traffic_taffy/comparison.py,sha256=goGJbJsr8mzMqRvrJOXxW9QJaLZUg4W85Ji7Bjl-UKA,583
|
5
|
+
traffic_taffy/dissection.py,sha256=q27ab-2oN1avXfyoFBhIUb9ZHsikcPm8A_ceQn662XQ,13792
|
6
|
+
traffic_taffy/dissectmany.py,sha256=h3tIIQhNCD2OaOev2M2WKAhk5HBX_vw6uhzLZAjohHM,2679
|
7
|
+
traffic_taffy/dissector.py,sha256=5XynUhIy80B1ZuWkMBTjeS8_Q1xJYaDp9w3DpQT75w0,7746
|
8
|
+
traffic_taffy/dissectorresults.py,sha256=LKoyX04Qjc6B7RnqtJgIWsyVnselJ9CygLkMAp3lhw0,647
|
9
|
+
traffic_taffy/graph.py,sha256=xO58IkMmfdgIEt04w06wmJhcdEGVzJxGMl1x7LnC-6k,3409
|
10
|
+
traffic_taffy/graphdata.py,sha256=Aa3wTyI_nkOtQQ35Qwv93qGNyytZyNW5V6TvAx9JDb4,2256
|
11
|
+
traffic_taffy/pcap_splitter.py,sha256=HKz7QOnekqxUut58TMPK3-dQmP98NIhL7Ii6ofFnxYY,3868
|
12
|
+
traffic_taffy/dissector_engine/__init__.py,sha256=iGi_DUtyTRaZxcb2qNbZSuSgE0ITBUpHRNQivo0gwx8,1190
|
13
|
+
traffic_taffy/dissector_engine/dpkt.py,sha256=uby0j6LFCjnxQvyR2APhKKtydKJmHV6ANn1oODRyIPo,4256
|
14
|
+
traffic_taffy/dissector_engine/scapy.py,sha256=0MMRQt3LTZ7dsEWBXnO4Lk8buQ4vH-9jEkXExuGis48,3799
|
15
|
+
traffic_taffy/output/__init__.py,sha256=0laqOfA1LvqlgL0IVDMp-qnwDIQuPLDvrpT3qV-RhjU,3455
|
16
|
+
traffic_taffy/output/console.py,sha256=me-BPAHwgqvl5tS-EvHmEPUEt6ryn0Rcj76lfGJazSc,2315
|
17
|
+
traffic_taffy/output/fsdb.py,sha256=c_XwjPdLcl85MZwBY7VgbPymqDZje8St_HmyJl_9LFU,1449
|
18
|
+
traffic_taffy/output/memory.py,sha256=McYpPbg4kux_U21OabE4lUhrgT60V0eKUiey0Udzc9s,1502
|
19
|
+
traffic_taffy/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
+
traffic_taffy/tools/cache_info.py,sha256=4SZVdcwA_36YLyIYN8F5AbKaM-xCLj8P089wE2fKXCA,1933
|
21
|
+
traffic_taffy/tools/compare.py,sha256=f2A1bDmMZc_TZkAGWCEpcFcQVXkO83aVYpMi013kFbg,3016
|
22
|
+
traffic_taffy/tools/dissect.py,sha256=fVfZ_fHOkiHaa51QF7uhTJlknkphw-AWssLF2zWYWCs,2089
|
23
|
+
traffic_taffy/tools/explore.py,sha256=Y_fjBDwDkghvK_bvrXevKSBc1qqpfQqkuRngr33T7PY,24888
|
24
|
+
traffic_taffy/tools/graph.py,sha256=8o3jxtRDgoXmb9vJXndc4agNzBlYQlNrC3jW5Cn-uAY,2215
|
25
|
+
traffic_taffy-0.4.1.dist-info/METADATA,sha256=BEdOspLVEQkIXc1YObuDSyIq9gnUz3rDgJGIXnH85uU,1014
|
26
|
+
traffic_taffy-0.4.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
27
|
+
traffic_taffy-0.4.1.dist-info/entry_points.txt,sha256=pl_Acah6y3vbCuS52Thx21WJ91YMzTs8Cdftz9740dk,267
|
28
|
+
traffic_taffy-0.4.1.dist-info/top_level.txt,sha256=wjeQaxXSKqUzrRtfbUlbSn8SoaL4VC73yudFAEtnIuo,14
|
29
|
+
traffic_taffy-0.4.1.dist-info/RECORD,,
|
@@ -0,0 +1,6 @@
|
|
1
|
+
[console_scripts]
|
2
|
+
taffy-cache-info = traffic_taffy.tools.cache_info:main
|
3
|
+
taffy-compare = traffic_taffy.tools.compare:main
|
4
|
+
taffy-dissect = traffic_taffy.tools.dissect:main
|
5
|
+
taffy-explorer = traffic_taffy.tools.explorer:main
|
6
|
+
taffy-graph = traffic_taffy.tools.graph:main
|
pcap_compare/cache_info.py
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
"""Loads the cached data for a file to display the results about it"""
|
2
|
-
|
3
|
-
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, FileType
|
4
|
-
from logging import debug, info, warning, error, critical
|
5
|
-
from rich import print
|
6
|
-
import logging
|
7
|
-
import sys
|
8
|
-
import pickle
|
9
|
-
|
10
|
-
def parse_args():
|
11
|
-
"Parse the command line arguments."
|
12
|
-
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter,
|
13
|
-
description=__doc__,
|
14
|
-
epilog="Exmaple Usage: ")
|
15
|
-
|
16
|
-
parser.add_argument("--log-level", "--ll", default="info",
|
17
|
-
help="Define the logging verbosity level (debug, info, warning, error, fotal, critical).")
|
18
|
-
|
19
|
-
parser.add_argument("cache_file", type=str,
|
20
|
-
help="The cache file to load and display information about")
|
21
|
-
|
22
|
-
args = parser.parse_args()
|
23
|
-
log_level = args.log_level.upper()
|
24
|
-
logging.basicConfig(level=log_level,
|
25
|
-
format="%(levelname)-10s:\t%(message)s")
|
26
|
-
return args
|
27
|
-
|
28
|
-
def main():
|
29
|
-
args = parse_args()
|
30
|
-
contents = pickle.load(open(args.cache_file, "rb"))
|
31
|
-
|
32
|
-
# play the major keys
|
33
|
-
for key in contents.keys():
|
34
|
-
if key != 'dissection' and key != 'parameters':
|
35
|
-
print(f"{key:<20} {contents[key]}")
|
36
|
-
|
37
|
-
# then the minors
|
38
|
-
print("parameters:")
|
39
|
-
for key in contents['parameters']:
|
40
|
-
print(f" {key:<16} {contents['parameters'][key]}")
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
if __name__ == "__main__":
|
46
|
-
main()
|
pcap_compare/compare.py
DELETED
@@ -1,288 +0,0 @@
|
|
1
|
-
"""Takes a set of pcap files to compare and creates a report"""
|
2
|
-
|
3
|
-
import logging
|
4
|
-
from logging import info
|
5
|
-
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
|
6
|
-
from typing import List
|
7
|
-
from rich.console import Console
|
8
|
-
from pcap_compare.dissectmany import PCAPDissectMany
|
9
|
-
from pcap_compare.dissector import (
|
10
|
-
PCAPDissectorType,
|
11
|
-
dissector_add_parseargs,
|
12
|
-
limitor_add_parseargs,
|
13
|
-
PCAPDissector,
|
14
|
-
check_dissector_level,
|
15
|
-
)
|
16
|
-
|
17
|
-
|
18
|
-
class PcapCompare:
|
19
|
-
"Takes a set of PCAPs to then perform various comparisons upon"
|
20
|
-
|
21
|
-
REPORT_VERSION: int = 2
|
22
|
-
|
23
|
-
def __init__(
|
24
|
-
self,
|
25
|
-
pcaps: List[str],
|
26
|
-
maximum_count: int | None = None,
|
27
|
-
deep: bool = True,
|
28
|
-
print_threshold: float = 0.0,
|
29
|
-
print_minimum_count: int | None = None,
|
30
|
-
print_match_string: str | None = None,
|
31
|
-
pkt_filter: str | None = None,
|
32
|
-
only_positive: bool = False,
|
33
|
-
only_negative: bool = False,
|
34
|
-
cache_results: bool = False,
|
35
|
-
dissection_level: PCAPDissectorType = PCAPDissectorType.COUNT_ONLY,
|
36
|
-
) -> None:
|
37
|
-
|
38
|
-
self.pcaps = pcaps
|
39
|
-
self.deep = deep
|
40
|
-
self.maximum_count = maximum_count
|
41
|
-
self.print_threshold = print_threshold
|
42
|
-
self.print_minimum_count = print_minimum_count
|
43
|
-
self.print_match_string = print_match_string
|
44
|
-
self.pkt_filter = pkt_filter
|
45
|
-
self.only_positive = only_positive
|
46
|
-
self.only_negative = only_negative
|
47
|
-
self.cache_results = cache_results
|
48
|
-
self.dissection_level = dissection_level
|
49
|
-
|
50
|
-
def compare_results(self, report1: dict, report2: dict) -> dict:
|
51
|
-
"compares the results from two reports"
|
52
|
-
|
53
|
-
# TODO: handle recursive depths, where items are subtrees rather than Counters
|
54
|
-
|
55
|
-
report = {}
|
56
|
-
|
57
|
-
# TODO: we're only (currently) doing full pcap compares
|
58
|
-
report1 = report1[0]
|
59
|
-
report2 = report2[0]
|
60
|
-
|
61
|
-
for key in report1:
|
62
|
-
# TODO: deal with missing keys from one set
|
63
|
-
report1_total = report1[key].total()
|
64
|
-
report2_total = report2[key].total()
|
65
|
-
report[key] = {}
|
66
|
-
|
67
|
-
for subkey in report1[key].keys():
|
68
|
-
delta = 0.0
|
69
|
-
total = 0
|
70
|
-
if subkey in report1[key] and subkey in report2[key]:
|
71
|
-
delta = (
|
72
|
-
report2[key][subkey] / report2_total
|
73
|
-
- report1[key][subkey] / report1_total
|
74
|
-
)
|
75
|
-
total = report2[key][subkey] + report1[key][subkey]
|
76
|
-
ref_count = report1[key][subkey]
|
77
|
-
comp_count = report2[key][subkey]
|
78
|
-
else:
|
79
|
-
delta = -1.0
|
80
|
-
total = report1[key][subkey]
|
81
|
-
ref_count = report1[key][subkey]
|
82
|
-
comp_count = 0
|
83
|
-
|
84
|
-
report[key][subkey] = {
|
85
|
-
"delta": delta,
|
86
|
-
"total": total,
|
87
|
-
"ref_count": ref_count,
|
88
|
-
"comp_count": comp_count,
|
89
|
-
}
|
90
|
-
|
91
|
-
for subkey in report2[key].keys():
|
92
|
-
if subkey not in report[key]:
|
93
|
-
delta = 1.0
|
94
|
-
total = report2[key][subkey]
|
95
|
-
ref_count = 0
|
96
|
-
comp_count = report2[key][subkey]
|
97
|
-
|
98
|
-
report[key][subkey] = {
|
99
|
-
"delta": delta,
|
100
|
-
"total": total,
|
101
|
-
"ref_count": ref_count,
|
102
|
-
"comp_count": comp_count,
|
103
|
-
}
|
104
|
-
|
105
|
-
return report
|
106
|
-
|
107
|
-
def filter_check(self, data: dict) -> bool:
|
108
|
-
"Returns true if we should include it"
|
109
|
-
delta: float = data["delta"]
|
110
|
-
total: int = data["total"]
|
111
|
-
|
112
|
-
if self.only_positive and delta <= 0:
|
113
|
-
return False
|
114
|
-
|
115
|
-
if self.only_negative and delta >= 0:
|
116
|
-
return False
|
117
|
-
|
118
|
-
if not self.print_threshold and not self.print_minimum_count:
|
119
|
-
# always print
|
120
|
-
return True
|
121
|
-
|
122
|
-
if self.print_threshold and not self.print_minimum_count:
|
123
|
-
# check print_threshold as a fraction
|
124
|
-
if abs(delta) > self.print_threshold:
|
125
|
-
return True
|
126
|
-
elif not self.print_threshold and self.print_minimum_count:
|
127
|
-
# just check print_minimum_count
|
128
|
-
if total > self.print_minimum_count:
|
129
|
-
return True
|
130
|
-
else:
|
131
|
-
# require both
|
132
|
-
if total > self.print_minimum_count and abs(delta) > self.print_threshold:
|
133
|
-
return True
|
134
|
-
|
135
|
-
return False
|
136
|
-
|
137
|
-
def print_report(self, report: dict) -> None:
|
138
|
-
"prints a report to the console"
|
139
|
-
console = Console()
|
140
|
-
for key in sorted(report):
|
141
|
-
reported: bool = False
|
142
|
-
|
143
|
-
if self.print_match_string and self.print_match_string not in key:
|
144
|
-
continue
|
145
|
-
|
146
|
-
for subkey, data in sorted(
|
147
|
-
report[key].items(), key=lambda x: x[1]["delta"], reverse=True
|
148
|
-
):
|
149
|
-
if not self.filter_check(data):
|
150
|
-
continue
|
151
|
-
|
152
|
-
# print the header
|
153
|
-
if not reported:
|
154
|
-
print(f"====== {key}")
|
155
|
-
reported = True
|
156
|
-
|
157
|
-
delta: float = data["delta"]
|
158
|
-
|
159
|
-
# apply some fancy styling
|
160
|
-
style = ""
|
161
|
-
if delta < -0.5:
|
162
|
-
style = "[bold red]"
|
163
|
-
elif delta < 0.0:
|
164
|
-
style = "[red]"
|
165
|
-
elif delta > 0.5:
|
166
|
-
style = "[bold green]"
|
167
|
-
elif delta > 0.0:
|
168
|
-
style = "[green]"
|
169
|
-
endstyle = style.replace("[", "[/")
|
170
|
-
|
171
|
-
# construct the output line with styling
|
172
|
-
subkey = PCAPDissector.make_printable(subkey)
|
173
|
-
line = f" {style}{subkey:<50}{endstyle}"
|
174
|
-
line += f"{100*delta:>6.2f} {data['total']:>8} "
|
175
|
-
line += f"{data['ref_count']:>8} {data['comp_count']:>8}"
|
176
|
-
|
177
|
-
# print it to the rich console
|
178
|
-
console.print(line)
|
179
|
-
|
180
|
-
def print(self) -> None:
|
181
|
-
"outputs the results"
|
182
|
-
for n, report in enumerate(self.reports):
|
183
|
-
print(f"************ report #{n}")
|
184
|
-
self.print_report(report)
|
185
|
-
|
186
|
-
def compare(self) -> None:
|
187
|
-
"Compares each pcap against the original source"
|
188
|
-
|
189
|
-
reports = []
|
190
|
-
|
191
|
-
# TODO: use parallel processes to load multiple at a time
|
192
|
-
|
193
|
-
# load the first as a reference pcap
|
194
|
-
info(f"reading pcap files using level={self.dissection_level}")
|
195
|
-
pdm = PCAPDissectMany(
|
196
|
-
self.pcaps,
|
197
|
-
bin_size=None,
|
198
|
-
maximum_count=self.maximum_count,
|
199
|
-
pcap_filter=self.pkt_filter,
|
200
|
-
cache_results=self.cache_results,
|
201
|
-
dissector_level=self.dissection_level,
|
202
|
-
)
|
203
|
-
results = pdm.load_all()
|
204
|
-
|
205
|
-
reference = next(results)
|
206
|
-
for other in results:
|
207
|
-
# compare the two
|
208
|
-
reports.append(self.compare_results(reference["data"], other["data"]))
|
209
|
-
|
210
|
-
self.reports = reports
|
211
|
-
|
212
|
-
|
213
|
-
def parse_args():
|
214
|
-
"Parse the command line arguments."
|
215
|
-
parser = ArgumentParser(
|
216
|
-
formatter_class=ArgumentDefaultsHelpFormatter,
|
217
|
-
description=__doc__,
|
218
|
-
epilog="Exmaple Usage: ",
|
219
|
-
)
|
220
|
-
|
221
|
-
limiting_parser = limitor_add_parseargs(parser)
|
222
|
-
|
223
|
-
limiting_parser.add_argument(
|
224
|
-
"-t",
|
225
|
-
"--print-threshold",
|
226
|
-
default=0.0,
|
227
|
-
type=float,
|
228
|
-
help="Don't print results with abs(percent) less than this threshold",
|
229
|
-
)
|
230
|
-
|
231
|
-
limiting_parser.add_argument(
|
232
|
-
"-P", "--only-positive", action="store_true", help="Only show positive entries"
|
233
|
-
)
|
234
|
-
|
235
|
-
limiting_parser.add_argument(
|
236
|
-
"-N", "--only-negative", action="store_true", help="Only show negative entries"
|
237
|
-
)
|
238
|
-
|
239
|
-
dissector_add_parseargs(parser)
|
240
|
-
|
241
|
-
debugging_group = parser.add_argument_group("Debugging options")
|
242
|
-
|
243
|
-
debugging_group.add_argument(
|
244
|
-
"--log-level",
|
245
|
-
"--ll",
|
246
|
-
default="info",
|
247
|
-
help="Define the logging verbosity level (debug, info, warning, error, ...).",
|
248
|
-
)
|
249
|
-
|
250
|
-
parser.add_argument("pcap_files", type=str, nargs="*", help="PCAP files to analyze")
|
251
|
-
|
252
|
-
args = parser.parse_args()
|
253
|
-
log_level = args.log_level.upper()
|
254
|
-
logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
|
255
|
-
|
256
|
-
check_dissector_level(args.dissection_level)
|
257
|
-
|
258
|
-
return args
|
259
|
-
|
260
|
-
|
261
|
-
def main():
|
262
|
-
args = parse_args()
|
263
|
-
pc = PcapCompare(
|
264
|
-
args.pcap_files,
|
265
|
-
maximum_count=args.packet_count,
|
266
|
-
print_threshold=float(args.print_threshold) / 100.0,
|
267
|
-
print_minimum_count=args.minimum_count,
|
268
|
-
print_match_string=args.match_string,
|
269
|
-
only_positive=args.only_positive,
|
270
|
-
only_negative=args.only_negative,
|
271
|
-
cache_results=args.cache_pcap_results,
|
272
|
-
dissection_level=args.dissection_level,
|
273
|
-
)
|
274
|
-
|
275
|
-
# compare the pcaps
|
276
|
-
pc.compare()
|
277
|
-
|
278
|
-
# print the results
|
279
|
-
pc.print()
|
280
|
-
|
281
|
-
# maybe save them
|
282
|
-
# TODO: loading and saving both makes more sense, throw error
|
283
|
-
if args.save_report:
|
284
|
-
pc.save_report(args.save_report)
|
285
|
-
|
286
|
-
|
287
|
-
if __name__ == "__main__":
|
288
|
-
main()
|
pcap_compare/dissectmany.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
from pcap_compare.dissector import PCAPDissector
|
2
|
-
from concurrent.futures import ProcessPoolExecutor
|
3
|
-
from logging import info
|
4
|
-
|
5
|
-
|
6
|
-
class PCAPDissectMany:
|
7
|
-
def __init__(self, pcap_files, *args, **kwargs):
|
8
|
-
self.pcap_files = pcap_files
|
9
|
-
self.args = args
|
10
|
-
self.kwargs = kwargs
|
11
|
-
self.futures = {}
|
12
|
-
|
13
|
-
def load_pcap(self, pcap_file):
|
14
|
-
pd = PCAPDissector(pcap_file, *self.args, **self.kwargs)
|
15
|
-
info(f"reading {pcap_file}")
|
16
|
-
return {"file": pcap_file, "data": pd.load()}
|
17
|
-
|
18
|
-
def load_all(self):
|
19
|
-
with ProcessPoolExecutor() as executor:
|
20
|
-
results = executor.map(self.load_pcap, self.pcap_files)
|
21
|
-
return results
|