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

Make adding virtual NTFS filesystem more resilient #691

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 26 additions & 3 deletions dissect/target/helpers/loaderutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,32 @@ def add_virtual_ntfs_filesystem(
fh_sds = _try_open(fs, sds_path)

if any([fh_boot, fh_mft]):
ntfs = NtfsFilesystem(boot=fh_boot, mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
target.filesystems.add(ntfs)
fs.ntfs = ntfs.ntfs
ntfs = None

try:
ntfs = NtfsFilesystem(boot=fh_boot, mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
except Exception as e:
if fh_boot:
message = "Failed to load NTFS filesystem from %s, retrying without $Boot file"
else:
message = "Failed to load NTFS filesystem from %s, skipping"

log.warning(message, fs)
log.debug("", exc_info=e)

if fh_boot:
try:
# Try once more without the $Boot file
ntfs = NtfsFilesystem(mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
except Exception:
log.warning("Failed to load NTFS filesystem from %s without $Boot file, skipping", fs)

# Only add it if we have a valid NTFS with an MFT
if ntfs and ntfs.ntfs.mft:
target.filesystems.add(ntfs)
fs.ntfs = ntfs.ntfs
else:
log.warning("Failed to load NTFS filesystem from %s, skipping", fs)


def _try_open(fs: Filesystem, path: str) -> BinaryIO:
Expand Down