dissect.target 3.17.dev27__py3-none-any.whl → 3.17.dev29__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -65,6 +65,9 @@ class MQTTStream(AlignedStream):
65
65
  class MQTTConnection:
66
66
  broker = None
67
67
  host = None
68
+ prev = -1
69
+ factor = 1
70
+ prefetch_factor_inc = 10
68
71
 
69
72
  def __init__(self, broker: Broker, host: str):
70
73
  self.broker = broker
@@ -95,20 +98,32 @@ class MQTTConnection:
95
98
 
96
99
  def read(self, disk_id: int, offset: int, length: int, optimization_strategy: int) -> bytes:
97
100
  message = None
98
- self.broker.seek(self.host, disk_id, offset, length, optimization_strategy)
99
101
 
102
+ message = self.broker.read(self.host, disk_id, offset, length)
103
+ if message:
104
+ return message.data
105
+
106
+ if self.prev == offset - (length * self.factor):
107
+ if self.factor < 500:
108
+ self.factor += self.prefetch_factor_inc
109
+ else:
110
+ self.factor = 1
111
+
112
+ self.prev = offset
113
+ flength = length * self.factor
114
+ self.broker.factor = self.factor
115
+ self.broker.seek(self.host, disk_id, offset, flength, optimization_strategy)
100
116
  attempts = 0
101
117
  while True:
102
- message = self.broker.read(self.host, disk_id, offset, length)
103
- # don't waste time with sleep if we have a response
104
- if message:
118
+ if message := self.broker.read(self.host, disk_id, offset, length):
119
+ # don't waste time with sleep if we have a response
105
120
  break
106
121
 
107
122
  attempts += 1
108
- time.sleep(0.01)
109
- if attempts > 100:
123
+ time.sleep(0.1)
124
+ if attempts > 300:
110
125
  # message might have not reached agent, resend...
111
- self.broker.seek(self.host, disk_id, offset, length, optimization_strategy)
126
+ self.broker.seek(self.host, disk_id, offset, flength, optimization_strategy)
112
127
  attempts = 0
113
128
 
114
129
  return message.data
@@ -127,6 +142,7 @@ class Broker:
127
142
  diskinfo = {}
128
143
  index = {}
129
144
  topo = {}
145
+ factor = 1
130
146
 
131
147
  def __init__(self, broker: Broker, port: str, key: str, crt: str, ca: str, case: str, **kwargs):
132
148
  self.broker_host = broker
@@ -137,10 +153,13 @@ class Broker:
137
153
  self.case = case
138
154
  self.command = kwargs.get("command", None)
139
155
 
156
+ def clear_cache(self) -> None:
157
+ self.index = {}
158
+
140
159
  @suppress
141
160
  def read(self, host: str, disk_id: int, seek_address: int, read_length: int) -> SeekMessage:
142
161
  key = f"{host}-{disk_id}-{seek_address}-{read_length}"
143
- return self.index.pop(key)
162
+ return self.index.get(key)
144
163
 
145
164
  @suppress
146
165
  def disk(self, host: str) -> DiskMessage:
@@ -165,14 +184,15 @@ class Broker:
165
184
  disk_id = tokens[3]
166
185
  seek_address = int(tokens[4], 16)
167
186
  read_length = int(tokens[5], 16)
168
- msg = SeekMessage(data=payload)
169
187
 
170
- key = f"{hostname}-{disk_id}-{seek_address}-{read_length}"
188
+ for i in range(self.factor):
189
+ sublength = int(read_length / self.factor)
190
+ start = i * sublength
191
+ key = f"{hostname}-{disk_id}-{seek_address+start}-{sublength}"
192
+ if key in self.index:
193
+ continue
171
194
 
172
- if key in self.index:
173
- return
174
-
175
- self.index[key] = msg
195
+ self.index[key] = SeekMessage(data=payload[start : start + sublength])
176
196
 
177
197
  def _on_id(self, hostname: str, payload: bytes) -> None:
178
198
  key = hostname
@@ -204,9 +224,14 @@ class Broker:
204
224
  elif response == "ID":
205
225
  self._on_id(hostname, msg.payload)
206
226
 
207
- def seek(self, host: str, disk_id: int, offset: int, length: int, optimization_strategy: int) -> None:
227
+ def seek(self, host: str, disk_id: int, offset: int, flength: int, optimization_strategy: int) -> None:
228
+ length = int(flength / self.factor)
229
+ key = f"{host}-{disk_id}-{offset}-{length}"
230
+ if key in self.index:
231
+ return
232
+
208
233
  self.mqtt_client.publish(
209
- f"{self.case}/{host}/SEEK/{disk_id}/{hex(offset)}/{hex(length)}", pack("<I", optimization_strategy)
234
+ f"{self.case}/{host}/SEEK/{disk_id}/{hex(offset)}/{hex(flength)}", pack("<I", optimization_strategy)
210
235
  )
211
236
 
212
237
  def info(self, host: str) -> None:
@@ -154,7 +154,7 @@ class MftPlugin(Plugin):
154
154
  try:
155
155
  inuse = bool(record.header.Flags & FILE_RECORD_SEGMENT_IN_USE)
156
156
  owner, _ = get_owner_and_group(record, fs)
157
- resident = None
157
+ resident = False
158
158
  size = None
159
159
 
160
160
  if not record.is_dir():
@@ -173,8 +173,7 @@ def main():
173
173
  collected_plugins = {}
174
174
 
175
175
  if targets:
176
- for target in targets:
177
- plugin_target = Target.open(target)
176
+ for plugin_target in Target.open_all(targets, args.children):
178
177
  if isinstance(plugin_target._loader, ProxyLoader):
179
178
  parser.error("can't list compatible plugins for remote targets.")
180
179
  funcs, _ = find_plugin_functions(plugin_target, args.list, compatibility=True, show_hidden=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.17.dev27
3
+ Version: 3.17.dev29
4
4
  Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -85,7 +85,7 @@ dissect/target/loaders/itunes.py,sha256=69aMTQiiGYpmD_EYSmf9mO1re8C3jAZIEStmwlMx
85
85
  dissect/target/loaders/kape.py,sha256=t5TfrGLqPeIpUUpXzIl6aHsqXMEGDqJ5YwDCs07DiBA,1237
86
86
  dissect/target/loaders/local.py,sha256=Ul-LCd_fY7SyWOVR6nH-NqbkuNpxoZVmffwrkvQElU8,16453
87
87
  dissect/target/loaders/log.py,sha256=cCkDIRS4aPlX3U-n_jUKaI2FPSV3BDpfqKceaU7rBbo,1507
88
- dissect/target/loaders/mqtt.py,sha256=b0VrQ75_tmc4POkcfnUwKJoj1qmcjm1OKsVBQ9MjgqI,9552
88
+ dissect/target/loaders/mqtt.py,sha256=D8AmdOz2atD92z8bhjVFi3tC1H7pYmP4UrOCtMgfwMY,10396
89
89
  dissect/target/loaders/multiraw.py,sha256=4a3ZST0NwjnfPDxHkcEfAcX2ddUlT_C-rcrMHNg1wp4,1046
90
90
  dissect/target/loaders/ova.py,sha256=6h4O-7i87J394C6KgLsPkdXRAKNwtPubzLNS3vBGs7U,744
91
91
  dissect/target/loaders/ovf.py,sha256=ELMq6J2y6cPKbp7pjWAqMMnFYefWxXNqzIiAQdvGGXQ,1061
@@ -163,7 +163,7 @@ dissect/target/plugins/filesystem/resolver.py,sha256=HfyASUFV4F9uD-yFXilFpPTORAs
163
163
  dissect/target/plugins/filesystem/walkfs.py,sha256=e8HEZcV5Wiua26FGWL3xgiQ_PIhcNvGI5KCdsAx2Nmo,2298
164
164
  dissect/target/plugins/filesystem/yara.py,sha256=q_pbrQArNaWP4ILRzK7VQhukIw16LhUvntoviHmZ38Q,2241
165
165
  dissect/target/plugins/filesystem/ntfs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
- dissect/target/plugins/filesystem/ntfs/mft.py,sha256=Za-fsTcKlAlhm9ugJlMdwsJVf2Osrh4PrEGSFuv-Eeo,9564
166
+ dissect/target/plugins/filesystem/ntfs/mft.py,sha256=AD3w2FIjDAf8x2KEbBhz2NeOA_lxIAmw353w6J3ObYU,9565
167
167
  dissect/target/plugins/filesystem/ntfs/mft_timeline.py,sha256=vvNFAZbr7s3X2OTYf4ES_L6-XsouTXcTymfxnHfZ1Rw,6791
168
168
  dissect/target/plugins/filesystem/ntfs/usnjrnl.py,sha256=uiT1ipmcAo__6VIUi8R_vvIu22vdnjMACKwLSAbzYjs,3704
169
169
  dissect/target/plugins/filesystem/ntfs/utils.py,sha256=xG7Lgw9NX4tDDrZVRm0vycFVJTOM7j-HrjqzDh0f4uA,3136
@@ -320,7 +320,7 @@ dissect/target/tools/fs.py,sha256=cizCrW8rqdpT1irA8g6mslkaXX7CynWVQ7fvRUrcxNU,37
320
320
  dissect/target/tools/info.py,sha256=3smHr8I71yj3kCjsQ5nXkOHI9T_N8UwvkVa1CNOxB-s,5461
321
321
  dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLcEg,4174
322
322
  dissect/target/tools/mount.py,sha256=L_0tSmiBdW4aSaF0vXjB0bAkTC0kmT2N1hrbW6s5Jow,3254
323
- dissect/target/tools/query.py,sha256=6zz9SXS6YnHj7eguORS8Je7N4iM0i1PZDIQ-gyJ1nPY,15593
323
+ dissect/target/tools/query.py,sha256=ONHu2FVomLccikb84qBrlhNmEfRoHYFQMcahk_y2c9A,15580
324
324
  dissect/target/tools/reg.py,sha256=FDsiBBDxjWVUBTRj8xn82vZe-J_d9piM-TKS3PHZCcM,3193
325
325
  dissect/target/tools/shell.py,sha256=4v6Z06YJDjKv6e6SRvWNjQ2n_KHo_CjL4P0w1_gY_ro,44827
326
326
  dissect/target/tools/utils.py,sha256=sQizexY3ui5vmWw4KOBLg5ecK3TPFjD-uxDqRn56ZTY,11304
@@ -336,10 +336,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
336
336
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
337
337
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
338
338
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
339
- dissect.target-3.17.dev27.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
- dissect.target-3.17.dev27.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
- dissect.target-3.17.dev27.dist-info/METADATA,sha256=3-kTMZehcHT31jjm50J9_Msj1Pw6LqWUMsiMaSaLiBY,11300
342
- dissect.target-3.17.dev27.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
- dissect.target-3.17.dev27.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
- dissect.target-3.17.dev27.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
- dissect.target-3.17.dev27.dist-info/RECORD,,
339
+ dissect.target-3.17.dev29.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
+ dissect.target-3.17.dev29.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
+ dissect.target-3.17.dev29.dist-info/METADATA,sha256=Wi4QRqrkL4L_LUjliqpshIGB5Z1cJMN_l9F1DFHY1Pc,11300
342
+ dissect.target-3.17.dev29.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
+ dissect.target-3.17.dev29.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
+ dissect.target-3.17.dev29.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
+ dissect.target-3.17.dev29.dist-info/RECORD,,