From a5e8d98a9c29ca06c09bac648a693aadc538296a Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 13 Jul 2017 01:31:19 +0100 Subject: [PATCH] Refactor the location of the linux banner cache. --- volatility/framework/automagic/linux_symbol_cache.py | 8 +++----- volatility/framework/constants.py | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/volatility/framework/automagic/linux_symbol_cache.py b/volatility/framework/automagic/linux_symbol_cache.py index 73cbbfc80..e7484c7b2 100644 --- a/volatility/framework/automagic/linux_symbol_cache.py +++ b/volatility/framework/automagic/linux_symbol_cache.py @@ -8,8 +8,6 @@ from volatility.framework.symbols import intermed vollog = logging.getLogger(__name__) -cached_linuxbanner_filepath = os.path.join(constants.CACHE_PATH, "linux_banners.cache") - class LinuxSymbolCache(interfaces.automagic.AutomagicInterface): """Class to run through all Linux symbols tables and cache their banners""" @@ -19,8 +17,8 @@ class LinuxSymbolCache(interfaces.automagic.AutomagicInterface): # We only need to be called once, so no recursion necessary linuxbanners = {} - if os.path.exists(cached_linuxbanner_filepath): - with open(cached_linuxbanner_filepath, "rb") as f: + if os.path.exists(constants.LINUX_BANNERS_PATH): + with open(constants.LINUX_BANNERS_PATH, "rb") as f: # We use pickle over JSON because we're dealing with bytes objects linuxbanners.update(pickle.load(f)) @@ -59,5 +57,5 @@ class LinuxSymbolCache(interfaces.automagic.AutomagicInterface): except KeyError: pass - with open(cached_linuxbanner_filepath, "wb") as f: + with open(constants.LINUX_BANNERS_PATH, "wb") as f: pickle.dump(linuxbanners, f) diff --git a/volatility/framework/constants.py b/volatility/framework/constants.py index 77fb3a86a..9dcec5492 100644 --- a/volatility/framework/constants.py +++ b/volatility/framework/constants.py @@ -23,3 +23,5 @@ if sys.platform == 'windows': else: CACHE_PATH = os.path.join(os.path.expanduser("~"), ".cache", "volatility3") os.makedirs(CACHE_PATH, exist_ok = True) + +LINUX_BANNERS_PATH = os.path.join(CACHE_PATH, "linux_banners.cache")