mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-24 23:22:23 +02:00
Core: Allow for deprecation of constants gracefully
This commit is contained in:
@@ -7,7 +7,7 @@ import glob
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
required_python_version = (3, 6, 0)
|
||||
required_python_version = (3, 7, 0)
|
||||
if (sys.version_info.major != required_python_version[0] or sys.version_info.minor < required_python_version[1] or
|
||||
(sys.version_info.minor == required_python_version[1] and sys.version_info.micro < required_python_version[2])):
|
||||
raise RuntimeError(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Optional, Tuple, Type
|
||||
|
||||
from volatility3.framework import constants, interfaces
|
||||
@@ -40,7 +41,8 @@ class LinuxIntelStacker(interfaces.automagic.StackerLayerInterface):
|
||||
if isinstance(layer, intel.Intel):
|
||||
return None
|
||||
|
||||
linux_banners = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).get_identifier_dictionary(
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
linux_banners = symbol_cache.SqliteCache(identifiers_path).get_identifier_dictionary(
|
||||
operating_system = 'linux')
|
||||
# If we have no banners, don't bother scanning
|
||||
if not linux_banners:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import struct
|
||||
from typing import Optional
|
||||
|
||||
@@ -42,7 +43,8 @@ class MacIntelStacker(interfaces.automagic.StackerLayerInterface):
|
||||
if isinstance(layer, intel.Intel):
|
||||
return None
|
||||
|
||||
mac_banners = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).get_identifier_dictionary(
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
mac_banners = symbol_cache.SqliteCache(identifiers_path).get_identifier_dictionary(
|
||||
operating_system = 'mac')
|
||||
# If we have no banners, don't bother scanning
|
||||
if not mac_banners:
|
||||
|
||||
@@ -388,7 +388,8 @@ class SymbolCacheMagic(interfaces.automagic.AutomagicInterface):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._cache = SqliteCache(constants.IDENTIFIERS_PATH)
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
self._cache = SqliteCache(identifiers_path)
|
||||
|
||||
def __call__(self, context, config_path, configurable, progress_callback = None):
|
||||
"""Runs the automagic over the configurable."""
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, Callable, Iterable, List, Optional, Tuple
|
||||
|
||||
from volatility3.framework import constants, interfaces, layers
|
||||
@@ -40,7 +41,8 @@ class SymbolFinder(interfaces.automagic.AutomagicInterface):
|
||||
"""Creates a cached copy of the results, but only it's been
|
||||
requested."""
|
||||
if not self._banners:
|
||||
cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
cache = symbol_cache.SqliteCache(identifiers_path)
|
||||
self._banners = cache.get_identifier_dictionary(operating_system = self.operating_system)
|
||||
return self._banners
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ volatility This includes default scanning block sizes, etc.
|
||||
import enum
|
||||
import os.path
|
||||
import sys
|
||||
import warnings
|
||||
from typing import Callable, Optional
|
||||
|
||||
import volatility3.framework.constants.linux
|
||||
@@ -67,13 +68,7 @@ if sys.platform == 'win32':
|
||||
CACHE_PATH = os.path.join(os.environ.get("APPDATA", os.path.expanduser("~")), "volatility3")
|
||||
os.makedirs(CACHE_PATH, exist_ok = True)
|
||||
|
||||
LINUX_BANNERS_PATH = os.path.join(CACHE_PATH, "linux_banners.cache")
|
||||
"""Default location to record information about available linux banners"""
|
||||
|
||||
MAC_BANNERS_PATH = os.path.join(CACHE_PATH, "mac_banners.cache")
|
||||
"""Default location to record information about available mac banners"""
|
||||
|
||||
IDENTIFIERS_PATH = os.path.join(CACHE_PATH, "identifiers.cache")
|
||||
IDENTIFIERS_FILENAME = "identifier.cache"
|
||||
"""Default location to record information about available identifiers"""
|
||||
|
||||
CACHE_SQLITE_SCEMA_VERSION = 1
|
||||
@@ -107,3 +102,23 @@ OFFLINE = False
|
||||
|
||||
REMOTE_ISF_URL = None # 'http://localhost:8000/banners.json'
|
||||
"""Remote URL to query for a list of ISF addresses"""
|
||||
|
||||
###
|
||||
# DEPRECATED VALUES
|
||||
###
|
||||
|
||||
_deprecated_LINUX_BANNERS_FILENAME = os.path.join(CACHE_PATH, 'linux_banners.cache')
|
||||
"""This value is deprecated and is no longer used within volatility"""
|
||||
|
||||
_deprecated_MAC_BANNERS_PATH = os.path.join(CACHE_PATH, 'mac_banners.cache')
|
||||
"""This value is deprecated and is no longer used within volatility"""
|
||||
|
||||
_deprecated_IDENTIFIERS_PATH = os.path.join(CACHE_PATH, IDENTIFIERS_FILENAME)
|
||||
"""This value is deprecated in favour of CACHE_PATH joined to IDENTIFIER_FILENAME"""
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
deprecated_tag = '_deprecated_'
|
||||
if name in [x[len(deprecated_tag):] for x in globals() if x.startswith(deprecated_tag)]:
|
||||
warnings.warn(f"{name} is deprecated", FutureWarning)
|
||||
return globals()[f"{deprecated_tag}{name}"]
|
||||
|
||||
@@ -109,7 +109,8 @@ class IsfInfo(plugins.PluginInterface):
|
||||
num_enums = len(data.get('enums', []))
|
||||
num_bases = len(data.get('base_types', []))
|
||||
|
||||
identifier_cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
identifier_cache = symbol_cache.SqliteCache(identifiers_path)
|
||||
identifier = identifier_cache.get_identifier(location = entry)
|
||||
if identifier:
|
||||
identifier = identifier.decode('utf-8', errors = 'replace')
|
||||
@@ -120,7 +121,8 @@ class IsfInfo(plugins.PluginInterface):
|
||||
vollog.warning(f"Invalid ISF: {entry}")
|
||||
yield (0, (entry, valid, num_bases, num_types, num_symbols, num_enums, identifier))
|
||||
else:
|
||||
cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
cache = symbol_cache.SqliteCache(identifiers_path)
|
||||
valid = 'Unknown'
|
||||
for identifier, location in cache.get_identifier_dictionary().items():
|
||||
num_bases, num_types, num_enums, num_symbols = cache.get_location_statistics(location)
|
||||
|
||||
@@ -80,7 +80,8 @@ class PDBUtility(interfaces.configuration.VersionableInterface):
|
||||
vollog.debug(f"Required version of SQLiteCache not found")
|
||||
return None
|
||||
|
||||
value = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).find_location(
|
||||
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
|
||||
value = symbol_cache.SqliteCache(identifiers_path).find_location(
|
||||
symbol_cache.WindowsIdentifier.generate(pdb_name.strip('\x00'), guid.upper(), age), 'windows')
|
||||
|
||||
if value:
|
||||
|
||||
Reference in New Issue
Block a user