From 9e6987ca3fc6216ea3e2f2097140c1ac07aff6ad Mon Sep 17 00:00:00 2001 From: Austin Gibbons Date: Wed, 19 Jun 2024 14:59:24 -0400 Subject: [PATCH] Switch ufs to loopback and limit volume index recursion. --- imagemounter_mitre/filesystems.py | 15 ++++++++++++++- imagemounter_mitre/volume_system.py | 17 +++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/imagemounter_mitre/filesystems.py b/imagemounter_mitre/filesystems.py index b4cea0f..d6a1421 100644 --- a/imagemounter_mitre/filesystems.py +++ b/imagemounter_mitre/filesystems.py @@ -339,7 +339,8 @@ class ExtFileSystem(MountFileSystem): _mount_opts = 'noexec,noload' -class UfsFileSystem(MountFileSystem): +class UfsFileSystem(LoopbackFileSystemMixin, MountFileSystem): + type = 'ufs' aliases = ['4.2bsd', 'ufs2', 'ufs 2'] # TODO: support for other ufstypes @@ -354,6 +355,18 @@ def detect(cls, source, description): res.update({cls: -20, VolumeSystemFileSystem: 20}) return res + def mount(self): + try: + self._make_mountpoint() + self._find_loopback() + _util.check_call_(['mount', '-t', 'ufs', '-o', f'ufstype=ufs2,offset={self.volume.parent.offset}', + self.loopback, self.mountpoint], stdout=subprocess.PIPE) + return + except Exception: + self._free_loopback() + self._clear_mountpoint() + raise + class NtfsFileSystem(MountFileSystem): type = 'ntfs' diff --git a/imagemounter_mitre/volume_system.py b/imagemounter_mitre/volume_system.py index e93c8e6..771832b 100644 --- a/imagemounter_mitre/volume_system.py +++ b/imagemounter_mitre/volume_system.py @@ -452,12 +452,17 @@ def detect(self, volume_system, vstype='detect'): if len(values) > 5: description = values[5] - volume = volume_system._make_subvolume( - index=self._format_index(volume_system, int(index[:-1])), - offset=int(start) * volume_system.disk.block_size, - size=int(length) * volume_system.disk.block_size - ) - volume.info['fsdescription'] = description + index = self._format_index(volume_system, int(index[:-1])) + volume = None + if index.count('.') < 2: + volume = volume_system._make_subvolume( + index=index, + offset=int(start) * volume_system.disk.block_size, + size=int(length) * volume_system.disk.block_size + ) + volume.info['fsdescription'] = description + else: + continue except Exception: logger.exception("Error while parsing mmls output") continue