From e0799d7c149c70246fb658dd487538185a940d7c Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Thu, 15 Dec 2022 17:40:17 -0500 Subject: [PATCH] Handle cases where the framework module is nil --- .../remote/kerberos/ticket/storage/base.rb | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/msf/core/exploit/remote/kerberos/ticket/storage/base.rb b/lib/msf/core/exploit/remote/kerberos/ticket/storage/base.rb index 2fa4add9e3e5e..28152c6c087d6 100644 --- a/lib/msf/core/exploit/remote/kerberos/ticket/storage/base.rb +++ b/lib/msf/core/exploit/remote/kerberos/ticket/storage/base.rb @@ -11,11 +11,6 @@ class Base # @return [Msf::Module] the Metasploit framework module that is associated with the authentication instance attr_reader :framework_module - def_delegators :@framework_module, - :print_status, - :print_good, - :workspace - def initialize(framework: nil, framework_module: nil) @framework = framework || framework_module&.framework @framework_module = framework_module @@ -63,8 +58,28 @@ def store_ccache(ccache, options = {}) nil end + # @return [String] The name of the workspace in which to operate. + def workspace + if @framework_module + return @framework_module.workspace + elsif @framework&.db&.active + return @framework.db.workspace&.name + end + end + private + # Forward whatever method calls this to the specified framework module, but + # only if it's present otherwise return nil. + def proxied_module_method(*args, **kwargs) + return nil unless @framework_module + + @framework_module.send(__callee__, *args, **kwargs) + end + + alias :print_good :proxied_module_method + alias :print_status :proxied_module_method + # Return the raw stored objects. # # @param [Hash] options See the options hash description in {#tickets}.