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

Fallback mount sysvol to C: if not mounted to another drive letter #671

Merged
merged 4 commits into from
Apr 9, 2024
Merged
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
9 changes: 9 additions & 0 deletions dissect/target/plugins/os/windows/_os.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import operator
import struct
from typing import Any, Iterator, Optional

Expand Down Expand Up @@ -77,6 +78,14 @@ def add_mounts(self) -> None:
self.target.log.warning("Failed to map drive letters")
self.target.log.debug("", exc_info=e)

# Fallback mount the sysvol to C: if we didn't manage to mount it to any other drive letter
if operator.countOf(self.target.fs.mounts.values(), self.target.fs.mounts["sysvol"]) == 1:
if "c:" not in self.target.fs.mounts:
self.target.log.debug("Unable to determine drive letter of sysvol, falling back to C:")
self.target.fs.mount("c:", self.target.fs.mounts["sysvol"])
else:
self.target.log.warning("Unknown drive letter for sysvol")

@export(property=True)
def hostname(self) -> Optional[str]:
key = "HKLM\\SYSTEM\\ControlSet001\\Control\\Computername\\Computername"
Expand Down