traffic-taffy 0.9.3__tar.gz → 0.9.5__tar.gz

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.
Files changed (59) hide show
  1. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/PKG-INFO +1 -1
  2. traffic_taffy-0.9.5/traffic_taffy/__init__.py +1 -0
  3. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/statistical.py +3 -3
  4. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissector_engine/dpkt.py +62 -13
  5. traffic_taffy-0.9.5/traffic_taffy/report.py +12 -0
  6. traffic_taffy-0.9.5/traffic_taffy/tests/test_dpkt_engine.py +15 -0
  7. traffic_taffy-0.9.3/traffic_taffy/__init__.py +0 -1
  8. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/.gitignore +0 -0
  9. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/LICENSE.txt +0 -0
  10. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/README.md +0 -0
  11. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/pyproject.toml +0 -0
  12. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/__init__.py +0 -0
  13. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/comparecorrelation.py +0 -0
  14. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/comparecorrelationchanges.py +0 -0
  15. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/compareseries.py +0 -0
  16. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/algorithms/compareslices.py +0 -0
  17. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/compare.py +0 -0
  18. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/comparison.py +0 -0
  19. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/config.py +0 -0
  20. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissection.py +0 -0
  21. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissectmany.py +0 -0
  22. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissector.py +0 -0
  23. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissector_engine/__init__.py +0 -0
  24. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissector_engine/dnstap.py +0 -0
  25. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/dissector_engine/scapy.py +0 -0
  26. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/graph.py +0 -0
  27. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/graphdata.py +0 -0
  28. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/hooks/__init__.py +0 -0
  29. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/hooks/ip2asn.py +0 -0
  30. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/hooks/labels.py +0 -0
  31. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/hooks/psl.py +0 -0
  32. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/iana/tables.msgpak +0 -0
  33. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/output/__init__.py +0 -0
  34. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/output/console.py +0 -0
  35. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/output/fsdb.py +0 -0
  36. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/output/memory.py +0 -0
  37. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/reports/__init__.py +0 -0
  38. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/reports/compareslicesreport.py +0 -0
  39. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/reports/correlationchangereport.py +0 -0
  40. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/reports/correlationreport.py +0 -0
  41. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/taffy_config.py +0 -0
  42. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_compare_results.py +0 -0
  43. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_config.py +0 -0
  44. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_dict_merge.py +0 -0
  45. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_global_config.py +0 -0
  46. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_hooks.py +0 -0
  47. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_normalize.py +0 -0
  48. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_pcap_dissector.py +0 -0
  49. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_pcap_splitter.py +0 -0
  50. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_splitter.py +0 -0
  51. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tests/test_value_printing.py +0 -0
  52. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/__init__.py +0 -0
  53. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/cache_info.py +0 -0
  54. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/compare.py +0 -0
  55. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/config.py +0 -0
  56. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/dissect.py +0 -0
  57. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/explore.py +0 -0
  58. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/export.py +0 -0
  59. {traffic_taffy-0.9.3 → traffic_taffy-0.9.5}/traffic_taffy/tools/graph.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: traffic-taffy
3
- Version: 0.9.3
3
+ Version: 0.9.5
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>
@@ -0,0 +1 @@
1
+ __VERSION__ = "0.9.5"
@@ -65,7 +65,7 @@ class ComparisonStatistical(ComparisonSlicesAlgorithm):
65
65
  right_count = right_side[key][subkey]
66
66
  left_percentage = 0.0
67
67
  if right_side_total == 0:
68
- right_percentage = 100
68
+ right_percentage = 1.0
69
69
  else:
70
70
  right_percentage = right_side[key][subkey] / right_side_total
71
71
  new_right_count += 1 # this value wasn't in the left
@@ -81,12 +81,12 @@ class ComparisonStatistical(ComparisonSlicesAlgorithm):
81
81
  )
82
82
 
83
83
  if right_side_total == 0:
84
- right_percent = 100
84
+ right_percent = 1.0
85
85
  else:
86
86
  right_percent = new_right_count / right_side_total
87
87
 
88
88
  if left_side_total == 0:
89
- left_percent = 100
89
+ left_percent = 1.0
90
90
  else:
91
91
  left_percent = new_left_count / left_side_total
92
92
 
@@ -2,12 +2,13 @@
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
9
9
 
10
10
  import dpkt
11
+ import socket
11
12
 
12
13
 
13
14
  class DissectionEngineDpkt(DissectionEngine):
@@ -20,6 +21,7 @@ class DissectionEngineDpkt(DissectionEngine):
20
21
  def __init__(self, *args: list, **kwargs: dict):
21
22
  """Create a dissection engine for quickly parsing and counting packets."""
22
23
  super().__init__(*args, **kwargs)
24
+ self.data_link_type = None
23
25
 
24
26
  def load_data(self) -> None:
25
27
  """Load the specified PCAP into memory."""
@@ -29,6 +31,9 @@ class DissectionEngineDpkt(DissectionEngine):
29
31
  else:
30
32
  # it's an open handle already
31
33
  pcap = dpkt.pcap.Reader(self.pcap_file)
34
+
35
+ self.data_link_type = pcap.datalink()
36
+
32
37
  if self.pcap_filter:
33
38
  pcap.setfilter(self.pcap_filter)
34
39
  pcap.dispatch(self.maximum_count, self.callback)
@@ -144,14 +149,34 @@ class DissectionEngineDpkt(DissectionEngine):
144
149
  level = level.value
145
150
 
146
151
  if level >= PCAPDissectorLevel.THROUGH_IP.value:
147
- eth = dpkt.ethernet.Ethernet(packet)
148
- # these names are designed to match scapy names
149
- self.incr("Ethernet_dst", eth.dst)
150
- self.incr("Ethernet_src", eth.src)
151
- self.incr("Ethernet_type", eth.type)
152
-
153
- if isinstance(eth.data, dpkt.ip.IP):
154
- ip = eth.data
152
+ if self.data_link_type == 1:
153
+ # Ethernet based encapsulation
154
+ eth = dpkt.ethernet.Ethernet(packet)
155
+ # these names are designed to match scapy names
156
+ self.incr("Ethernet_dst", eth.dst)
157
+ self.incr("Ethernet_src", eth.src)
158
+ self.incr("Ethernet_type", eth.type)
159
+ data = eth.data
160
+ elif self.data_link_type == 101:
161
+ # Raw IP encapsulation
162
+ if packet[0] == 0x45:
163
+ data = dpkt.ip.IP(packet)
164
+ elif packet[0] == 0x60:
165
+ data = dpkt.ip6.IP6(packet)
166
+ else:
167
+ error("Unknown IP version in data")
168
+ raise ValueError("unknown IP version")
169
+ else:
170
+ error(f"unknown link type: {self.data_link_type}")
171
+ raise ValueError("unknown link type")
172
+
173
+ # TODO(hardaker): add ip6.IP6 support
174
+ next_layer = None
175
+ udp = None
176
+ tcp = None
177
+
178
+ if isinstance(data, dpkt.ip.IP):
179
+ ip = data
155
180
  udp = None
156
181
  tcp = None
157
182
 
@@ -177,8 +202,32 @@ class DissectionEngineDpkt(DissectionEngine):
177
202
  self.incr(prefix + "version", ip.v)
178
203
  self.incr(prefix + "ttl", ip.ttl)
179
204
 
180
- if isinstance(ip.data, dpkt.udp.UDP):
181
- udp = ip.data
205
+ next_layer = ip.data
206
+
207
+ elif isinstance(data, dpkt.ip6.IP6):
208
+ ip6 = data
209
+
210
+ ipver = "IPv6"
211
+ prefix = f"Ethernet_{ipver}_"
212
+
213
+ # TODO(hardaker): make sure all these match scapy
214
+ socket.inet_ntop(
215
+ socket.AF_INET6,
216
+ b"\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01",
217
+ )
218
+
219
+ self.incr(prefix + "dst", socket.inet_ntop(socket.AF_INET6, ip6.dst))
220
+ self.incr(prefix + "src", socket.inet_ntop(socket.AF_INET6, ip6.src))
221
+ self.incr(prefix + "fl", ip6.flow)
222
+ self.incr(prefix + "hlim", ip6.hlim)
223
+ self.incr(prefix + "nh", ip6.nxt)
224
+ self.incr(prefix + "plen", ip6.plen)
225
+ self.incr(prefix + "tc", ip6.fc)
226
+ next_layer = ip6.data
227
+
228
+ if next_layer:
229
+ if isinstance(next_layer, dpkt.udp.UDP):
230
+ udp = next_layer
182
231
  self.incr(prefix + "UDP_sport", udp.sport)
183
232
  self.incr(prefix + "UDP_dport", udp.dport)
184
233
  self.incr(prefix + "UDP_len", udp.ulen)
@@ -186,8 +235,8 @@ class DissectionEngineDpkt(DissectionEngine):
186
235
 
187
236
  # TODO(hardaker): handle DNS and others for level 3
188
237
 
189
- elif isinstance(ip.data, dpkt.tcp.TCP):
190
- tcp = ip.data
238
+ elif isinstance(next_layer, dpkt.tcp.TCP):
239
+ tcp = next_layer
191
240
  self.incr(prefix + "TCP_sport", tcp.sport)
192
241
  self.incr(prefix + "TCP_dport", tcp.dport)
193
242
  self.incr(prefix + "TCP_seq", tcp.seq)
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class Report:
6
+ delta_percentage: float
7
+ delta_absolute: int
8
+ total: int
9
+ left_count: int
10
+ right_count: int
11
+ left_percentage: float
12
+ right_percentage: float
@@ -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
+
@@ -1 +0,0 @@
1
- __VERSION__ = "0.9.3"
File without changes
File without changes
File without changes