mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-06 17:57:38 +02:00
Add: plugin version, logger, dump options
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import logging
|
||||
import struct
|
||||
from typing import List, Iterator, Tuple
|
||||
|
||||
from volatility3.framework import interfaces, renderers
|
||||
from volatility3.framework import constants, interfaces, renderers
|
||||
from volatility3.framework.configuration import requirements
|
||||
from volatility3.framework.symbols.windows.extensions.registry import RegValueTypes
|
||||
from volatility3.plugins.windows.registry import hivelist, printkey
|
||||
|
||||
vollog = logging.getLogger(__name__)
|
||||
|
||||
class Certificates(interfaces.plugins.PluginInterface):
|
||||
"""Lists the certificates in the registry's Certificate Store."""
|
||||
|
||||
_required_framework_version = (2, 0, 0)
|
||||
_version = (1, 0, 0)
|
||||
|
||||
@classmethod
|
||||
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
|
||||
@@ -20,7 +23,11 @@ class Certificates(interfaces.plugins.PluginInterface):
|
||||
architectures = ["Intel32", "Intel64"]),
|
||||
requirements.SymbolTableRequirement(name = "nt_symbols", description = "Windows kernel symbols"),
|
||||
requirements.PluginRequirement(name = 'hivelist', plugin = hivelist.HiveList, version = (1, 0, 0)),
|
||||
requirements.PluginRequirement(name = 'printkey', plugin = printkey.PrintKey, version = (1, 0, 0))
|
||||
requirements.PluginRequirement(name = 'printkey', plugin = printkey.PrintKey, version = (1, 0, 0)),
|
||||
requirements.BooleanRequirement(name = 'dump',
|
||||
description = "Extract listed certificates",
|
||||
default = False,
|
||||
optional = True)
|
||||
]
|
||||
|
||||
def parse_data(self, data: bytes) -> Tuple[str, bytes]:
|
||||
@@ -48,21 +55,22 @@ class Certificates(interfaces.plugins.PluginInterface):
|
||||
try:
|
||||
# Walk it
|
||||
node_path = hive.get_key(top_key, return_list = True)
|
||||
for (depth, is_key, last_write_time, key_path, volatility,
|
||||
node) in printkey.PrintKey.key_iterator(hive, node_path, recurse = True):
|
||||
for (_, is_key, _, key_path, _, node) in printkey.PrintKey.key_iterator(hive, node_path, recurse = True):
|
||||
if not is_key and RegValueTypes(node.Type).name == "REG_BINARY":
|
||||
name, certificate_data = self.parse_data(node.decode_data())
|
||||
unique_key_offset = key_path.casefold().index(top_key.casefold()) + len(top_key) + 1
|
||||
reg_section = key_path[unique_key_offset:key_path.index("\\", unique_key_offset)]
|
||||
key_hash = key_path[key_path.rindex("\\") + 1:]
|
||||
|
||||
if not isinstance(certificate_data, interfaces.renderers.BaseAbsentValue):
|
||||
with self.open("{} - {} - {}.crt".format(hex(hive.hive_offset), reg_section,
|
||||
key_hash)) as file_data:
|
||||
file_data.write(certificate_data)
|
||||
if self.config['dump']:
|
||||
if not isinstance(certificate_data, interfaces.renderers.BaseAbsentValue):
|
||||
with self.open("{} - {} - {}.crt".format(hex(hive.hive_offset), reg_section,
|
||||
key_hash)) as file_data:
|
||||
file_data.write(certificate_data)
|
||||
yield (0, (top_key, reg_section, key_hash, name))
|
||||
except KeyError:
|
||||
# Key wasn't found in this hive, carry on
|
||||
vollog.log(constants.LOGLEVEL_VVVV, "Key wasn't found in this hive")
|
||||
pass
|
||||
|
||||
def run(self) -> renderers.TreeGrid:
|
||||
|
||||
Reference in New Issue
Block a user