Skip to content

Commit 4388f76

Browse files
authored
Improve cit plugin exception handling (#961)
1 parent f36ce59 commit 4388f76

File tree

1 file changed

+20
-7
lines changed
  • dissect/target/plugins/os/windows/regf

1 file changed

+20
-7
lines changed

dissect/target/plugins/os/windows/regf/cit.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,16 @@ def local_wintimestamp(target, ts):
632632
class CITPlugin(Plugin):
633633
"""Plugin that parses CIT data from the registry.
634634
635-
Reference:
636-
- https://dfir.ru/2018/12/02/the-cit-database-and-the-syscache-hive/
635+
References:
636+
- https://dfir.ru/2018/12/02/the-cit-database-and-the-syscache-hive/
637637
"""
638638

639639
__namespace__ = "cit"
640640

641641
KEY = "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\CIT"
642642

643643
def check_compatible(self) -> None:
644-
if not len(list(self.target.registry.keys(self.KEY))) > 0:
644+
if not list(self.target.registry.keys(self.KEY)):
645645
raise UnsupportedPluginError("No CIT registry key found")
646646

647647
@export(record=get_args(CITRecords))
@@ -770,8 +770,9 @@ def cit(self) -> Iterator[CITRecords]:
770770
yield from _yield_bitmap_records(
771771
self.target, cit, entry.use_data.bitmaps.foreground, CITProgramBitmapForegroundRecord
772772
)
773-
except Exception:
774-
self.target.log.exception("Failed to parse CIT value: %s", value.name)
773+
except Exception as e:
774+
self.target.log.warning("Failed to parse CIT value: %s", value.name)
775+
self.target.log.debug("", exc_info=e)
775776

776777
@export(record=CITPostUpdateUseInfoRecord)
777778
def puu(self) -> Iterator[CITPostUpdateUseInfoRecord]:
@@ -788,10 +789,16 @@ def puu(self) -> Iterator[CITPostUpdateUseInfoRecord]:
788789
for reg_key in keys:
789790
for key in self.target.registry.keys(reg_key):
790791
try:
791-
puu = c_cit.CIT_POST_UPDATE_USE_INFO(key.value("PUUActive").value)
792+
key_value = key.value("PUUActive").value
793+
puu = c_cit.CIT_POST_UPDATE_USE_INFO(key_value)
792794
except RegistryValueNotFoundError:
793795
continue
794796

797+
except EOFError as e:
798+
self.target.log.warning("Exception reading CIT structure in key %s", key.path)
799+
self.target.log.debug("Unable to parse value %s", key_value, exc_info=e)
800+
continue
801+
795802
yield CITPostUpdateUseInfoRecord(
796803
log_time_start=wintimestamp(puu.LogTimeStart),
797804
update_key=puu.UpdateKey,
@@ -852,10 +859,16 @@ def dp(self) -> Iterator[CITDPRecord | CITDPDurationRecord]:
852859
for reg_key in keys:
853860
for key in self.target.registry.keys(reg_key):
854861
try:
855-
dp = c_cit.CIT_DP_DATA(key.value("DP").value)
862+
key_value = key.value("DP").value
863+
dp = c_cit.CIT_DP_DATA(key_value)
856864
except RegistryValueNotFoundError:
857865
continue
858866

867+
except EOFError as e:
868+
self.target.log.warning("Exception reading CIT structure in key %s", key.path)
869+
self.target.log.debug("Unable to parse value %s", key_value, exc_info=e)
870+
continue
871+
859872
user = self.target.registry.get_user(key)
860873
log_time_start = wintimestamp(dp.LogTimeStart)
861874

0 commit comments

Comments
 (0)