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

Fixed support for unprivileged accounts for the SMB loader & minor bug fix #466

Merged
merged 9 commits into from
Dec 8, 2023
Merged

Fixed support for unprivileged accounts for the SMB loader & minor bug fix #466

merged 9 commits into from
Dec 8, 2023

Conversation

Paradoxis
Copy link
Contributor

@Paradoxis Paradoxis commented Dec 1, 2023

Fixed two bugs:

…returned by `detect()` due to an AttributeError: 'NoneType' object has no attribute 'get'
@Paradoxis
Copy link
Contributor Author

Important to note is that the registry still logs a verbose error, but it seems like intended behavior since it's logged explicitly.

2023-12-01T12:44:43.991136Z [warning  ] <Target .>: Failed to map drive letters [dissect.target.target] 
Traceback (most recent call last):
  File "dissect/target/plugins/os/windows/_os.py", line 52, in add_mounts
    for key in self.target.registry.keys("HKLM\\System\\MountedDevices"):
  File "dissect/target/plugins/os/windows/registry.py", line 296, in keys
    for key in self._iter_controlset_keypaths(keys):
  File "dissect/target/plugins/os/windows/registry.py", line 309, in _iter_controlset_keypaths
    if not self.controlsets or not CONTROLSET_REGEX.search(key):
           ^^^^^^^^^^^^^^^^
  File "dissect/target/plugins/os/windows/registry.py", line 206, in controlsets
    for key in self.key("HKLM\\SYSTEM").subkeys():
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "dissect/target/plugins/os/windows/registry.py", line 265, in key
    res = self._root.key(key)
          ^^^^^^^^^^^^^^^^^^^
  File "dissect/target/helpers/regutil.py", line 282, in key
    vkey = vkey.subkey(part)
           ^^^^^^^^^^^^^^^^^
  File "dissect/target/helpers/regutil.py", line 345, in subkey
    raise RegistryKeyNotFoundError(subkey)
dissect.target.exceptions.RegistryKeyNotFoundError: HKEY_LOCAL_MACHINE
Unknown-windows />

@Schamper
Copy link
Member

Schamper commented Dec 4, 2023

Important to note is that the registry still logs a verbose error, but it seems like intended behavior since it's logged explicitly.

That should probably be separated out into a log.warning for the message and a log.debug for the stacktrace.

@Paradoxis
Copy link
Contributor Author

Paradoxis commented Dec 4, 2023

@Schamper applied changes, although the stack trace originates from the windows plugin meaning it will still be printed as far as I know

@Schamper
Copy link
Member

Schamper commented Dec 4, 2023

@Schamper applied changes, although the stack trace originates from the windows plugin meaning it will still be printed as far as I know

You could change these lines: https://github.com/fox-it/dissect.target/blob/main/dissect/target/plugins/os/windows/_os.py#L80

self.target.log.warning("Failed to map drive letters")
self.target.log.debug("", exc_info=e)

@Paradoxis
Copy link
Contributor Author

@Schamper applied changes, although the stack trace originates from the windows plugin meaning it will still be printed as far as I know

You could change these lines: https://github.com/fox-it/dissect.target/blob/main/dissect/target/plugins/os/windows/_os.py#L80

self.target.log.warning("Failed to map drive letters")
self.target.log.debug("", exc_info=e)

Added :)

Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the CI errors?

@Paradoxis
Copy link
Contributor Author

Paradoxis commented Dec 7, 2023

Can you fix the CI errors?

@Schamper Fixed linting issues & added missing mock import

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (8674c31) 73.94% compared to head (c85ccf5) 73.93%.

Files Patch % Lines
dissect/target/loaders/smb.py 76.19% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
- Coverage   73.94%   73.93%   -0.02%     
==========================================
  Files         259      259              
  Lines       20878    20888      +10     
==========================================
+ Hits        15439    15444       +5     
- Misses       5439     5444       +5     
Flag Coverage Δ
unittests 73.93% <80.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Schamper Schamper merged commit 8bb86ca into fox-it:main Dec 8, 2023
JSCU-CNI pushed a commit to JSCU-CNI/dissect.target that referenced this pull request Jan 2, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SMB loader crashes on startup when using unprivileged accounts
2 participants