dissect.target 3.19.dev57__py3-none-any.whl → 3.20__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. dissect/target/container.py +1 -1
  2. dissect/target/exceptions.py +6 -5
  3. dissect/target/filesystem.py +2 -2
  4. dissect/target/filesystems/btrfs.py +14 -5
  5. dissect/target/filesystems/config.py +5 -1
  6. dissect/target/filesystems/extfs.py +5 -4
  7. dissect/target/filesystems/fat.py +22 -16
  8. dissect/target/filesystems/ffs.py +11 -4
  9. dissect/target/filesystems/jffs.py +12 -7
  10. dissect/target/filesystems/ntfs.py +22 -6
  11. dissect/target/filesystems/overlay.py +14 -4
  12. dissect/target/filesystems/smb.py +3 -3
  13. dissect/target/filesystems/squashfs.py +4 -4
  14. dissect/target/filesystems/vmfs.py +4 -4
  15. dissect/target/filesystems/xfs.py +15 -8
  16. dissect/target/helpers/compat/path_common.py +5 -5
  17. dissect/target/helpers/configutil.py +128 -32
  18. dissect/target/helpers/cyber.py +2 -0
  19. dissect/target/helpers/data/windowsZones.xml +19 -23
  20. dissect/target/helpers/docs.py +1 -1
  21. dissect/target/helpers/keychain.py +2 -0
  22. dissect/target/helpers/mount.py +2 -1
  23. dissect/target/helpers/record.py +29 -2
  24. dissect/target/helpers/record_modifier.py +5 -1
  25. dissect/target/helpers/regutil.py +56 -26
  26. dissect/target/loader.py +1 -1
  27. dissect/target/loaders/mqtt.py +104 -9
  28. dissect/target/loaders/proxmox.py +68 -0
  29. dissect/target/loaders/vma.py +1 -1
  30. dissect/target/loaders/xva.py +1 -1
  31. dissect/target/plugin.py +24 -21
  32. dissect/target/plugins/apps/av/mcafee.py +2 -0
  33. dissect/target/plugins/apps/av/sophos.py +2 -0
  34. dissect/target/plugins/apps/av/trendmicro.py +2 -0
  35. dissect/target/plugins/apps/browser/chromium.py +27 -6
  36. dissect/target/plugins/apps/container/docker.py +48 -32
  37. dissect/target/plugins/apps/editor/__init__.py +0 -0
  38. dissect/target/plugins/apps/editor/editor.py +23 -0
  39. dissect/target/plugins/apps/{texteditor → editor}/windowsnotepad.py +40 -31
  40. dissect/target/plugins/apps/other/__init__.py +0 -0
  41. dissect/target/plugins/apps/other/env.py +56 -0
  42. dissect/target/plugins/apps/shell/powershell.py +6 -2
  43. dissect/target/plugins/apps/shell/wget.py +91 -0
  44. dissect/target/plugins/apps/ssh/openssh.py +2 -0
  45. dissect/target/plugins/apps/ssh/opensshd.py +2 -0
  46. dissect/target/plugins/apps/virtualization/__init__.py +0 -0
  47. dissect/target/plugins/apps/virtualization/vmware_workstation.py +61 -0
  48. dissect/target/plugins/apps/vpn/wireguard.py +9 -9
  49. dissect/target/plugins/apps/webhosting/cpanel.py +2 -0
  50. dissect/target/plugins/apps/webserver/caddy.py +2 -0
  51. dissect/target/plugins/apps/webserver/nginx.py +2 -0
  52. dissect/target/plugins/child/esxi.py +3 -1
  53. dissect/target/plugins/child/parallels.py +68 -0
  54. dissect/target/plugins/child/proxmox.py +23 -0
  55. dissect/target/plugins/child/virtuozzo.py +12 -8
  56. dissect/target/plugins/child/vmware_workstation.py +23 -8
  57. dissect/target/plugins/filesystem/acquire_hash.py +2 -1
  58. dissect/target/plugins/filesystem/icat.py +15 -11
  59. dissect/target/plugins/filesystem/ntfs/mft.py +10 -6
  60. dissect/target/plugins/filesystem/ntfs/mft_timeline.py +3 -1
  61. dissect/target/plugins/filesystem/ntfs/usnjrnl.py +2 -0
  62. dissect/target/plugins/filesystem/ntfs/utils.py +3 -1
  63. dissect/target/plugins/filesystem/unix/suid.py +4 -1
  64. dissect/target/plugins/filesystem/walkfs.py +2 -0
  65. dissect/target/plugins/general/example.py +2 -2
  66. dissect/target/plugins/general/loaders.py +18 -5
  67. dissect/target/plugins/general/network.py +20 -5
  68. dissect/target/plugins/general/osinfo.py +1 -0
  69. dissect/target/plugins/general/plugins.py +53 -10
  70. dissect/target/plugins/os/unix/_os.py +70 -44
  71. dissect/target/plugins/os/unix/applications.py +78 -0
  72. dissect/target/plugins/os/unix/bsd/citrix/history.py +2 -0
  73. dissect/target/plugins/os/unix/bsd/osx/_os.py +4 -21
  74. dissect/target/plugins/os/unix/bsd/osx/network.py +92 -0
  75. dissect/target/plugins/os/unix/bsd/osx/user.py +4 -0
  76. dissect/target/plugins/os/unix/cronjobs.py +8 -4
  77. dissect/target/plugins/os/unix/etc/etc.py +4 -0
  78. dissect/target/plugins/os/unix/generic.py +2 -0
  79. dissect/target/plugins/os/unix/history.py +27 -25
  80. dissect/target/plugins/os/unix/linux/_os.py +8 -10
  81. dissect/target/plugins/os/unix/linux/cmdline.py +2 -0
  82. dissect/target/plugins/os/unix/linux/debian/apt.py +4 -1
  83. dissect/target/plugins/os/unix/linux/debian/dpkg.py +3 -3
  84. dissect/target/plugins/os/unix/linux/debian/proxmox/__init__.py +0 -0
  85. dissect/target/plugins/os/unix/linux/debian/proxmox/_os.py +141 -0
  86. dissect/target/plugins/os/unix/linux/debian/proxmox/vm.py +29 -0
  87. dissect/target/plugins/os/unix/linux/debian/snap.py +79 -0
  88. dissect/target/plugins/os/unix/linux/environ.py +2 -0
  89. dissect/target/plugins/os/unix/linux/fortios/_os.py +74 -63
  90. dissect/target/plugins/os/unix/linux/fortios/generic.py +2 -0
  91. dissect/target/plugins/os/unix/linux/fortios/locale.py +2 -0
  92. dissect/target/plugins/os/unix/linux/modules.py +2 -0
  93. dissect/target/plugins/os/unix/linux/netstat.py +2 -0
  94. dissect/target/{helpers → plugins/os/unix/linux}/network_managers.py +11 -9
  95. dissect/target/plugins/os/unix/linux/processes.py +2 -0
  96. dissect/target/plugins/os/unix/linux/redhat/yum.py +4 -1
  97. dissect/target/plugins/os/unix/linux/services.py +5 -3
  98. dissect/target/plugins/os/unix/linux/sockets.py +2 -0
  99. dissect/target/plugins/os/unix/linux/suse/zypper.py +4 -1
  100. dissect/target/plugins/os/unix/locale.py +2 -0
  101. dissect/target/plugins/os/unix/locate/gnulocate.py +4 -2
  102. dissect/target/plugins/os/unix/locate/mlocate.py +2 -0
  103. dissect/target/plugins/os/unix/locate/plocate.py +3 -1
  104. dissect/target/plugins/os/unix/log/atop.py +2 -0
  105. dissect/target/plugins/os/unix/log/audit.py +3 -1
  106. dissect/target/plugins/os/unix/log/auth.py +351 -38
  107. dissect/target/plugins/os/unix/log/journal.py +123 -101
  108. dissect/target/plugins/os/unix/log/lastlog.py +5 -3
  109. dissect/target/plugins/os/unix/log/messages.py +51 -27
  110. dissect/target/plugins/os/unix/log/utmp.py +52 -71
  111. dissect/target/plugins/os/unix/packagemanager.py +5 -38
  112. dissect/target/plugins/os/unix/shadow.py +3 -1
  113. dissect/target/plugins/os/unix/trash.py +132 -0
  114. dissect/target/plugins/os/windows/_os.py +22 -41
  115. dissect/target/plugins/os/windows/activitiescache.py +9 -4
  116. dissect/target/plugins/os/windows/adpolicy.py +2 -1
  117. dissect/target/plugins/os/windows/amcache.py +16 -13
  118. dissect/target/plugins/os/windows/defender.py +4 -3
  119. dissect/target/plugins/os/windows/dpapi/keyprovider/credhist.py +3 -0
  120. dissect/target/plugins/os/windows/dpapi/keyprovider/empty.py +3 -0
  121. dissect/target/plugins/os/windows/dpapi/keyprovider/keychain.py +3 -0
  122. dissect/target/plugins/os/windows/dpapi/keyprovider/lsa.py +3 -0
  123. dissect/target/plugins/os/windows/env.py +1 -2
  124. dissect/target/plugins/os/windows/exchange/exchange.py +6 -4
  125. dissect/target/plugins/os/windows/generic.py +68 -19
  126. dissect/target/plugins/os/windows/lnk.py +2 -0
  127. dissect/target/plugins/os/windows/locale.py +9 -3
  128. dissect/target/plugins/os/windows/log/etl.py +5 -4
  129. dissect/target/plugins/os/windows/log/evt.py +12 -8
  130. dissect/target/plugins/os/windows/log/evtx.py +9 -7
  131. dissect/target/plugins/os/windows/log/mssql.py +103 -0
  132. dissect/target/plugins/os/windows/log/pfro.py +2 -1
  133. dissect/target/plugins/os/windows/network.py +380 -0
  134. dissect/target/plugins/os/windows/notifications.py +6 -4
  135. dissect/target/plugins/os/windows/prefetch.py +7 -2
  136. dissect/target/plugins/os/windows/regf/7zip.py +9 -1
  137. dissect/target/plugins/os/windows/regf/applications.py +62 -0
  138. dissect/target/plugins/os/windows/regf/auditpol.py +2 -1
  139. dissect/target/plugins/os/windows/regf/bam.py +3 -1
  140. dissect/target/plugins/os/windows/regf/cit.py +14 -12
  141. dissect/target/plugins/os/windows/regf/clsid.py +6 -3
  142. dissect/target/plugins/os/windows/regf/firewall.py +2 -1
  143. dissect/target/plugins/os/windows/regf/mru.py +9 -8
  144. dissect/target/plugins/os/windows/regf/nethist.py +6 -3
  145. dissect/target/plugins/os/windows/regf/recentfilecache.py +3 -1
  146. dissect/target/plugins/os/windows/regf/regf.py +5 -1
  147. dissect/target/plugins/os/windows/regf/shellbags.py +351 -345
  148. dissect/target/plugins/os/windows/regf/shimcache.py +1 -1
  149. dissect/target/plugins/os/windows/regf/usb.py +2 -1
  150. dissect/target/plugins/os/windows/regf/userassist.py +2 -1
  151. dissect/target/plugins/os/windows/registry.py +11 -0
  152. dissect/target/plugins/os/windows/services.py +3 -2
  153. dissect/target/plugins/os/windows/startupinfo.py +7 -2
  154. dissect/target/plugins/os/windows/syscache.py +5 -2
  155. dissect/target/plugins/os/windows/tasks.py +1 -1
  156. dissect/target/plugins/os/windows/thumbcache.py +11 -5
  157. dissect/target/plugins/os/windows/ual.py +12 -9
  158. dissect/target/plugins/os/windows/wer.py +21 -6
  159. dissect/target/plugins/os/windows/wua_history.py +0 -1
  160. dissect/target/target.py +13 -8
  161. dissect/target/tools/dump/utils.py +4 -0
  162. dissect/target/tools/fsutils.py +1 -1
  163. dissect/target/tools/info.py +1 -1
  164. dissect/target/tools/mount.py +15 -5
  165. dissect/target/tools/query.py +15 -9
  166. dissect/target/tools/shell.py +98 -9
  167. dissect/target/tools/utils.py +7 -7
  168. dissect/target/volume.py +4 -4
  169. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/METADATA +6 -2
  170. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/RECORD +176 -160
  171. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/WHEEL +1 -1
  172. dissect/target/helpers/targetd.py +0 -58
  173. dissect/target/loaders/targetd.py +0 -223
  174. dissect/target/plugins/apps/texteditor/texteditor.py +0 -13
  175. dissect/target/plugins/os/unix/etc.py +0 -9
  176. /dissect/target/plugins/apps/{texteditor → database}/__init__.py +0 -0
  177. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/COPYRIGHT +0 -0
  178. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/LICENSE +0 -0
  179. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/entry_points.txt +0 -0
  180. {dissect.target-3.19.dev57.dist-info → dissect.target-3.20.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,7 @@ import json
4
4
  import logging
5
5
  import re
6
6
  from pathlib import Path
7
- from typing import Iterator, Optional
7
+ from typing import Iterator
8
8
 
9
9
  from dissect.cstruct import cstruct
10
10
  from dissect.util import ts
@@ -128,12 +128,17 @@ class DockerPlugin(Plugin):
128
128
  for data_root in self.installs:
129
129
  images_path = data_root.joinpath("image/overlay2/repositories.json")
130
130
 
131
- if images_path.exists():
132
- repositories = json.loads(images_path.read_text()).get("Repositories")
133
- else:
131
+ if not images_path.exists():
134
132
  self.target.log.debug("No docker images found, file %s does not exist.", images_path)
135
133
  continue
136
134
 
135
+ try:
136
+ repositories = json.loads(images_path.read_text()).get("Repositories", {})
137
+ except (json.JSONDecodeError, UnicodeDecodeError) as e:
138
+ self.target.log.warning("Unable to parse JSON in: %s", images_path)
139
+ self.target.log.debug("", exc_info=e)
140
+ continue
141
+
137
142
  for name, tags in repositories.items():
138
143
  for tag, hash in tags.items():
139
144
  image_metadata_path = data_root.joinpath(
@@ -142,8 +147,12 @@ class DockerPlugin(Plugin):
142
147
  created = None
143
148
 
144
149
  if image_metadata_path.exists():
145
- image_metadata = json.loads(image_metadata_path.read_text())
146
- created = convert_timestamp(image_metadata.get("created"))
150
+ try:
151
+ image_metadata = json.loads(image_metadata_path.read_text())
152
+ created = convert_timestamp(image_metadata.get("created"))
153
+ except (json.JSONDecodeError, UnicodeDecodeError) as e:
154
+ self.target.log.warning("Unable to parse JSON in: %s", image_metadata_path)
155
+ self.target.log.debug("", exc_info=e)
147
156
 
148
157
  yield DockerImageRecord(
149
158
  name=name,
@@ -160,47 +169,51 @@ class DockerPlugin(Plugin):
160
169
 
161
170
  for data_root in self.installs:
162
171
  for config_path in data_root.joinpath("containers").glob("**/config.v2.json"):
163
- config = json.loads(config_path.read_text())
172
+ try:
173
+ config = json.loads(config_path.read_text())
174
+ except (json.JSONDecodeError, UnicodeDecodeError) as e:
175
+ self.target.log.warning("Unable to parse JSON in file: %s", config_path)
176
+ self.target.log.debug("", exc_info=e)
177
+ continue
178
+
164
179
  container_id = config.get("ID")
165
180
 
166
181
  # determine state
167
- running = config.get("State").get("Running")
182
+ running = config.get("State", {}).get("Running")
168
183
  if running:
169
- ports = config.get("NetworkSettings").get("Ports", {})
170
- pid = config.get("Pid")
171
- else:
172
- ports = config.get("Config").get("ExposedPorts", {})
173
- pid = None
184
+ ports = config.get("NetworkSettings", {}).get("Ports", {})
185
+
186
+ if not running or not ports:
187
+ ports = config.get("Config", {}).get("ExposedPorts", {})
174
188
 
175
189
  # parse volumes
176
190
  volumes = []
177
- if mount_points := config.get("MountPoints"):
178
- for mp in mount_points:
179
- mount_point = mount_points[mp]
191
+ if mount_points := config.get("MountPoints", {}):
192
+ for mount_point in mount_points.values():
180
193
  volumes.append(f"{mount_point.get('Source')}:{mount_point.get('Destination')}")
181
194
 
182
195
  # determine mount point
183
196
  mount_path = None
184
- if config.get("Driver") == "overlay2":
197
+ if container_id and config.get("Driver") == "overlay2":
185
198
  mount_path = data_root.joinpath("image/overlay2/layerdb/mounts", container_id)
186
199
  if not mount_path.exists():
187
- self.target.log.warning("Overlay2 mount path for container %s does not exist!", container_id)
200
+ self.target.log.warning("Overlay2 mount path does not exist for container: %s", container_id)
188
201
 
189
202
  else:
190
- self.target.log.warning("Encountered unsupported container filesystem %s", config.get("Driver"))
203
+ self.target.log.warning("Encountered unsupported container filesystem: %s", config.get("Driver"))
191
204
 
192
205
  yield DockerContainerRecord(
193
206
  container_id=container_id,
194
- image=config.get("Config").get("Image"),
195
- image_id=config.get("Image").split(":")[-1],
196
- command=config.get("Config").get("Cmd"),
207
+ image=config.get("Config", {}).get("Image"),
208
+ image_id=config.get("Image", "").split(":")[-1],
209
+ command=f"{config.get('Path', '')} {' '.join(config.get('Args', []))}".strip(),
197
210
  created=convert_timestamp(config.get("Created")),
198
211
  running=running,
199
- pid=pid,
200
- started=convert_timestamp(config.get("State").get("StartedAt")),
201
- finished=convert_timestamp(config.get("State").get("FinishedAt")),
212
+ pid=config.get("State", {}).get("Pid"),
213
+ started=convert_timestamp(config.get("State", {}).get("StartedAt")),
214
+ finished=convert_timestamp(config.get("State", {}).get("FinishedAt")),
202
215
  ports=convert_ports(ports),
203
- names=config.get("Name").replace("/", "", 1),
216
+ names=config.get("Name", "").replace("/", "", 1),
204
217
  volumes=volumes,
205
218
  mount_path=mount_path,
206
219
  config_path=config_path,
@@ -288,19 +301,19 @@ class DockerPlugin(Plugin):
288
301
  for line in open_decompress(path, "rt"):
289
302
  try:
290
303
  entry = json.loads(line)
291
- except json.JSONDecodeError as e:
292
- self.target.log.warning("Could not decode JSON line in file %s", path)
304
+ except (json.JSONDecodeError, UnicodeDecodeError) as e:
305
+ self.target.log.warning("Could not decode JSON line in file: %s", path)
293
306
  self.target.log.debug("", exc_info=e)
294
307
  continue
295
308
  yield entry
296
309
 
297
310
 
298
- def get_data_path(path: Path) -> Optional[str]:
311
+ def get_data_path(path: Path) -> str | None:
299
312
  """Returns the configured Docker daemon data-root path."""
300
313
  try:
301
314
  config = json.loads(path.open("rt").read())
302
- except json.JSONDecodeError as e:
303
- log.warning("Could not read JSON file '%s'", path)
315
+ except (json.JSONDecodeError, UnicodeDecodeError) as e:
316
+ log.warning("Could not read JSON file: %s", path)
304
317
  log.debug(exc_info=e)
305
318
 
306
319
  return config.get("data-root")
@@ -341,7 +354,7 @@ def find_installs(target: Target) -> Iterator[Path]:
341
354
  yield data_root_path
342
355
 
343
356
 
344
- def convert_timestamp(timestamp: str) -> str:
357
+ def convert_timestamp(timestamp: str | None) -> str:
345
358
  """Docker sometimes uses (unpadded) 9 digit nanosecond precision
346
359
  in their timestamp logs, eg. "2022-12-19T13:37:00.123456789Z".
347
360
 
@@ -350,6 +363,9 @@ def convert_timestamp(timestamp: str) -> str:
350
363
  compatbility with the 6 digit %f microsecond directive.
351
364
  """
352
365
 
366
+ if not timestamp:
367
+ return
368
+
353
369
  timestamp_nanoseconds_plus_postfix = timestamp[19:]
354
370
  match = RE_DOCKER_NS.match(timestamp_nanoseconds_plus_postfix)
355
371
 
File without changes
@@ -0,0 +1,23 @@
1
+ from dissect.target.plugin import NamespacePlugin, export
2
+
3
+ COMMON_EDITOR_FIELDS = [
4
+ ("datetime", "ts"),
5
+ ("string", "editor"),
6
+ ("path", "source"),
7
+ ]
8
+
9
+
10
+ class EditorPlugin(NamespacePlugin):
11
+ """Editor plugin."""
12
+
13
+ __namespace__ = "editor"
14
+
15
+ @export
16
+ def extensions(self) -> None:
17
+ """Yields installed extensions."""
18
+ raise NotImplementedError
19
+
20
+ @export
21
+ def history(self) -> None:
22
+ """Yields history of files."""
23
+ raise NotImplementedError
@@ -16,11 +16,8 @@ from dissect.target.helpers.record import (
16
16
  WindowsUserRecord,
17
17
  create_extended_descriptor,
18
18
  )
19
- from dissect.target.plugin import export
20
- from dissect.target.plugins.apps.texteditor.texteditor import (
21
- GENERIC_TAB_CONTENTS_RECORD_FIELDS,
22
- TexteditorPlugin,
23
- )
19
+ from dissect.target.plugin import alias, export
20
+ from dissect.target.plugins.apps.editor.editor import COMMON_EDITOR_FIELDS, EditorPlugin
24
21
  from dissect.target.target import Target
25
22
 
26
23
  # Thanks to @Nordgaren, @daddycocoaman, @JustArion and @ogmini for their suggestions and feedback in the PR
@@ -94,16 +91,25 @@ struct options_v2 {
94
91
  };
95
92
  """
96
93
 
97
- WINDOWS_SAVED_TABS_EXTRA_FIELDS = [("datetime", "modification_time"), ("digest", "hashes"), ("path", "saved_path")]
94
+ GENERIC_TAB_CONTENTS_RECORD_FIELDS = [
95
+ ("string", "content"),
96
+ ("path", "path"),
97
+ ("string", "deleted_content"),
98
+ ]
98
99
 
99
100
  WindowsNotepadUnsavedTabRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
100
- "texteditor/windowsnotepad/tab/unsaved",
101
- GENERIC_TAB_CONTENTS_RECORD_FIELDS,
101
+ "application/editor/windowsnotepad/tab/unsaved",
102
+ COMMON_EDITOR_FIELDS + GENERIC_TAB_CONTENTS_RECORD_FIELDS,
102
103
  )
103
104
 
104
105
  WindowsNotepadSavedTabRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
105
- "texteditor/windowsnotepad/tab/saved",
106
- GENERIC_TAB_CONTENTS_RECORD_FIELDS + WINDOWS_SAVED_TABS_EXTRA_FIELDS,
106
+ "application/editor/windowsnotepad/tab/saved",
107
+ COMMON_EDITOR_FIELDS
108
+ + GENERIC_TAB_CONTENTS_RECORD_FIELDS
109
+ + [
110
+ ("digest", "digest"),
111
+ ("path", "saved_path"),
112
+ ],
107
113
  )
108
114
 
109
115
  c_windowstab = cstruct().load(windowstab_def)
@@ -264,7 +270,7 @@ class WindowsNotepadTab:
264
270
  self.deleted_content = deleted_content if deleted_content else None
265
271
 
266
272
 
267
- class WindowsNotepadPlugin(TexteditorPlugin):
273
+ class WindowsNotepadPlugin(EditorPlugin):
268
274
  """Windows notepad tab content plugin."""
269
275
 
270
276
  __namespace__ = "windowsnotepad"
@@ -273,28 +279,27 @@ class WindowsNotepadPlugin(TexteditorPlugin):
273
279
 
274
280
  def __init__(self, target: Target):
275
281
  super().__init__(target)
276
- self.users_tabs: list[TargetPath, UnixUserRecord | WindowsUserRecord] = []
282
+ self.users_tabs: set[TargetPath, UnixUserRecord | WindowsUserRecord] = set()
277
283
  for user_details in self.target.user_details.all_with_home():
278
284
  for tab_file in user_details.home_path.glob(self.GLOB):
279
- # These files seem to contain information on different settings / configurations,
280
- # and are skipped for now
285
+ # These files contain information on different settings / configurations, and are skipped for now.
281
286
  if tab_file.name.endswith(".1.bin") or tab_file.name.endswith(".0.bin"):
282
287
  continue
283
288
 
284
- self.users_tabs.append((tab_file, user_details.user))
289
+ self.users_tabs.add((tab_file, user_details.user))
285
290
 
286
291
  def check_compatible(self) -> None:
287
292
  if not self.users_tabs:
288
293
  raise UnsupportedPluginError("No Windows Notepad tab files found")
289
294
 
295
+ @alias("tabs")
290
296
  @export(record=[WindowsNotepadSavedTabRecord, WindowsNotepadUnsavedTabRecord])
291
- def tabs(self) -> Iterator[WindowsNotepadSavedTabRecord | WindowsNotepadUnsavedTabRecord]:
297
+ def history(self) -> Iterator[WindowsNotepadSavedTabRecord | WindowsNotepadUnsavedTabRecord]:
292
298
  """Return contents from Windows 11 Notepad tabs - and its deleted content if available.
293
299
 
294
300
  Windows Notepad application for Windows 11 is now able to restore both saved and unsaved tabs when you re-open
295
301
  the application.
296
302
 
297
-
298
303
  Resources:
299
304
  - https://github.com/fox-it/dissect.target/pull/540
300
305
  - https://github.com/JustArion/Notepad-Tabs
@@ -304,37 +309,41 @@ class WindowsNotepadPlugin(TexteditorPlugin):
304
309
  - https://github.com/Nordgaren/tabstate-util/issues/1
305
310
  - https://medium.com/@mahmoudsoheem/new-digital-forensics-artifact-from-windows-notepad-527645906b7b
306
311
 
307
- Yields a WindowsNotepadSavedTabRecord or WindowsNotepadUnsavedTabRecord. with fields:
312
+ Yields ``WindowsNotepadSavedTabRecord`` or ``WindowsNotepadUnsavedTabRecord`` records:
308
313
 
309
314
  .. code-block:: text
310
315
 
311
- content (string): The content of the tab.
312
- path (path): The path to the tab file.
313
- deleted_content (string): The deleted content of the tab, if available.
314
- hashes (digest): A digest of the tab content.
315
- saved_path (path): The path where the tab was saved.
316
- modification_time (datetime): The modification time of the tab.
316
+ ts (datetime): The modification time of the tab.
317
+ content (string): The content of the tab.
318
+ path (path): The path to the tab file.
319
+ deleted_content (string): The deleted content of the tab, if available.
320
+ digest (digest): A digest of the tab content.
321
+ saved_path (path): The path where the tab was saved.
317
322
  """
318
323
  for file, user in self.users_tabs:
319
- # Parse the file
320
- tab: WindowsNotepadTab = WindowsNotepadTab(file)
324
+ tab = WindowsNotepadTab(file)
321
325
 
322
326
  if tab.is_saved:
323
327
  yield WindowsNotepadSavedTabRecord(
328
+ ts=wintimestamp(tab.tab_header.timestamp),
329
+ editor="windowsnotepad",
324
330
  content=tab.content,
325
331
  path=tab.file,
326
332
  deleted_content=tab.deleted_content,
327
- hashes=digest((None, None, tab.tab_header.sha256.hex())),
333
+ digest=digest((None, None, tab.tab_header.sha256.hex())),
328
334
  saved_path=tab.tab_header.filePath,
329
- modification_time=wintimestamp(tab.tab_header.timestamp),
330
- _target=self.target,
335
+ source=file,
331
336
  _user=user,
337
+ _target=self.target,
332
338
  )
339
+
333
340
  else:
334
341
  yield WindowsNotepadUnsavedTabRecord(
342
+ editor="windowsnotepad",
335
343
  content=tab.content,
344
+ deleted_content=tab.deleted_content,
336
345
  path=tab.file,
337
- _target=self.target,
346
+ source=file,
338
347
  _user=user,
339
- deleted_content=tab.deleted_content,
348
+ _target=self.target,
340
349
  )
File without changes
@@ -0,0 +1,56 @@
1
+ from typing import Iterator
2
+
3
+ from dissect.target.helpers.configutil import Env
4
+ from dissect.target.helpers.record import TargetRecordDescriptor
5
+ from dissect.target.plugin import Plugin, arg, export
6
+
7
+ EnvironmentFileRecord = TargetRecordDescriptor(
8
+ "application/other/file/environment",
9
+ [
10
+ ("datetime", "ts_mtime"),
11
+ ("string", "key"),
12
+ ("string", "value"),
13
+ ("string", "comment"),
14
+ ("path", "path"),
15
+ ],
16
+ )
17
+
18
+
19
+ class EnvironmentFilePlugin(Plugin):
20
+ """Environment file plugin."""
21
+
22
+ def check_compatible(self) -> None:
23
+ # `--env-path` is provided at runtime
24
+ pass
25
+
26
+ @export(record=EnvironmentFileRecord)
27
+ @arg("--env-path", help="path to scan environment files in")
28
+ @arg("--extension", help="extension of files to scan", default="env")
29
+ def envfile(self, env_path: str, extension: str = "env") -> Iterator[EnvironmentFileRecord]:
30
+ """Yield environment variables found in ``.env`` files at the provided path."""
31
+
32
+ if not env_path:
33
+ self.target.log.error("No ``--path`` provided!")
34
+
35
+ if not (path := self.target.fs.path(env_path)).exists():
36
+ self.target.log.error("Provided path %s does not exist!", path)
37
+
38
+ for file in path.glob("**/*." + extension):
39
+ if not file.is_file():
40
+ continue
41
+
42
+ mtime = file.lstat().st_mtime
43
+
44
+ with file.open("r") as fh:
45
+ parser = Env(comments=True)
46
+ parser.read_file(fh)
47
+
48
+ for key, (value, comment) in parser.parsed_data.items():
49
+ yield EnvironmentFileRecord(
50
+ ts_mtime=mtime,
51
+ key=key,
52
+ value=value,
53
+ comment=comment,
54
+ path=file,
55
+ _target=self.target,
56
+ )
@@ -1,3 +1,5 @@
1
+ from typing import Iterator
2
+
1
3
  from dissect.target.exceptions import UnsupportedPluginError
2
4
  from dissect.target.helpers.descriptor_extensions import UserRecordDescriptorExtension
3
5
  from dissect.target.helpers.record import create_extended_descriptor
@@ -14,6 +16,8 @@ ConsoleHostHistoryRecord = create_extended_descriptor([UserRecordDescriptorExten
14
16
 
15
17
 
16
18
  class PowerShellHistoryPlugin(Plugin):
19
+ """Windows PowerShell history plugin."""
20
+
17
21
  PATHS = [
18
22
  "AppData/Roaming/Microsoft/Windows/PowerShell/psreadline",
19
23
  ".local/share/powershell/PSReadLine",
@@ -35,10 +39,10 @@ class PowerShellHistoryPlugin(Plugin):
35
39
  raise UnsupportedPluginError("No ConsoleHost_history.txt files found")
36
40
 
37
41
  @export(record=ConsoleHostHistoryRecord)
38
- def powershell_history(self):
42
+ def powershell_history(self) -> Iterator[ConsoleHostHistoryRecord]:
39
43
  """Return PowerShell command history for all users.
40
44
 
41
- The PowerShell ConsoleHost_history.txt file contains information about the commands executed with PowerShell in
45
+ The PowerShell ``ConsoleHost_history.txt`` file contains information about the commands executed with PowerShell in
42
46
  a terminal. No data is recorded from terminal-less PowerShell sessions. Commands are saved to disk after the process has completed.
43
47
  PSReadLine does not save commands containing 'password', 'asplaintext', 'token', 'apikey' or 'secret'.
44
48
 
@@ -0,0 +1,91 @@
1
+ from typing import Iterator
2
+
3
+ from dissect.target.exceptions import UnsupportedPluginError
4
+ from dissect.target.helpers.descriptor_extensions import UserRecordDescriptorExtension
5
+ from dissect.target.helpers.fsutil import TargetPath
6
+ from dissect.target.helpers.record import create_extended_descriptor
7
+ from dissect.target.plugin import Plugin, export
8
+ from dissect.target.plugins.general.users import UserDetails
9
+ from dissect.target.target import Target
10
+
11
+ WgetHstsRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
12
+ "apps/shell/wget/hsts",
13
+ [
14
+ ("datetime", "ts_created"),
15
+ ("uri", "host"),
16
+ ("boolean", "explicit_port"),
17
+ ("boolean", "include_subdomains"),
18
+ ("datetime", "max_age"),
19
+ ("path", "source"),
20
+ ],
21
+ )
22
+
23
+
24
+ class WgetPlugin(Plugin):
25
+ """Wget shell plugin."""
26
+
27
+ __namespace__ = "wget"
28
+
29
+ def __init__(self, target: Target):
30
+ super().__init__(target)
31
+ self.artifacts = list(self._find_artifacts())
32
+
33
+ def _find_artifacts(self) -> Iterator[tuple[UserDetails, TargetPath]]:
34
+ for user_details in self.target.user_details.all_with_home():
35
+ if (hsts_file := user_details.home_path.joinpath(".wget-hsts")).exists():
36
+ yield hsts_file, user_details
37
+
38
+ def check_compatible(self) -> None:
39
+ if not self.artifacts:
40
+ raise UnsupportedPluginError("No .wget-hsts files found on target")
41
+
42
+ @export(record=WgetHstsRecord)
43
+ def hsts(self) -> Iterator[WgetHstsRecord]:
44
+ """Yield domain entries found in wget HSTS files.
45
+
46
+ When using the ``wget`` command-line utility, a file named ``.wget-hsts`` is created in the user's home
47
+ directory by default. The ``.wget-hsts`` file records HTTP Strict Transport Security (HSTS) information for the
48
+ websites visited by the user via ``wget``.
49
+
50
+ Resources:
51
+ - https://www.gnu.org/software/wget
52
+ - https://gitlab.com/gnuwget/wget/-/blob/master/src/hsts.c
53
+ - https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
54
+
55
+ Yields ``WgetHstsRecord`` records with the following fields:
56
+
57
+ .. code-block:: text
58
+
59
+ ts_created (datetime): When the host was first added to the HSTS file
60
+ host (uri): The host that was accessed over TLS by wget
61
+ explicit_port (boolean): If the TCP port for TLS should be checked
62
+ include_subdomains (boolean): If subdomains are included in the HSTS check
63
+ max_age (datetime): Time to live of the entry in the HSTS file
64
+ source (path): Location of the .wget-hsts file
65
+ """
66
+ for hsts_file, user_details in self.artifacts:
67
+ if not hsts_file.is_file():
68
+ continue
69
+
70
+ for line in hsts_file.open("rt").readlines():
71
+ if not (line := line.strip()) or line.startswith("#"):
72
+ continue
73
+
74
+ try:
75
+ host, port, subdomain_count, created, max_age = line.split("\t")
76
+
77
+ except ValueError as e:
78
+ self.target.log.warning("Unexpected wget hsts line in file: %s", hsts_file)
79
+ self.target.log.debug("", exc_info=e)
80
+ continue
81
+
82
+ yield WgetHstsRecord(
83
+ ts_created=int(created),
84
+ host=host,
85
+ explicit_port=int(port),
86
+ include_subdomains=int(subdomain_count),
87
+ max_age=int(created) + int(max_age),
88
+ source=hsts_file,
89
+ _user=user_details.user,
90
+ _target=self.target,
91
+ )
@@ -31,6 +31,8 @@ def find_sshd_directory(target: Target) -> TargetPath:
31
31
 
32
32
 
33
33
  class OpenSSHPlugin(SSHPlugin):
34
+ """OpenSSH plugin."""
35
+
34
36
  __namespace__ = "openssh"
35
37
 
36
38
  SSHD_DIRECTORIES = ["/sysvol/ProgramData/ssh", "/etc/ssh"]
@@ -74,6 +74,8 @@ SSHD_MULTIPLE_DEFINITIONS_ALLOWED_FIELDS = (
74
74
 
75
75
 
76
76
  class SSHServerPlugin(SSHPlugin):
77
+ """OpenSSHd server plugin."""
78
+
77
79
  __namespace__ = "opensshd"
78
80
 
79
81
  def __init__(self, target: Target):
File without changes
@@ -0,0 +1,61 @@
1
+ from typing import Iterator
2
+
3
+ from dissect.target.exceptions import UnsupportedPluginError
4
+ from dissect.target.helpers.descriptor_extensions import UserRecordDescriptorExtension
5
+ from dissect.target.helpers.fsutil import TargetPath
6
+ from dissect.target.helpers.record import create_extended_descriptor
7
+ from dissect.target.plugin import Plugin, alias, export
8
+ from dissect.target.plugins.general.users import UserDetails
9
+ from dissect.target.target import Target
10
+
11
+ VmwareDragAndDropRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
12
+ "virtualization/vmware/clipboard",
13
+ [
14
+ ("datetime", "ts"),
15
+ ("path", "path"),
16
+ ],
17
+ )
18
+
19
+ VMWARE_DND_PATHS = [
20
+ # Windows
21
+ "AppData/Local/Temp/VmwareDND",
22
+ # Linux
23
+ ".cache/vmware/drag_and_drop",
24
+ ]
25
+
26
+
27
+ class VmwareWorkstationPlugin(Plugin):
28
+ """VMware Workstation plugin."""
29
+
30
+ __namespace__ = "vmware"
31
+
32
+ def __init__(self, target: Target):
33
+ super().__init__(target)
34
+ self.dnd_dirs = list(self.find_dnd_dirs())
35
+
36
+ def check_compatible(self) -> None:
37
+ if not self.dnd_dirs:
38
+ raise UnsupportedPluginError("No VMware Workstation DnD artifact(s) found")
39
+
40
+ def find_dnd_dirs(self) -> Iterator[tuple[UserDetails, TargetPath]]:
41
+ for user_details in self.target.user_details.all_with_home():
42
+ for dnd_path in VMWARE_DND_PATHS:
43
+ if (dnd_dir := user_details.home_path.joinpath(dnd_path)).exists():
44
+ yield user_details, dnd_dir
45
+
46
+ @alias("draganddrop")
47
+ @export(record=VmwareDragAndDropRecord)
48
+ def clipboard(self) -> Iterator[VmwareDragAndDropRecord]:
49
+ """Yield cached VMware Workstation drag-and-drop file artifacts."""
50
+
51
+ for user_details, dnd_dir in self.dnd_dirs:
52
+ for file in dnd_dir.rglob("*/*"):
53
+ if file.is_dir():
54
+ continue
55
+
56
+ yield VmwareDragAndDropRecord(
57
+ ts=file.lstat().st_mtime,
58
+ path=file,
59
+ _user=user_details.user,
60
+ _target=self.target,
61
+ )
@@ -52,15 +52,13 @@ class WireGuardPlugin(Plugin):
52
52
 
53
53
  __namespace__ = "wireguard"
54
54
 
55
- """
56
- TODO: NetworkManager uses a different stanza format
57
- "/etc/NetworkManager/system-connections/Wireguard*",
58
- TODO: systemd uses a different stanza format
59
- "/etc/systemd/network/wg*.netdev",
60
- "/etc/systemd/network/*wg*.netdev",
61
- TODO: other locations such as $HOME/.config/wireguard
62
- TODO: parse native network manager formats from MacOS, Ubuntu and Windows.
63
- """
55
+ # TODO: NetworkManager uses a different stanza format
56
+ # "/etc/NetworkManager/system-connections/Wireguard*",
57
+ # TODO: systemd uses a different stanza format
58
+ # "/etc/systemd/network/wg*.netdev",
59
+ # "/etc/systemd/network/*wg*.netdev",
60
+ # TODO: other locations such as $HOME/.config/wireguard
61
+ # TODO: parse native network manager formats from MacOS, Ubuntu and Windows.
64
62
 
65
63
  CONFIG_GLOBS = [
66
64
  # Linux
@@ -160,6 +158,8 @@ def _parse_config(content: str) -> ConfigParser:
160
158
 
161
159
 
162
160
  class MultiDict(OrderedDict):
161
+ """OrderedDict implementation which allows multiple values for the keys ``Peer`` and ``Interface``."""
162
+
163
163
  def __init__(self, *args, **kwargs):
164
164
  self._unique = 0
165
165
  super().__init__(*args, **kwargs)
@@ -23,6 +23,8 @@ CPANEL_LASTLOGIN_PATTERN = re.compile(
23
23
 
24
24
 
25
25
  class CPanelPlugin(Plugin):
26
+ """cPanel webhosting plugin."""
27
+
26
28
  # TODO: Parse other log files https://support.cartika.com/portal/en/kb/articles/whm-cpanel-log-files-and-locations
27
29
  __namespace__ = "cpanel"
28
30
 
@@ -22,6 +22,8 @@ LOG_REGEX = re.compile(
22
22
 
23
23
 
24
24
  class CaddyPlugin(WebserverPlugin):
25
+ """Caddy webserver plugin."""
26
+
25
27
  __namespace__ = "caddy"
26
28
 
27
29
  def __init__(self, target: Target):
@@ -18,6 +18,8 @@ LOG_REGEX = re.compile(
18
18
 
19
19
 
20
20
  class NginxPlugin(WebserverPlugin):
21
+ """Nginx webserver plugin."""
22
+
21
23
  __namespace__ = "nginx"
22
24
 
23
25
  def __init__(self, target: Target):