dissect.target 3.18.dev10__py3-none-any.whl → 3.18.dev12__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,77 @@
1
+ import fnmatch
2
+ import logging
3
+ import re
4
+ from pathlib import Path
5
+ from typing import Iterator
6
+
7
+ from dissect.target import Target
8
+ from dissect.target.helpers.record import TargetRecordDescriptor
9
+ from dissect.target.plugin import arg, export
10
+ from dissect.target.plugins.general.config import (
11
+ ConfigurationEntry,
12
+ ConfigurationTreePlugin,
13
+ )
14
+
15
+ UnixConfigTreeRecord = TargetRecordDescriptor(
16
+ "unix/config",
17
+ [
18
+ ("path", "source"),
19
+ ("path", "path"),
20
+ ("string", "key"),
21
+ ("string[]", "value"),
22
+ ],
23
+ )
24
+
25
+ log = logging.getLogger(__name__)
26
+
27
+
28
+ class EtcTree(ConfigurationTreePlugin):
29
+ __namespace__ = "etc"
30
+
31
+ def __init__(self, target: Target):
32
+ super().__init__(target, "/etc")
33
+
34
+ def _sub(self, items: ConfigurationEntry, entry: Path, pattern: str) -> Iterator[UnixConfigTreeRecord]:
35
+ index = 0
36
+ config_entry = items
37
+ if not isinstance(items, dict):
38
+ items = items.as_dict()
39
+
40
+ for raw_key, value in items.items():
41
+ key = re.sub(r"[\n\r\t]", "", raw_key)
42
+ path = Path(entry) / Path(key)
43
+
44
+ if isinstance(value, dict):
45
+ yield from self._sub(value, path, pattern)
46
+ continue
47
+
48
+ if not isinstance(value, list):
49
+ value = [str(value)]
50
+
51
+ if fnmatch.fnmatch(path, pattern):
52
+ data = {
53
+ "_target": self.target,
54
+ "source": self.target.fs.path(config_entry.entry.path),
55
+ "path": path,
56
+ "key": key,
57
+ "value": value,
58
+ }
59
+ if value == [""]:
60
+ data["key"] = index
61
+ data["value"] = [key]
62
+ index += 1
63
+
64
+ yield UnixConfigTreeRecord(**data)
65
+
66
+ @export(record=UnixConfigTreeRecord)
67
+ @arg("--glob", dest="pattern", required=False, default="*", type=str, help="Glob-style pattern to search for")
68
+ def etc(self, pattern: str) -> Iterator[UnixConfigTreeRecord]:
69
+ for entry, subs, items in self.config_fs.walk("/"):
70
+ for item in items:
71
+ try:
72
+ config_object = self.get(str(Path(entry) / Path(item)))
73
+ if isinstance(config_object, ConfigurationEntry):
74
+ yield from self._sub(config_object, Path(entry) / Path(item), pattern)
75
+ except Exception:
76
+ log.warning("Could not open configuration item: %s", item)
77
+ pass
@@ -21,7 +21,7 @@ class WindowsPlugin(OSPlugin):
21
21
  self.add_mounts()
22
22
 
23
23
  target.props["sysvol_drive"] = next(
24
- (mnt for mnt, fs in target.fs.mounts.items() if fs is target.fs.mounts["sysvol"] and mnt != "sysvol"),
24
+ (mnt for mnt, fs in target.fs.mounts.items() if fs is target.fs.mounts.get("sysvol") and mnt != "sysvol"),
25
25
  None,
26
26
  )
27
27
 
@@ -78,13 +78,16 @@ class WindowsPlugin(OSPlugin):
78
78
  self.target.log.warning("Failed to map drive letters")
79
79
  self.target.log.debug("", exc_info=e)
80
80
 
81
+ sysvol_drive = self.target.fs.mounts.get("sysvol")
81
82
  # 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 sysvol_drive and operator.countOf(self.target.fs.mounts.values(), sysvol_drive) == 1:
83
84
  if "c:" not in self.target.fs.mounts:
84
85
  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
+ self.target.fs.mount("c:", sysvol_drive)
86
87
  else:
87
88
  self.target.log.warning("Unknown drive letter for sysvol")
89
+ else:
90
+ self.target.log.warning("No sysvol drive found")
88
91
 
89
92
  @export(property=True)
90
93
  def hostname(self) -> Optional[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.18.dev10
3
+ Version: 3.18.dev12
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
@@ -209,6 +209,8 @@ dissect/target/plugins/os/unix/bsd/osx/_os.py,sha256=KvP7YJ7apVwoIop7MR-8q5QbVGo
209
209
  dissect/target/plugins/os/unix/bsd/osx/user.py,sha256=qopB0s3n7e6Q7NjWzn8Z-dKtDtU7e6In4Vm7hIvvedo,2322
210
210
  dissect/target/plugins/os/unix/esxi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
211
211
  dissect/target/plugins/os/unix/esxi/_os.py,sha256=8kFFK9986zN8hXmDUWwdQHtbV33nWKerRuisg_xbsoQ,17504
212
+ dissect/target/plugins/os/unix/etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
+ dissect/target/plugins/os/unix/etc/etc.py,sha256=ZyuMfP1QKA2_l8XQVu5CLex049MVFre3Yru5otiAqpE,2531
212
214
  dissect/target/plugins/os/unix/linux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
215
  dissect/target/plugins/os/unix/linux/_os.py,sha256=YJYwuq_iAinOrPqTE49Q4DLYMWBeRCly1uTbDvPhp6Q,2796
214
216
  dissect/target/plugins/os/unix/linux/cmdline.py,sha256=AyMfndt3UsmJtoOyZYC8nWq2GZg9oPvn8SiI3M4NxnE,1622
@@ -253,7 +255,7 @@ dissect/target/plugins/os/unix/log/lastlog.py,sha256=Wq89wRSFZSBsoKVCxjDofnC4yw9
253
255
  dissect/target/plugins/os/unix/log/messages.py,sha256=CXA-SkMPLaCgnTQg9nzII-7tO8Il_ENQmuYvDxo33rI,4698
254
256
  dissect/target/plugins/os/unix/log/utmp.py,sha256=1nPHIaBUHt_9z6PDrvyqg4huKLihUaWLrMmgMsbaeIo,7755
255
257
  dissect/target/plugins/os/windows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
256
- dissect/target/plugins/os/windows/_os.py,sha256=g5XGtruvyWx4YAhMpGZnAaIFWQqLNQpee_Ot7ROmD8w,12606
258
+ dissect/target/plugins/os/windows/_os.py,sha256=i9RPs99YD3KvZpAHAIuaQeGDy0nt5DIvfMbreqO_JIY,12723
257
259
  dissect/target/plugins/os/windows/activitiescache.py,sha256=Q2aILnhJ2rp2AwEbWwyBuSLjMbGqaYJTsavSbfkcFKE,6741
258
260
  dissect/target/plugins/os/windows/adpolicy.py,sha256=fULRFO_I_QxAn6G9SCwlLL-TLVliS13JEGnGotf7lSA,6983
259
261
  dissect/target/plugins/os/windows/amcache.py,sha256=ZZNOs3bILTf0AGkDkhoatndl0j39DXkstN7oOyxJECU,27188
@@ -343,10 +345,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
343
345
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
344
346
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
345
347
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
346
- dissect.target-3.18.dev10.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
347
- dissect.target-3.18.dev10.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
348
- dissect.target-3.18.dev10.dist-info/METADATA,sha256=ccY-AXd6JQ_QbmuIHLJAyNRoeb8aWmrL8zSVqZqUNGg,12723
349
- dissect.target-3.18.dev10.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
350
- dissect.target-3.18.dev10.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
351
- dissect.target-3.18.dev10.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
352
- dissect.target-3.18.dev10.dist-info/RECORD,,
348
+ dissect.target-3.18.dev12.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
349
+ dissect.target-3.18.dev12.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
350
+ dissect.target-3.18.dev12.dist-info/METADATA,sha256=oWwEEHk6AHCEQn67G19XvZrlpWcdxNUTlHh025msebE,12723
351
+ dissect.target-3.18.dev12.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
352
+ dissect.target-3.18.dev12.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
353
+ dissect.target-3.18.dev12.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
354
+ dissect.target-3.18.dev12.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.0)
2
+ Generator: setuptools (70.1.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5