dissect.target 3.17.dev20__py3-none-any.whl → 3.17.dev22__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
1
4
  import re
2
5
  from collections import defaultdict
3
6
  from configparser import ConfigParser, MissingSectionHeaderError
4
7
  from io import StringIO
5
8
  from re import compile, sub
6
- from typing import Any, Callable, Iterable, Match, Optional, Union
9
+ from typing import Any, Callable, Iterable, Match, Optional
7
10
 
8
11
  from defusedxml import ElementTree
9
12
 
@@ -11,6 +14,8 @@ from dissect.target.exceptions import PluginError
11
14
  from dissect.target.helpers.fsutil import TargetPath
12
15
  from dissect.target.target import Target
13
16
 
17
+ log = logging.getLogger(__name__)
18
+
14
19
  try:
15
20
  from ruamel.yaml import YAML
16
21
 
@@ -60,7 +65,7 @@ class Template:
60
65
  """
61
66
 
62
67
  if not path.exists() or path.is_dir():
63
- self.target.log.debug("Failed to get config file %s", path)
68
+ log.debug("Failed to get config file %s", path)
64
69
  config = None
65
70
 
66
71
  if self.name == "netplan":
@@ -85,7 +90,7 @@ class Template:
85
90
  if HAS_YAML:
86
91
  return self.parser(path.open("rb"))
87
92
  else:
88
- self.target.log.error("Failed to parse %s. Cannot import ruamel.yaml", self.name)
93
+ log.error("Failed to parse %s. Cannot import ruamel.yaml", self.name)
89
94
  return None
90
95
 
91
96
  def _parse_wicked_config(self, path: TargetPath) -> dict:
@@ -278,7 +283,7 @@ class Parser:
278
283
  if option in translation_values and value:
279
284
  return translation_key
280
285
 
281
- def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Union[str, Callable]:
286
+ def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Optional[str | Callable]:
282
287
  """Internal function to get arbitrary options values from a parsed (non-translated) dictionary.
283
288
 
284
289
  Args:
@@ -289,8 +294,13 @@ class Parser:
289
294
  Returns:
290
295
  Value(s) corrensponding to that network configuration option.
291
296
  """
297
+ if not config:
298
+ log.error("Cannot get option %s: No config to parse", option)
299
+ return
300
+
292
301
  if section:
293
- config = config[section]
302
+ config = config.get(section, {})
303
+
294
304
  for key, value in config.items():
295
305
  if key == option:
296
306
  return value
@@ -364,7 +374,7 @@ class NetworkManager:
364
374
  if self.registered:
365
375
  self.config = self.parser.parse()
366
376
  else:
367
- self.target.log.error("Network manager %s is not registered. Cannot parse config.", self.name)
377
+ log.error("Network manager %s is not registered. Cannot parse config.", self.name)
368
378
 
369
379
  @property
370
380
  def interface(self) -> set:
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import operator
3
4
  import struct
4
5
  from typing import Any, Iterator, Optional
5
6
 
@@ -77,6 +78,14 @@ class WindowsPlugin(OSPlugin):
77
78
  self.target.log.warning("Failed to map drive letters")
78
79
  self.target.log.debug("", exc_info=e)
79
80
 
81
+ # Fallback mount the sysvol to C: if we didn't manage to mount it to any other drive letter
82
+ if operator.countOf(self.target.fs.mounts.values(), self.target.fs.mounts["sysvol"]) == 1:
83
+ if "c:" not in self.target.fs.mounts:
84
+ self.target.log.debug("Unable to determine drive letter of sysvol, falling back to C:")
85
+ self.target.fs.mount("c:", self.target.fs.mounts["sysvol"])
86
+ else:
87
+ self.target.log.warning("Unknown drive letter for sysvol")
88
+
80
89
  @export(property=True)
81
90
  def hostname(self) -> Optional[str]:
82
91
  key = "HKLM\\SYSTEM\\ControlSet001\\Control\\Computername\\Computername"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.17.dev20
3
+ Version: 3.17.dev22
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
@@ -57,7 +57,7 @@ dissect/target/helpers/loaderutil.py,sha256=kiyMWra_gVxfNSGwLlgxLcuuqAYuCMDc5NiC
57
57
  dissect/target/helpers/localeutil.py,sha256=Y4Fh4jDSGfm5356xSLMriUCN8SZP_FAHg_iodkAxNq4,1504
58
58
  dissect/target/helpers/mount.py,sha256=JxhUYyEbDnHfzPpfuWy4nV9OwCJPoDSGdHHNiyvd_l0,3949
59
59
  dissect/target/helpers/mui.py,sha256=i-7XoHbu4WO2fYapK9yGAMW04rFlgRispknc1KQIS5Q,22258
60
- dissect/target/helpers/network_managers.py,sha256=FSFYVuHsOzxLc68_LTzfFUd3IIBQQpI7rJRwTg7xznQ,24494
60
+ dissect/target/helpers/network_managers.py,sha256=OgrYhbBqM6K5OfUnCdTLG0RBrR-DcpR1CPezbNddK7k,24667
61
61
  dissect/target/helpers/polypath.py,sha256=h8p7m_OCNiQljGwoZh5Aflr9H2ot6CZr6WKq1OSw58o,2175
62
62
  dissect/target/helpers/protobuf.py,sha256=NwKrZD4q9v7J8GnZX9gbzMUMV5pR78eAV17jgWOz_EY,1730
63
63
  dissect/target/helpers/record.py,sha256=lWl7k2Mp9Axllm0tXzPGJx2zj2zONsyY_p5g424T0Lc,4826
@@ -250,7 +250,7 @@ dissect/target/plugins/os/unix/log/lastlog.py,sha256=eL_dbB1sPoy0tyavIjT457ZLVfX
250
250
  dissect/target/plugins/os/unix/log/messages.py,sha256=W3CeI0tchdRql9SKLFDxk9AKwUvqIrnpCujcERvDt90,2846
251
251
  dissect/target/plugins/os/unix/log/utmp.py,sha256=21tvzG977LqzRShV6uAoU-83WDcLUrI_Tv__2ZVi9rw,7756
252
252
  dissect/target/plugins/os/windows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
253
- dissect/target/plugins/os/windows/_os.py,sha256=6jfMa7T7uo_1fDGjffFtU4UjxKI1ynjciwmsKWiJGEU,12050
253
+ dissect/target/plugins/os/windows/_os.py,sha256=EA9B9Rgb1C9NMvlX3gXhTRFXYaI6zrrKRg0OYq4v1ts,12589
254
254
  dissect/target/plugins/os/windows/activitiescache.py,sha256=yY41YdCZk9e97Q8_rjZHknMUeOVDxgBG9VtXQHANUsQ,6710
255
255
  dissect/target/plugins/os/windows/adpolicy.py,sha256=rvsvywChfms7d2kMwXRVHZaf8zJ46WmMwYplGAYEax8,6984
256
256
  dissect/target/plugins/os/windows/amcache.py,sha256=ZZNOs3bILTf0AGkDkhoatndl0j39DXkstN7oOyxJECU,27188
@@ -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.dev20.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
- dissect.target-3.17.dev20.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
- dissect.target-3.17.dev20.dist-info/METADATA,sha256=w19ITKpjeWu52HPdEU4SD_axvpgGpBr8_nsETBOLeEw,11300
342
- dissect.target-3.17.dev20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
- dissect.target-3.17.dev20.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
- dissect.target-3.17.dev20.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
- dissect.target-3.17.dev20.dist-info/RECORD,,
339
+ dissect.target-3.17.dev22.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
+ dissect.target-3.17.dev22.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
+ dissect.target-3.17.dev22.dist-info/METADATA,sha256=cN-xuf_ljLS_FB73b9J8PW4bUT5KvBbk13pEIPNl430,11300
342
+ dissect.target-3.17.dev22.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
+ dissect.target-3.17.dev22.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
+ dissect.target-3.17.dev22.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
+ dissect.target-3.17.dev22.dist-info/RECORD,,