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

Switch ufs to loopback and limit volume index recursion. #5

Merged
merged 1 commit into from
Jun 26, 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
15 changes: 14 additions & 1 deletion imagemounter_mitre/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
17 changes: 11 additions & 6 deletions imagemounter_mitre/volume_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading