diff --git a/volatility/cli/volshell/generic.py b/volatility/cli/volshell/generic.py index 7b73f8834..ee1c301c9 100644 --- a/volatility/cli/volshell/generic.py +++ b/volatility/cli/volshell/generic.py @@ -22,7 +22,7 @@ except ImportError: has_capstone = False -class Volshell(interfaces.plugins.PluginInterface, interfaces.plugins.FileConsumerInterface): +class Volshell(interfaces.plugins.PluginInterface): """Shell environment to directly interact with a memory image.""" def __init__(self, *args, **kwargs): @@ -103,8 +103,10 @@ class Volshell(interfaces.plugins.PluginInterface, interfaces.plugins.FileConsum 'display_doublewords'], self.display_doublewords), (['dq', 'display_quadwords'], self.display_quadwords), (['dis', 'disassemble'], self.disassemble), (['cl', 'change_layer'], self.change_layer), (['context'], self.context), (['self'], self), - (['dpo', 'display_plugin_output'], self.display_plugin_output), (['rp', 'run_plugin'], self.run_plugin), - (['rt', 'render_treegrid'], self.render_treegrid), (['hh', 'help'], self.help)] + (['dpo', 'display_plugin_output'], self.display_plugin_output), + (['gt', 'generate_treegrid'], self.generate_treegrid), (['rt', + 'render_treegrid'], self.render_treegrid), + (['hh', 'help'], self.help)] def _construct_locals_dict(self) -> Dict[str, Any]: """Returns a dictionary of the locals """ @@ -248,10 +250,12 @@ class Volshell(interfaces.plugins.PluginInterface, interfaces.plugins.FileConsum return hex(value.vol.offset) def consume_file(self, file: interfaces.plugins.FileInterface) -> None: + """Dummy file consumer to satisfy the """ pass - def run_plugin(self, plugin: Type[interfaces.plugins.PluginInterface], **kwargs) -> interfaces.renderers.TreeGrid: - """Runs a specific plugin passing in kwarg values returning a TreeGrid""" + def generate_treegrid(self, plugin: Type[interfaces.plugins.PluginInterface], + **kwargs) -> interfaces.renderers.TreeGrid: + """Generates a TreeGrid based on a specific plugin passing in kwarg configuration values""" path_join = interfaces.configuration.path_join # Generate a temporary configuration path @@ -263,7 +267,7 @@ class Volshell(interfaces.plugins.PluginInterface, interfaces.plugins.FileConsum self.config[path_join(plugin_config_suffix, plugin.__name__, name)] = value try: - constructed = plugins.construct_plugin(self.context, [], plugin, plugin_path, None, self) + constructed = plugins.construct_plugin(self.context, [], plugin, plugin_path, None, NullFileConsumer()) return constructed.run() except exceptions.UnsatisfiedException as excp: print("Unable to validate the plugin requirements: {}\n".format([x for x in excp.unsatisfied])) @@ -271,10 +275,18 @@ class Volshell(interfaces.plugins.PluginInterface, interfaces.plugins.FileConsum def render_treegrid(self, treegrid: interfaces.renderers.TreeGrid, renderer: Optional[interfaces.renderers.Renderer] = None) -> None: - """Renders a treegrid as produced by run_plugin""" + """Renders a treegrid as produced by generate_treegrid""" if renderer is None: renderer = text_renderer.QuickTextRenderer() renderer.render(treegrid) def display_plugin_output(self, plugin: Type[interfaces.plugins.PluginInterface], **kwargs) -> None: - self.render_treegrid(self.run_plugin(plugin, **kwargs)) + self.render_treegrid(self.generate_treegrid(plugin, **kwargs)) + + +class NullFileConsumer(interfaces.plugins.FileConsumerInterface): + """Null FileConsumer that swallows files whole""" + + def consume_file(self, file: interfaces.plugins.FileInterface) -> None: + """Dummy file consumer to satisfy the FileConsumerInterface""" + pass