From f152c9df50c805d3154c1eeb243f9f3136779692 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Wed, 2 Feb 2022 22:50:28 -0500 Subject: [PATCH] Maintain module config after reload from load_modules --- pwncat/manager.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pwncat/manager.py b/pwncat/manager.py index 644f330..b5e9d0e 100644 --- a/pwncat/manager.py +++ b/pwncat/manager.py @@ -971,8 +971,21 @@ class Manager: # Update the current module context if we just replaced a module if old_module != new_module and self.config.module == old_module: + # Save the local configuration for the module + config = self.config.locals + # Use the new module self.config.use(new_module) + # Attempt to re-set any configuration items previously set + # This could fail if the argument definitions changed on disk. + for key, value in config.items(): + try: + self.config.set(key, value) + except ValueError as exc: + self.log( + f"[yellow]warning[/yellow]: failed to re-set module config: {key}: {exc}" + ) + def reload_module( self, module: Union[str, "pwncat.modules.BaseModule"] ) -> "pwncat.modules.BaseModule":