traffic-taffy 0.9.2__py3-none-any.whl → 0.9.4__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/__init__.py +1 -1
- traffic_taffy/algorithms/statistical.py +6 -3
- traffic_taffy/dissector_engine/dpkt.py +29 -9
- traffic_taffy/report.py +12 -0
- traffic_taffy/tests/test_dpkt_engine.py +15 -0
- traffic_taffy/tools/config.py +39 -39
- {traffic_taffy-0.9.2.dist-info → traffic_taffy-0.9.4.dist-info}/METADATA +7 -1
- {traffic_taffy-0.9.2.dist-info → traffic_taffy-0.9.4.dist-info}/RECORD +11 -9
- {traffic_taffy-0.9.2.dist-info → traffic_taffy-0.9.4.dist-info}/WHEEL +0 -0
- {traffic_taffy-0.9.2.dist-info → traffic_taffy-0.9.4.dist-info}/entry_points.txt +0 -0
- {traffic_taffy-0.9.2.dist-info → traffic_taffy-0.9.4.dist-info}/licenses/LICENSE.txt +0 -0
traffic_taffy/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__VERSION__ = "0.9.
|
1
|
+
__VERSION__ = "0.9.4"
|
@@ -64,7 +64,10 @@ class ComparisonStatistical(ComparisonSlicesAlgorithm):
|
|
64
64
|
left_count = 0
|
65
65
|
right_count = right_side[key][subkey]
|
66
66
|
left_percentage = 0.0
|
67
|
-
|
67
|
+
if right_side_total == 0:
|
68
|
+
right_percentage = 1.0
|
69
|
+
else:
|
70
|
+
right_percentage = right_side[key][subkey] / right_side_total
|
68
71
|
new_right_count += 1 # this value wasn't in the left
|
69
72
|
|
70
73
|
report[key][subkey] = CompareSlicesReport(
|
@@ -78,12 +81,12 @@ class ComparisonStatistical(ComparisonSlicesAlgorithm):
|
|
78
81
|
)
|
79
82
|
|
80
83
|
if right_side_total == 0:
|
81
|
-
right_percent =
|
84
|
+
right_percent = 1.0
|
82
85
|
else:
|
83
86
|
right_percent = new_right_count / right_side_total
|
84
87
|
|
85
88
|
if left_side_total == 0:
|
86
|
-
left_percent =
|
89
|
+
left_percent = 1.0
|
87
90
|
else:
|
88
91
|
left_percent = new_left_count / left_side_total
|
89
92
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
-
from logging import debug
|
5
|
+
from logging import debug, error
|
6
6
|
from traffic_taffy.dissector_engine import DissectionEngine
|
7
7
|
from traffic_taffy.dissection import Dissection, PCAPDissectorLevel
|
8
8
|
from pcap_parallel import PCAPParallel
|
@@ -20,6 +20,7 @@ class DissectionEngineDpkt(DissectionEngine):
|
|
20
20
|
def __init__(self, *args: list, **kwargs: dict):
|
21
21
|
"""Create a dissection engine for quickly parsing and counting packets."""
|
22
22
|
super().__init__(*args, **kwargs)
|
23
|
+
self.data_link_type = None
|
23
24
|
|
24
25
|
def load_data(self) -> None:
|
25
26
|
"""Load the specified PCAP into memory."""
|
@@ -29,6 +30,9 @@ class DissectionEngineDpkt(DissectionEngine):
|
|
29
30
|
else:
|
30
31
|
# it's an open handle already
|
31
32
|
pcap = dpkt.pcap.Reader(self.pcap_file)
|
33
|
+
|
34
|
+
self.data_link_type = pcap.datalink()
|
35
|
+
|
32
36
|
if self.pcap_filter:
|
33
37
|
pcap.setfilter(self.pcap_filter)
|
34
38
|
pcap.dispatch(self.maximum_count, self.callback)
|
@@ -144,14 +148,30 @@ class DissectionEngineDpkt(DissectionEngine):
|
|
144
148
|
level = level.value
|
145
149
|
|
146
150
|
if level >= PCAPDissectorLevel.THROUGH_IP.value:
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
if self.data_link_type == 1:
|
152
|
+
# Ethernet based encapsulation
|
153
|
+
eth = dpkt.ethernet.Ethernet(packet)
|
154
|
+
# these names are designed to match scapy names
|
155
|
+
self.incr("Ethernet_dst", eth.dst)
|
156
|
+
self.incr("Ethernet_src", eth.src)
|
157
|
+
self.incr("Ethernet_type", eth.type)
|
158
|
+
data = eth.data
|
159
|
+
elif self.data_link_type == 101:
|
160
|
+
# Raw IP encapsulation
|
161
|
+
if packet[0] == 0x45:
|
162
|
+
data = dpkt.ip.IP(packet)
|
163
|
+
elif packet[0] == 0x60:
|
164
|
+
data = dpkt.ip6.IP6(packet)
|
165
|
+
else:
|
166
|
+
error("Unknown IP version in data")
|
167
|
+
raise ValueError("unknown IP version")
|
168
|
+
else:
|
169
|
+
error(f"unknown link type: {self.data_link_type}")
|
170
|
+
raise ValueError("unknown link type")
|
171
|
+
|
172
|
+
# TODO(hardaker): add ip6.IP6 support
|
173
|
+
if isinstance(data, dpkt.ip.IP):
|
174
|
+
ip = data
|
155
175
|
udp = None
|
156
176
|
tcp = None
|
157
177
|
|
traffic_taffy/report.py
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
import os
|
2
|
+
from traffic_taffy.dissection import PCAPDissectorLevel
|
3
|
+
from traffic_taffy.dissector_engine.dpkt import DissectionEngineDpkt
|
4
|
+
|
5
|
+
def test_dpkt_engine():
|
6
|
+
test_pcap = "dns.pcap"
|
7
|
+
test_pcap = "port53-2023-30-31_20.pcap"
|
8
|
+
test_pcap = "airplane-wireless.pcap"
|
9
|
+
if not os.path.exists(test_pcap):
|
10
|
+
return
|
11
|
+
|
12
|
+
engine = DissectionEngineDpkt(test_pcap,
|
13
|
+
dissector_level = PCAPDissectorLevel.COMMON_LAYERS)
|
14
|
+
dissection = engine.load()
|
15
|
+
|
traffic_taffy/tools/config.py
CHANGED
@@ -33,48 +33,48 @@ except ModuleNotFoundError:
|
|
33
33
|
logging.debug("psl module not loadable")
|
34
34
|
|
35
35
|
|
36
|
+
def taffy_config_parse_args() -> Namespace:
|
37
|
+
"""Parse the command line arguments."""
|
38
|
+
|
39
|
+
config: TaffyConfig = TaffyConfig()
|
40
|
+
config.config_option_names = ["-y", "--config"]
|
41
|
+
config[TT_CFG.LOG_LEVEL] = "info"
|
42
|
+
|
43
|
+
config.read_configfile_from_arguments(sys.argv)
|
44
|
+
|
45
|
+
parser = ArgumentParser(
|
46
|
+
formatter_class=RichHelpFormatter,
|
47
|
+
description=__doc__,
|
48
|
+
epilog="Example Usage: taffy-config > defaults.yml",
|
49
|
+
)
|
50
|
+
|
51
|
+
parser.add_argument(
|
52
|
+
"-y",
|
53
|
+
"--config",
|
54
|
+
default=None,
|
55
|
+
type=str,
|
56
|
+
help="Configuration file (YAML) to load.",
|
57
|
+
)
|
58
|
+
|
59
|
+
parser.add_argument(
|
60
|
+
"--log-level",
|
61
|
+
"--ll",
|
62
|
+
default="info",
|
63
|
+
help="Define the logging verbosity level (debug, info, warning, error, fotal, critical).",
|
64
|
+
)
|
65
|
+
|
66
|
+
args = parser.parse_args()
|
67
|
+
log_level = args.log_level.upper()
|
68
|
+
logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
|
69
|
+
|
70
|
+
config.load_namespace(args)
|
71
|
+
return config
|
72
|
+
|
73
|
+
|
36
74
|
def main() -> None:
|
37
75
|
"""Dissect a pcap file and report contents."""
|
38
76
|
|
39
|
-
|
40
|
-
"""Parse the command line arguments."""
|
41
|
-
|
42
|
-
config: TaffyConfig = TaffyConfig()
|
43
|
-
config.config_option_names = ["-y", "--config"]
|
44
|
-
config[TT_CFG.LOG_LEVEL] = "info"
|
45
|
-
|
46
|
-
config.read_configfile_from_arguments(sys.argv)
|
47
|
-
|
48
|
-
parser = ArgumentParser(
|
49
|
-
formatter_class=RichHelpFormatter,
|
50
|
-
description=__doc__,
|
51
|
-
epilog="Example Usage: taffy-config > defaults.yml",
|
52
|
-
)
|
53
|
-
|
54
|
-
parser.add_argument(
|
55
|
-
"-y",
|
56
|
-
"--config",
|
57
|
-
default=None,
|
58
|
-
type=str,
|
59
|
-
help="Configuration file (YAML) to load.",
|
60
|
-
)
|
61
|
-
|
62
|
-
parser.add_argument(
|
63
|
-
"--log-level",
|
64
|
-
"--ll",
|
65
|
-
default="info",
|
66
|
-
help="Define the logging verbosity level (debug, info, warning, error, fotal, critical).",
|
67
|
-
)
|
68
|
-
|
69
|
-
args = parser.parse_args()
|
70
|
-
log_level = args.log_level.upper()
|
71
|
-
logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
|
72
|
-
|
73
|
-
config.load_namespace(args)
|
74
|
-
return config
|
75
|
-
|
76
|
-
config = parse_args()
|
77
|
-
config.as_namespace()
|
77
|
+
config = taffy_config_parse_args()
|
78
78
|
|
79
79
|
print(yaml.dump(dict(config)))
|
80
80
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: traffic-taffy
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.4
|
4
4
|
Summary: A tool for doing differential analysis of pcap files
|
5
5
|
Project-URL: Homepage, https://traffic-taffy.github.io/
|
6
6
|
Author-email: Wes Hardaker <opensource@hardakers.net>
|
@@ -56,6 +56,12 @@ might be coming that will cause merge conflicts.
|
|
56
56
|
|
57
57
|
# Copyright and License
|
58
58
|
|
59
|
+
Traffic-taffy was created by [Wes Hardaker], a computer scientist at
|
60
|
+
[USC/ISI], with support from the Comcast Innovation Fund.
|
61
|
+
|
62
|
+
[Wes Hardaker]: https://ant.isi.edu/~hardaker/
|
63
|
+
[USC/ISI]: https://www.isi.edu/
|
64
|
+
|
59
65
|
This project is copyrighted by the University of Southern California,
|
60
66
|
Information Sciences institute. It is released under the Apache 2.0
|
61
67
|
license.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
traffic_taffy/__init__.py,sha256=
|
1
|
+
traffic_taffy/__init__.py,sha256=UI1Y766LRTQsBQeHgwpMOn6l2U43AJiA2KPxg4vVPO0,22
|
2
2
|
traffic_taffy/compare.py,sha256=g9rU6oa_2Wy0nUJ7K6TI8JTctyGCRvYEUakDBf7blOY,8644
|
3
3
|
traffic_taffy/comparison.py,sha256=KJxOp4UqhfRkF4LI1PMDRIefeyTm2w5sbdr7VUTS4KM,1451
|
4
4
|
traffic_taffy/config.py,sha256=DgTu2kA1Ec4Hbwl_44kTsdyJYvxAabgJk9a7aOH2XXU,4444
|
@@ -7,16 +7,17 @@ traffic_taffy/dissectmany.py,sha256=SWFXFyERNCi0j7hiMDEeJJdPYDpa0SOlSj1V8AqpXUA,
|
|
7
7
|
traffic_taffy/dissector.py,sha256=M5MHVPwfeMHa6s4TG8ZiiNjk7qaht65wdqm0nmRHdQ8,15682
|
8
8
|
traffic_taffy/graph.py,sha256=EfkxH5D9PNlDpvftkh9GyUusV05EV537QGB7JOMeW4w,4730
|
9
9
|
traffic_taffy/graphdata.py,sha256=r_QNXO3FzC7Vx4123SdCliAh7j2NCQ4Lb5uoOJnlt2M,3376
|
10
|
+
traffic_taffy/report.py,sha256=Yzb27hUWcWL-RxWpSQmRyM8NyWxQGT0l0jUCGHoYDSY,224
|
10
11
|
traffic_taffy/taffy_config.py,sha256=AmdQbWAhoiV7aTNSpV1exJfd5eA0a3sYTIjikHkMPwY,1124
|
11
12
|
traffic_taffy/algorithms/__init__.py,sha256=A7xI2ctotBT7WgG-6ItilXE_FIWF9QWc6UjdfGyThKw,737
|
12
13
|
traffic_taffy/algorithms/comparecorrelation.py,sha256=gakZJotZNOVj96y4_-vtt_ka8pZLBVERf44Yixtq_yE,5875
|
13
14
|
traffic_taffy/algorithms/comparecorrelationchanges.py,sha256=-ztWKpNN5lm_6e7hTSZytwzuK1RpMpfe1ksQgsb0_tk,7646
|
14
15
|
traffic_taffy/algorithms/compareseries.py,sha256=cVonTV6TnMZAaHlGqZ6shn0aDQTTHzK-tPvUAk3OkuQ,4165
|
15
16
|
traffic_taffy/algorithms/compareslices.py,sha256=aIDhISKi-m8uD65pBd3A2naoxYD9zeay6y7mAk4hXdg,4336
|
16
|
-
traffic_taffy/algorithms/statistical.py,sha256=
|
17
|
+
traffic_taffy/algorithms/statistical.py,sha256=0Hr62ZUZlFCNPUh6yVBRFjNho42cTGeX_GHtbq1sbak,4281
|
17
18
|
traffic_taffy/dissector_engine/__init__.py,sha256=Hu-UQtz7yhivmQLUP5b8tFQLEhy2bfvrRV3Q4aZp6vg,2202
|
18
19
|
traffic_taffy/dissector_engine/dnstap.py,sha256=rBzVlB0D3YVhHOsr17cbnCIZU13g20srgR4sE7ZfNUE,4810
|
19
|
-
traffic_taffy/dissector_engine/dpkt.py,sha256=
|
20
|
+
traffic_taffy/dissector_engine/dpkt.py,sha256=9JSyKBe2Ec0GItdmwo5mpzekg4Ua5NdpLnllhiV33Jg,11753
|
20
21
|
traffic_taffy/dissector_engine/scapy.py,sha256=WrZUfV_viR2Tro0kM3QKUkufIcM3RyYaZ3ncA1yZsaU,4897
|
21
22
|
traffic_taffy/hooks/__init__.py,sha256=Bvhl6RnyBqQkWuCU6TS0O_ZHe4qCQsC4HE8FELigWPw,661
|
22
23
|
traffic_taffy/hooks/ip2asn.py,sha256=7UA52L6jej0RYBptzP9izO0yXMcqH7wcp2ocDRUN5dg,2216
|
@@ -34,6 +35,7 @@ traffic_taffy/reports/correlationreport.py,sha256=9PdL_53mxfO619PFSoeRsTEm63L1J_
|
|
34
35
|
traffic_taffy/tests/test_compare_results.py,sha256=iLcS9wvEqxgKszIspLtD2Zw8Qk5JxOCurQwWYzhtOkM,2318
|
35
36
|
traffic_taffy/tests/test_config.py,sha256=UCqSJXVwpFFchcIbyFzLqjVF-wgEV755KlQ7thommro,4284
|
36
37
|
traffic_taffy/tests/test_dict_merge.py,sha256=t3rZSQQ0AlBxRKfLborx9SxYN53cCAQQzZ2w-__WT2Y,1429
|
38
|
+
traffic_taffy/tests/test_dpkt_engine.py,sha256=512Wfq7D1qVkfhGwf1u2QSgZooWqZQWV9L4OhpAr4AE,489
|
37
39
|
traffic_taffy/tests/test_global_config.py,sha256=kjr1wy1cXWagVLb0OnQYH0vz2htxLs944Xo42lNsir4,597
|
38
40
|
traffic_taffy/tests/test_hooks.py,sha256=amjEbtMwOZZCg_RCJ0wQR7aOqNfwz3IG3WY-9CwjSF4,1260
|
39
41
|
traffic_taffy/tests/test_normalize.py,sha256=sKHyiV8YXcKKcWqsbZP94nu_g5oEMJzzj6umeHxwa64,2638
|
@@ -44,13 +46,13 @@ traffic_taffy/tests/test_value_printing.py,sha256=rhmCUqnh1Lk1TTZvZi7ksvUWm4XDB4
|
|
44
46
|
traffic_taffy/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
47
|
traffic_taffy/tools/cache_info.py,sha256=ZanO6jDlTdfJ7w0N_7BkLyJj4NyZGShaH7SrUulbIoE,2085
|
46
48
|
traffic_taffy/tools/compare.py,sha256=oT5fIqfPeY6nGI9vSVAoKDsAVzzqfXJDzyOw2BhPfSI,3509
|
47
|
-
traffic_taffy/tools/config.py,sha256=
|
49
|
+
traffic_taffy/tools/config.py,sha256=RwJYyfI1yiAKbMzU5mcPTguBiH-hGRy5vk_YvAAjPuM,2343
|
48
50
|
traffic_taffy/tools/dissect.py,sha256=B-7e7aqEOWtJ-0P2Y-mzmrzoDqVrDCJ2JzGR45QtuuQ,3073
|
49
51
|
traffic_taffy/tools/explore.py,sha256=gUcOfAgangJJI1si1gLPUoWRUKmWUAXSP0oTD2JJygw,24149
|
50
52
|
traffic_taffy/tools/export.py,sha256=9zBBGhZK95b4ZiLJ8XK30GPsaBjgR84Sk1HoPIxRpTI,2844
|
51
53
|
traffic_taffy/tools/graph.py,sha256=KiKDY9R8JLT5-JouANoi_1WGcdFMhXsLnYlhPsFRWpM,2316
|
52
|
-
traffic_taffy-0.9.
|
53
|
-
traffic_taffy-0.9.
|
54
|
-
traffic_taffy-0.9.
|
55
|
-
traffic_taffy-0.9.
|
56
|
-
traffic_taffy-0.9.
|
54
|
+
traffic_taffy-0.9.4.dist-info/METADATA,sha256=JTazabFuUmC4sejWSCl5ib4E5A_iVEO8z7WuRnWGhHc,2241
|
55
|
+
traffic_taffy-0.9.4.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
|
56
|
+
traffic_taffy-0.9.4.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
|
57
|
+
traffic_taffy-0.9.4.dist-info/licenses/LICENSE.txt,sha256=hiV1DJgDQeSM1r7P-ez5oxily11S5nsCedU0jKzKKzo,11338
|
58
|
+
traffic_taffy-0.9.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|