-
Notifications
You must be signed in to change notification settings - Fork 481
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
Linux - Boottime support #1317
Merged
ikelos
merged 17 commits into
volatilityfoundation:develop
from
gcmoreira:linux_boottime_support
Nov 8, 2024
Merged
Linux - Boottime support #1317
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
18f7f03
linux: fix datetime import and remove unused ones
gcmoreira f822468
linux: Implement boot time support in the Volatility 3 core framework
gcmoreira 69512dc
Linux: pslist: Add creation time column and timeline support to the l…
gcmoreira d25df23
Linux: pslist: Add the boottime plugin
gcmoreira 1651ecb
linux: boottime api: Fix explicit returns mixed with implicit (fall t…
gcmoreira 4895af4
Linux: Boottime timeliner: Rollback timeliner event type changes and …
gcmoreira c4274c9
Linux: Fix exception message in TimespecVol3::__sub__()
gcmoreira 57ffd5b
Linux: Boottime API: Refactor TimespecVol3::negate() to return a new …
gcmoreira bb6dc9a
Merge branch 'develop' into linux_boottime_support
gcmoreira bee2a39
Linux: Minor: Add comment/header on each set of constants
gcmoreira 42d918c
Linux: Boottime API: Refactor Timespec Methods.
gcmoreira 7abe92c
Linux: Boottime API: Minor. Move negate() up
gcmoreira e197fba
Linux: Boottime API: Refactor __sub__ to operate through __add__() an…
gcmoreira a05397e
Linux: Boottime API: Minor. Fix docstring typo
gcmoreira 2efb4e7
Merge branch 'develop' into linux_boottime_support
gcmoreira c0fa2cf
Linux: Boottime API: User linux_constanst import
gcmoreira f05a169
Merge branch 'develop' into linux_boottime_support
gcmoreira 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 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
This file contains 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 @@ | ||
# This file is Copyright 2024 Volatility Foundation and licensed under the Volatility Software License 1.0 | ||
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0 | ||
# | ||
import datetime | ||
from typing import List, Tuple, Iterable | ||
|
||
|
||
from volatility3.framework import interfaces, renderers | ||
from volatility3.framework.configuration import requirements | ||
from volatility3.plugins import timeliner | ||
from volatility3.plugins.linux import pslist | ||
|
||
|
||
class Boottime(interfaces.plugins.PluginInterface, timeliner.TimeLinerInterface): | ||
"""Shows the time the system was started""" | ||
|
||
_required_framework_version = (2, 11, 0) | ||
|
||
_version = (1, 0, 0) | ||
|
||
@classmethod | ||
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]: | ||
return [ | ||
requirements.ModuleRequirement( | ||
name="kernel", | ||
description="Linux kernel", | ||
architectures=["Intel32", "Intel64"], | ||
), | ||
requirements.PluginRequirement( | ||
name="pslist", plugin=pslist.PsList, version=(2, 3, 0) | ||
), | ||
] | ||
|
||
@classmethod | ||
def get_time_namespaces_bootime( | ||
cls, | ||
context: interfaces.context.ContextInterface, | ||
vmlinux_module_name: str, | ||
) -> Iterable[Tuple[int, int, int, str, datetime.datetime]]: | ||
"""Enumerates tasks' boot times based on their time namespaces. | ||
|
||
Args: | ||
context: The context to retrieve required elements (layers, symbol tables) from | ||
vmlinux_module_name: The name of the kernel module on which to operate | ||
pids: Pid list | ||
unique: Filter unique time namespaces | ||
|
||
Yields: | ||
A tuple with the fields to show in the plugin output. | ||
""" | ||
time_namespace_ids = set() | ||
for task in pslist.PsList.list_tasks(context, vmlinux_module_name): | ||
time_namespace_id = task.get_time_namespace_id() | ||
# If it cannot get the time namespace i.e. kernels < 5.6, this still works | ||
# using None to just get the first tasks | ||
if time_namespace_id in time_namespace_ids: | ||
continue | ||
time_namespace_ids.add(time_namespace_id) | ||
boottime = task.get_boottime(root_time_namespace=False) | ||
|
||
fields = ( | ||
time_namespace_id, | ||
boottime, | ||
) | ||
yield fields | ||
|
||
def _generator(self): | ||
for ( | ||
time_namespace_id, | ||
boottime, | ||
) in self.get_time_namespaces_bootime( | ||
self.context, | ||
self.config["kernel"], | ||
): | ||
fields = [ | ||
time_namespace_id or renderers.NotAvailableValue(), | ||
boottime, | ||
] | ||
yield 0, fields | ||
|
||
def generate_timeline(self): | ||
for ( | ||
time_namespace_id, | ||
boottime, | ||
) in self.get_time_namespaces_bootime( | ||
self.context, | ||
self.config["kernel"], | ||
): | ||
description = f"System boot time for time namespace {time_namespace_id}" | ||
|
||
yield description, timeliner.TimeLinerType.CREATED, boottime | ||
|
||
def run(self): | ||
columns = [ | ||
("TIME NS", int), | ||
("Boot Time", datetime.datetime), | ||
] | ||
return renderers.TreeGrid(columns, self._generator()) |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change to the return response of a classmethod (the exposed API) should've meant that the MAJOR version got bumped, sorry for missing it... 5:S