Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError in syscache plugin #913

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dissect/target/plugins/os/windows/syscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def syscache(self) -> Iterator[SyscacheRecord]:
full_path = None
if mft:
try:
full_path = self.target.fs.path("\\".join(["sysvol", mft.mft(file_segment).fullpath()]))
if path := mft(file_segment).full_path():
full_path = self.target.fs.path("\\".join(["sysvol", path]))
except ntfs.Error:
pass

Expand Down
3 changes: 3 additions & 0 deletions tests/_data/plugins/os/windows/syscache/Syscache-mft.hve
Git LFS file not shown
22 changes: 22 additions & 0 deletions tests/plugins/os/windows/test_syscache.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dissect.target.filesystems.ntfs import NtfsFilesystem
from dissect.target.plugins.os.windows.syscache import SyscachePlugin
from tests._utils import absolute_path

Expand All @@ -10,3 +11,24 @@ def test_syscache_plugin(target_win, fs_win):

results = list(target_win.syscache())
assert len(results) == 401


def test_syscache_plugin_real_mft(target_win, fs_win):
filesystem = NtfsFilesystem(mft=open(absolute_path("_data/plugins/filesystem/ntfs/mft/mft.raw"), "rb"))

# We need to change the type of the mocked filesystem, since syscache.py checks for explicit value
target_win.fs.mounts["sysvol"].__type__ = "ntfs"
target_win.fs.mounts["sysvol"].ntfs = filesystem.ntfs

syscache_file = absolute_path("_data/plugins/os/windows/syscache/Syscache-mft.hve")
fs_win.map_file("System Volume Information/Syscache.hve", syscache_file)

target_win.add_plugin(SyscachePlugin)

results = list(target_win.syscache())
assert len(results) == 401

filepaths = [entry.path for entry in results]
assert filepaths.count(None) == 399
assert "sysvol\\NamelessDirectory\\totally_normal.txt" in filepaths
assert "sysvol\\text_document.txt" in filepaths
Loading