-
Notifications
You must be signed in to change notification settings - Fork 659
Creation of the Shutdown Plugin #1967
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
Open
Frascott05
wants to merge
11
commits into
volatilityfoundation:develop
Choose a base branch
from
Frascott05:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+127
−0
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8703ce9
Adding the Shutdown Plugin
Frascott05 d48a133
Merge branch 'volatilityfoundation:develop' into develop
Frascott05 3aaa229
Update volatility3/framework/plugins/windows/registry/shutdown.py
Frascott05 7d79096
Update volatility3/framework/plugins/windows/registry/shutdown.py
Frascott05 bffe5c4
Update volatility3/framework/plugins/windows/registry/shutdown.py
Frascott05 e8b1a78
Update shutdown.py
Frascott05 47b2a9d
Merge branch 'volatilityfoundation:develop' into develop
Frascott05 61a6ad9
Adding tests for the shutdown plugin
Frascott05 6f61f98
Refactor LastShutdown plugin for registry access
Frascott05 96c67c2
Clean up whitespace and comments in windows.py
Frascott05 ae8b2bd
Merge branch 'volatilityfoundation:develop' into develop
Frascott05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
volatility3/framework/plugins/windows/registry/shutdown.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import logging | ||
| import struct | ||
| from typing import Iterable, Optional | ||
|
|
||
| from volatility3.framework import interfaces, renderers, exceptions | ||
| from volatility3.framework.configuration import requirements | ||
| from volatility3.framework.layers import registry as registry_layer | ||
| from volatility3.framework.symbols.windows.extensions import registry | ||
| from volatility3.plugins.windows.registry import hivelist | ||
| from volatility3.framework.renderers import conversion | ||
|
|
||
| vollog = logging.getLogger(__name__) | ||
| class LastShutdown(interfaces.plugins.PluginInterface): | ||
| """Extract last Windows shutdown time from registry""" | ||
|
|
||
| _required_framework_version = (2, 0, 0) | ||
| _version = (1, 0, 0) | ||
|
|
||
| @classmethod | ||
| def get_requirements(cls): | ||
| return [ | ||
| requirements.ModuleRequirement( | ||
| name="kernel", | ||
| description="Windows kernel", | ||
| architectures=["Intel32", "Intel64"], | ||
| ), | ||
| requirements.VersionRequirement( | ||
| name="hivelist", | ||
| component=hivelist.HiveList, | ||
| version=(2, 0, 0), | ||
| ), | ||
| ] | ||
|
|
||
| @classmethod | ||
| def get_key( | ||
| cls, hive: registry_layer.RegistryHive, key_path: str | ||
| ) -> Optional["registry.CM_KEY_NODE"]: | ||
| try: | ||
| return hive.get_key(key_path) | ||
| except Exception: | ||
| return None | ||
|
|
||
| def _generator(self, syshive: registry_layer.RegistryHive) -> Iterable: | ||
|
|
||
| if not syshive: | ||
| return | ||
|
|
||
| # Windows systems typically maintain a small number of ControlSets | ||
| # (commonly 1–3, but occasionally more in recovery scenarios). | ||
| # We iterate over a bounded range to ensure we can recover shutdown | ||
| # time even if the active ControlSet cannot be determined via | ||
| # Select\\Current or if registry data is partially corrupted. | ||
| for i in range(1, 5): | ||
|
|
||
| key_path = f"ControlSet{i:03}\\Control\\Windows" | ||
|
|
||
| key = self.get_key(syshive, key_path) | ||
|
|
||
| if not key: | ||
| continue | ||
|
|
||
| for v in key.get_values(): | ||
|
|
||
| if v.get_name() == "ShutdownTime": | ||
|
|
||
| try: | ||
| data = syshive.read(v.Data + 4, v.DataLength) | ||
| except exceptions.InvalidAddressException: | ||
| continue | ||
|
|
||
| if not data or len(data) < 8: | ||
| continue | ||
|
|
||
| filetime = struct.unpack("<Q", data[:8])[0] | ||
| shutdown_time = conversion.wintime_to_datetime(filetime) | ||
|
|
||
| yield (0, (key_path, str(shutdown_time))) | ||
|
|
||
| def run(self): | ||
|
|
||
| syshive = None | ||
|
|
||
| for hive in hivelist.HiveList.list_hives( | ||
| context=self.context, | ||
| base_config_path=self.config_path, | ||
| kernel_module_name=self.config["kernel"], | ||
| ): | ||
|
|
||
| if hive.get_name().split("\\")[-1].upper() == "SYSTEM": | ||
| syshive = hive | ||
|
|
||
| return renderers.TreeGrid( | ||
| [ | ||
| ("Registry Key", str), | ||
| ("Last Shutdown Time", str), | ||
| ], | ||
| self._generator(syshive), | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.