mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-25 23:52:23 +02:00
Context.object accepts a template or a string name (and now a type flag). Module.object only accepts a string (because a template already has most of the stuff built in and might as well be passed to the Context.object constructor). The gotcha here is the absolute flag, which must now be set appropriately in all cases *except* where the module is constructed with an offset of 0 (whereby it will have no impact).
88 lines
3.9 KiB
Python
88 lines
3.9 KiB
Python
# This file was contributed to the Volatility Framework Version 3.
|
|
# Copyright (C) 2018 Volatility Foundation.
|
|
#
|
|
# THE LICENSED WORK IS PROVIDED UNDER THE TERMS OF THE Volatility Contributors
|
|
# Public License V1.0("LICENSE") AS FIRST COMPLETED BY: Volatility Foundation,
|
|
# Inc. ANY USE, PUBLIC DISPLAY, PUBLIC PERFORMANCE, REPRODUCTION OR DISTRIBUTION
|
|
# OF, OR PREPARATION OF SUBSEQUENT WORKS, DERIVATIVE WORKS OR DERIVED WORKS BASED
|
|
# ON, THE LICENSED WORK CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS LICENSE AND ITS
|
|
# TERMS, WHETHER OR NOT SUCH RECIPIENT READS THE TERMS OF THE LICENSE. "LICENSED
|
|
# WORK,” “RECIPIENT" AND “DISTRIBUTOR" ARE DEFINED IN THE LICENSE. A COPY OF THE
|
|
# LICENSE IS LOCATED IN THE TEXT FILE ENTITLED "LICENSE.txt" ACCOMPANYING THE
|
|
# CONTENTS OF THIS FILE. IF A COPY OF THE LICENSE DOES NOT ACCOMPANY THIS FILE, A
|
|
# COPY OF THE LICENSE MAY ALSO BE OBTAINED AT THE FOLLOWING WEB SITE:
|
|
# https://www.volatilityfoundation.org/license/vcpl_v1.0
|
|
#
|
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
|
|
# specific language governing rights and limitations under the License.
|
|
#
|
|
|
|
from typing import List
|
|
|
|
from volatility.framework import constants
|
|
from volatility.framework import exceptions, interfaces
|
|
from volatility.framework import renderers
|
|
from volatility.framework.configuration import requirements
|
|
from volatility.framework.renderers import format_hints
|
|
|
|
|
|
class Modules(interfaces.plugins.PluginInterface):
|
|
"""Lists the loaded kernel modules"""
|
|
|
|
@classmethod
|
|
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
|
|
return [
|
|
requirements.TranslationLayerRequirement(
|
|
name = 'primary', description = 'Memory layer for the kernel', architectures = ["Intel32", "Intel64"]),
|
|
requirements.SymbolTableRequirement(name = "nt_symbols", description = "Windows kernel symbols")
|
|
]
|
|
|
|
def _generator(self):
|
|
for mod in self.list_modules(self.context, self.config['primary'], self.config['nt_symbols']):
|
|
|
|
try:
|
|
BaseDllName = mod.BaseDllName.get_string()
|
|
except exceptions.InvalidAddressException:
|
|
BaseDllName = ""
|
|
|
|
try:
|
|
FullDllName = mod.FullDllName.get_string()
|
|
except exceptions.InvalidAddressException:
|
|
FullDllName = ""
|
|
|
|
yield (0, (
|
|
format_hints.Hex(mod.vol.offset),
|
|
format_hints.Hex(mod.DllBase),
|
|
format_hints.Hex(mod.SizeOfImage),
|
|
BaseDllName,
|
|
FullDllName,
|
|
))
|
|
|
|
@classmethod
|
|
def list_modules(cls, context: interfaces.context.ContextInterface, layer_name: str, symbol_table: str):
|
|
"""Lists all the modules in the primary layer"""
|
|
|
|
kvo = context.layers[layer_name].config['kernel_virtual_offset']
|
|
ntkrnlmp = context.module(symbol_table, layer_name = layer_name, offset = kvo)
|
|
|
|
try:
|
|
# use this type if its available (starting with windows 10)
|
|
ldr_entry_type = ntkrnlmp.get_type("_KLDR_DATA_TABLE_ENTRY")
|
|
except exceptions.SymbolError:
|
|
ldr_entry_type = ntkrnlmp.get_type("_LDR_DATA_TABLE_ENTRY")
|
|
|
|
type_name = ldr_entry_type.type_name.split(constants.BANG)[1]
|
|
|
|
list_head = ntkrnlmp.get_symbol("PsLoadedModuleList").address
|
|
list_entry = ntkrnlmp.object(symbol = "_LIST_ENTRY", offset = list_head)
|
|
reloff = ldr_entry_type.relative_child_offset("InLoadOrderLinks")
|
|
module = ntkrnlmp.object(symbol = type_name, offset = list_entry.vol.offset - reloff, absolute = True)
|
|
|
|
for mod in module.InLoadOrderLinks:
|
|
yield mod
|
|
|
|
def run(self):
|
|
return renderers.TreeGrid([("Offset", format_hints.Hex), ("Base", format_hints.Hex), ("Size", format_hints.Hex),
|
|
("Name", str), ("Path", str)], self._generator())
|