dissect.target 3.20.2.dev17__py3-none-any.whl → 3.20.2.dev19__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -125,7 +125,7 @@ class CredHistFile:
125
125
  yield CredHistEntry(
126
126
  version=entry.dwVersion,
127
127
  guid=UUID(bytes_le=entry.guidLink),
128
- user_sid=read_sid(entry.pSid),
128
+ user_sid=read_sid(entry.pSid) if entry.pSid else None,
129
129
  hash_alg=HashAlgorithm.from_id(entry.algHash),
130
130
  cipher_alg=cipher_alg,
131
131
  sha1=None,
@@ -611,11 +611,12 @@ class GenericPlugin(Plugin):
611
611
 
612
612
  try:
613
613
  key = self.target.registry.key("HKLM\\SECURITY\\Policy\\PolMachineAccountS")
614
+ raw_sid = key.value("(Default)").value
614
615
 
615
616
  yield ComputerSidRecord(
616
617
  ts=key.timestamp,
617
618
  sidtype="Domain",
618
- sid=read_sid(key.value("(Default)").value),
619
+ sid=read_sid(raw_sid) if raw_sid else None,
619
620
  _target=self.target,
620
621
  )
621
622
  except (RegistryError, struct.error):
@@ -0,0 +1,118 @@
1
+ from typing import Iterator
2
+
3
+ from dissect.util.ts import wintimestamp
4
+ from flow.record.fieldtypes import windows_path
5
+
6
+ from dissect.target.exceptions import UnsupportedPluginError
7
+ from dissect.target.helpers.descriptor_extensions import (
8
+ RegistryRecordDescriptorExtension,
9
+ UserRecordDescriptorExtension,
10
+ )
11
+ from dissect.target.helpers.record import create_extended_descriptor
12
+ from dissect.target.helpers.regutil import RegistryKey, RegistryValueNotFoundError
13
+ from dissect.target.plugin import Plugin, export
14
+ from dissect.target.target import Target
15
+
16
+ CamRecord = create_extended_descriptor([RegistryRecordDescriptorExtension, UserRecordDescriptorExtension])(
17
+ "windows/registry/cam",
18
+ [
19
+ ("datetime", "ts"),
20
+ ("string", "device"),
21
+ ("string", "app_name"),
22
+ ("path", "path"),
23
+ ("datetime", "last_started"),
24
+ ("datetime", "last_stopped"),
25
+ ("varint", "duration"),
26
+ ],
27
+ )
28
+
29
+
30
+ class CamPlugin(Plugin):
31
+ """Plugin that iterates various Capability Access Manager registry key locations."""
32
+
33
+ CONSENT_STORES = [
34
+ "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\CapabilityAccessManager\\ConsentStore",
35
+ "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\CapabilityAccessManager\\ConsentStore",
36
+ ]
37
+
38
+ def __init__(self, target: Target):
39
+ super().__init__(target)
40
+ self.app_regf_keys = self._find_apps()
41
+
42
+ def _find_apps(self) -> list[RegistryKey]:
43
+ apps = []
44
+ for store in self.target.registry.keys(self.CONSENT_STORES):
45
+ for key in store.subkeys():
46
+ apps.append(key)
47
+
48
+ return apps
49
+
50
+ def check_compatible(self) -> None:
51
+ if not self.app_regf_keys:
52
+ raise UnsupportedPluginError("No Capability Access Manager keys found")
53
+
54
+ def yield_apps(self) -> Iterator[RegistryKey]:
55
+ for app in self.app_regf_keys:
56
+ for key in app.subkeys():
57
+ if key.name == "NonPackaged": # NonPackaged registry key has more apps, so yield those apps
58
+ yield from key.subkeys()
59
+ else:
60
+ yield key
61
+
62
+ @export(record=CamRecord)
63
+ def cam(self) -> Iterator[CamRecord]:
64
+ """Iterate Capability Access Manager key locations.
65
+
66
+ The Capability Access Manager keeps track of processes that access I/O devices, like the webcam or microphone.
67
+ Applications are divided into packaged and non-packaged applications meaning Microsoft or
68
+ non-Microsoft applications.
69
+
70
+ References:
71
+ - https://docs.velociraptor.app/exchange/artifacts/pages/windows.registry.capabilityaccessmanager/
72
+ - https://svch0st.medium.com/can-you-track-processes-accessing-the-camera-and-microphone-7e6885b37072
73
+
74
+ Yields ``CamRecord`` with the following fields:
75
+
76
+ .. code-block:: text
77
+
78
+ hostname (string): The target hostname.
79
+ domain (string): The target domain.
80
+ ts (datetime): The modification timestamp of the registry key.
81
+ device (string): Name of the device privacy permission where asked for.
82
+ app_name (string): The name of the application.
83
+ path (path): The possible path to the application.
84
+ last_started (datetime): When the application last started using the device.
85
+ last_stopped (datetime): When the application last stopped using the device.
86
+ duration (datetime): How long the application used the device (seconds).
87
+ """
88
+
89
+ for key in self.yield_apps():
90
+ last_started = None
91
+ last_stopped = None
92
+ duration = None
93
+
94
+ try:
95
+ last_started = wintimestamp(key.value("LastUsedTimeStart").value)
96
+ except RegistryValueNotFoundError:
97
+ self.target.log.warning("No LastUsedTimeStart for application: %s", key.name)
98
+
99
+ try:
100
+ last_stopped = wintimestamp(key.value("LastUsedTimeStop").value)
101
+ except RegistryValueNotFoundError:
102
+ self.target.log.warning("No LastUsedTimeStop for application: %s", key.name)
103
+
104
+ if last_started and last_stopped:
105
+ duration = (last_stopped - last_started).seconds
106
+
107
+ yield CamRecord(
108
+ ts=key.ts,
109
+ device=key.path.split("\\")[-2],
110
+ app_name=key.name,
111
+ path=windows_path(key.name.replace("#", "\\")) if "#" in key.name else None,
112
+ last_started=last_started,
113
+ last_stopped=last_stopped,
114
+ duration=duration,
115
+ _target=self.target,
116
+ _key=key,
117
+ _user=self.target.registry.get_user(key),
118
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dissect.target
3
- Version: 3.20.2.dev17
3
+ Version: 3.20.2.dev19
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
@@ -287,7 +287,7 @@ dissect/target/plugins/os/windows/clfs.py,sha256=begVsZ-CY97Ksh6S1g03LjyBgu8ERY2
287
287
  dissect/target/plugins/os/windows/datetime.py,sha256=YKHUZU6lkKJocq15y0yCwvIIOb1Ej-kfvEBmHbrdIGw,9467
288
288
  dissect/target/plugins/os/windows/defender.py,sha256=JAJy8hr6jFGd290N1d5a-bVeD8rHc6E_pWEHxTpiMDk,32735
289
289
  dissect/target/plugins/os/windows/env.py,sha256=U5D74i_7tICxGDanqDU42Jqsx0asFFMIs6SpUwTnJc4,13884
290
- dissect/target/plugins/os/windows/generic.py,sha256=RJ1znzsIa4CFxmdMh91SjMY_pnjwxvldlTEKo58m_e8,24262
290
+ dissect/target/plugins/os/windows/generic.py,sha256=6jNRUrbvME3P7amvs3FxCuEtK7FLO2kiaNstAPv0JS8,24313
291
291
  dissect/target/plugins/os/windows/jumplist.py,sha256=3gZk6O1B3lKK2Jxe0B-HapOCEehk94CYNvCVDpQC9nQ,11773
292
292
  dissect/target/plugins/os/windows/lnk.py,sha256=AvqVmvP-QWHPKEI49hP-JeOVSI2R3Vxpy-lpfT70pSg,8097
293
293
  dissect/target/plugins/os/windows/locale.py,sha256=QiLWGgWrGBGHiXgep5iSOo6VNim4YC-xd4MdW0BUJPA,2486
@@ -306,7 +306,7 @@ dissect/target/plugins/os/windows/ual.py,sha256=S43ltndKKrs2SqeDLgZv4dzdqtJD8c3Y
306
306
  dissect/target/plugins/os/windows/wer.py,sha256=y4ZU6Yai53UsZ4VLr0V9_uLhZJZ_UEtdPuNzxKbGoEY,9269
307
307
  dissect/target/plugins/os/windows/wua_history.py,sha256=QNtOQNZWKsKyUUrUV8aeoAMDKoH-ERkLx8ahnJzpHCY,54783
308
308
  dissect/target/plugins/os/windows/credential/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
309
- dissect/target/plugins/os/windows/credential/credhist.py,sha256=YSjuyd53Augdy_lKKzZHtx5Ozt0HzF6LDYIOb-8P1Pw,7058
309
+ dissect/target/plugins/os/windows/credential/credhist.py,sha256=MBpnVycpQTbjD1THb5MbpKSBFYs8g8l1gCP68VamkIk,7082
310
310
  dissect/target/plugins/os/windows/credential/lsa.py,sha256=bo5zS4gDvMDU0c4456ZJ4FrDkcTnWdpmLaQZnZ33_fI,5638
311
311
  dissect/target/plugins/os/windows/credential/sam.py,sha256=iRqMNPLqrObJG2h6brzvAyeVBnIIgHVX_p_Hw_Jfa3A,15599
312
312
  dissect/target/plugins/os/windows/defender_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -339,6 +339,7 @@ dissect/target/plugins/os/windows/regf/applications.py,sha256=AZwaLXsVmqMjoZYI3d
339
339
  dissect/target/plugins/os/windows/regf/appxdebugkeys.py,sha256=X8MYLcD76pIZoIWwS_DgUp6q6pi2WO7jhZeoc4uGLak,3966
340
340
  dissect/target/plugins/os/windows/regf/auditpol.py,sha256=vTqWw0_vu9p_emWC8FuYcYQpOXhEFQQDLV0K6-18i9c,5208
341
341
  dissect/target/plugins/os/windows/regf/bam.py,sha256=jJ0i-82uteBU0hPgs81f8NV8NCeRtIklK82Me2S_ro0,2131
342
+ dissect/target/plugins/os/windows/regf/cam.py,sha256=e0y4mhWBfgMIRvOxybLFGZ3ztH3tyqvv5wY5uVEDatI,4717
342
343
  dissect/target/plugins/os/windows/regf/cit.py,sha256=WYuwzTJKSR8Ki0582zpTpRUApx_J3OIYFWivKgqH-Is,39178
343
344
  dissect/target/plugins/os/windows/regf/clsid.py,sha256=ellokL8H7TR8XkGqqWraJ3bL0qP5RJrjNsp4JeBLU7A,3810
344
345
  dissect/target/plugins/os/windows/regf/firewall.py,sha256=86JvlBc418nHB5l3IkbEnTw6zr-H5pEGEoZ8fBhmeLE,3231
@@ -383,10 +384,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
383
384
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
384
385
  dissect/target/volumes/md.py,sha256=7ShPtusuLGaIv27SvEETtgsuoQyAa4iAAeOR1NEaajI,1689
385
386
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
386
- dissect.target-3.20.2.dev17.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
387
- dissect.target-3.20.2.dev17.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
388
- dissect.target-3.20.2.dev17.dist-info/METADATA,sha256=3Zv71EoGm3Np-VOObIAcfDmZYOheFzB1Qtne5bvskj8,13184
389
- dissect.target-3.20.2.dev17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
390
- dissect.target-3.20.2.dev17.dist-info/entry_points.txt,sha256=yQwLCWUuzHgS6-sfCcRk66gAfoCfqXdCjqKjvhnQW8o,537
391
- dissect.target-3.20.2.dev17.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
392
- dissect.target-3.20.2.dev17.dist-info/RECORD,,
387
+ dissect.target-3.20.2.dev19.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
388
+ dissect.target-3.20.2.dev19.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
389
+ dissect.target-3.20.2.dev19.dist-info/METADATA,sha256=-4siqHElFX4TAmQ403qAyFwVMdhU1UPquE_a68cW0LU,13184
390
+ dissect.target-3.20.2.dev19.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
391
+ dissect.target-3.20.2.dev19.dist-info/entry_points.txt,sha256=yQwLCWUuzHgS6-sfCcRk66gAfoCfqXdCjqKjvhnQW8o,537
392
+ dissect.target-3.20.2.dev19.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
393
+ dissect.target-3.20.2.dev19.dist-info/RECORD,,