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

Add linux hidden_modules plugin #1283

Merged
merged 19 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6cd39c0
Refactor of module object. Adding function helpers to simplify the co…
gcmoreira Sep 18, 2024
5dee3ae
Add linux.hidden_modules plugin
gcmoreira Oct 1, 2024
d5e6e7c
Allow any module state value in both traditional and fast scan methods
gcmoreira Oct 1, 2024
590aa9c
Make it callable from other plugins.
gcmoreira Oct 3, 2024
8d925bd
Added the --heuristic-mode option, which relaxes constraints to impro…
gcmoreira Oct 3, 2024
e8754fa
Fix typo in usage help
gcmoreira Oct 3, 2024
b5948d7
Linux: hidden_modules: Add @Abyss-W4tcher suggestion to optimize the …
gcmoreira Oct 3, 2024
f455c30
Linux: hidden_modules: remove missed optional heuristic_mode argument
gcmoreira Oct 3, 2024
d98c7eb
linux: hidden_modules: Make the fast method the default. Remove vol2 …
gcmoreira Oct 16, 2024
0ddd921
linux: hidden_modules: Remove unused module imports
gcmoreira Oct 16, 2024
526007f
Linux: hidden_modules: Use child_template
gcmoreira Oct 29, 2024
cbe071f
Linux: hidden_modules: Import the whole architectures module
gcmoreira Oct 29, 2024
dfd8a1f
Linux: hidden_modules: Include kernel version and commit details
gcmoreira Oct 29, 2024
1c6a548
Linux: hidden_modules: Simplify symbols type checks
gcmoreira Oct 29, 2024
8960bda
Linux: hidden_modules: Add a symbol table check for a recent dwarf2js…
gcmoreira Oct 29, 2024
f537c4a
Merge branch 'develop' into linux_hidden_modules
gcmoreira Oct 29, 2024
4b76b69
Linux: hidden_modules: Add docstrings and comments to enhance the doc…
gcmoreira Oct 29, 2024
722ccd5
Linux: Extensions: Clean up the Linux constants imports in the object…
gcmoreira Oct 30, 2024
4f86b3f
Merge branch 'develop' into linux_hidden_modules
gcmoreira Oct 30, 2024
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
8 changes: 8 additions & 0 deletions volatility3/framework/constants/linux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,11 @@ class PT_FLAGS(Flag):
def flags(self) -> str:
"""Returns the ptrace flags string"""
return str(self).replace(self.__class__.__name__ + ".", "")


# Valid sizes for modules. Note that the Linux kernel does not define these values; they
# are based on empirical observations of typical memory allocations for kernel modules.
# We use this to verify that the found module falls within reasonable limits.
MODULE_MAXIMUM_CORE_SIZE = 20000000
MODULE_MAXIMUM_CORE_TEXT_SIZE = 20000000
MODULE_MINIMUM_SIZE = 4096
37 changes: 28 additions & 9 deletions volatility3/framework/symbols/linux/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@

from volatility3.framework import constants, exceptions, objects, interfaces, symbols
from volatility3.framework.renderers import conversion
from volatility3.framework.constants.linux import SOCK_TYPES, SOCK_FAMILY
from volatility3.framework.constants.linux import IP_PROTOCOLS, IPV6_PROTOCOLS
from volatility3.framework.constants.linux import TCP_STATES, NETLINK_PROTOCOLS
from volatility3.framework.constants.linux import ETH_PROTOCOLS, BLUETOOTH_STATES
from volatility3.framework.constants.linux import BLUETOOTH_PROTOCOLS, SOCKET_STATES
from volatility3.framework.constants.linux import CAPABILITIES, PT_FLAGS
from volatility3.framework.constants.linux import (
ikelos marked this conversation as resolved.
Show resolved Hide resolved
SOCK_TYPES,
SOCK_FAMILY,
IP_PROTOCOLS,
IPV6_PROTOCOLS,
TCP_STATES,
NETLINK_PROTOCOLS,
ETH_PROTOCOLS,
BLUETOOTH_STATES,
BLUETOOTH_PROTOCOLS,
SOCKET_STATES,
CAPABILITIES,
PT_FLAGS,
MODULE_MAXIMUM_CORE_SIZE,
MODULE_MAXIMUM_CORE_TEXT_SIZE,
MODULE_MINIMUM_SIZE,
)

from volatility3.framework.layers import linear
from volatility3.framework.objects import utility
from volatility3.framework.symbols import generic, linux, intermed
Expand All @@ -36,16 +48,23 @@ def __init__(self, *args, **kwargs):
self._mod_mem_type = None # Initialize _mod_mem_type to None for memoization

def is_valid(self):
ikelos marked this conversation as resolved.
Show resolved Hide resolved
"""Determine whether it is a valid module object by verifying the self-referential
in module_kobject. This also confirms that the module is actively allocated and
not a remnant of freed memory or a failed module load attempt by verifying the
module memory section sizes.
"""
layer = self._context.layers[self.vol.layer_name]
# Make sure the entire module content is readable
if not layer.is_valid(self.vol.offset, self.vol.size):
return False

core_size = self.get_core_size()
core_text_size = self.get_core_text_size()
init_size = self.get_init_size()
if not (
1 <= core_size <= 20000000
and core_size + self.get_init_size() >= 4096
and 1 <= self.get_core_text_size() <= 20000000
0 < core_text_size <= MODULE_MAXIMUM_CORE_TEXT_SIZE
and 0 < core_size <= MODULE_MAXIMUM_CORE_SIZE
and core_size + init_size >= MODULE_MINIMUM_SIZE
):
return False

Expand Down
Loading