Skip to content

Commit 6b21bdf

Browse files
Politie-SOCMiauwkeru
authored andcommitted
Prevent fake NTFS filesystem mounts
1 parent 6e90da6 commit 6b21bdf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dissect/target/tools/mount.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ def main() -> int:
8080
vnames.setdefault(basename, []).append(v)
8181
vfs.map_file_fh(f"volumes/{fname}", v)
8282

83+
fake_ntfs = set()
8384
for i, fs in enumerate(t.filesystems):
85+
ntfs_obj = getattr(fs, "ntfs", None)
86+
87+
if ntfs_obj in fake_ntfs:
88+
continue
89+
90+
if ntfs_obj and fs.__type__ != "ntfs":
91+
# A non ntfs filesystem with a "ntfs" object means that add_virtual_ntfs_filesystem was used.
92+
# The fake ntfs object is added to the filesystem after its parent.
93+
# We will mount an entry in filesystems/ for the virtual filesystem, not for the "fake" ntfs filesystem.
94+
fake_ntfs.add(ntfs_obj)
95+
8496
volumes = fs.volume if isinstance(fs.volume, list) else [fs.volume]
8597
for volume in volumes:
8698
default_name = f"fs_{i}"

0 commit comments

Comments
 (0)