From cb2f4ae4199e4802aab0feb9962eb4fd15a12831 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 24 Sep 2018 14:02:15 -0500 Subject: [PATCH 1/2] Add filter_ports and filter_services to cache When caching metadata about module include `filters` when available. --- lib/msf/core/modules/metadata/obj.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/msf/core/modules/metadata/obj.rb b/lib/msf/core/modules/metadata/obj.rb index 870548ecfb..c0adf24f5e 100644 --- a/lib/msf/core/modules/metadata/obj.rb +++ b/lib/msf/core/modules/metadata/obj.rb @@ -35,6 +35,10 @@ class Obj attr_reader :arch # @return [Integer] attr_reader :rport + # @return [Array] + attr_reader :filter_ports + # @return [Array] + attr_reader :filter_services # @return [Array] attr_reader :targets # @return [Time] @@ -80,6 +84,12 @@ class Obj @path = module_instance.file_path @mod_time = ::File.mtime(@path) rescue Time.now @ref_name = module_instance.refname + if module_instance.respond_to?('autofilter_ports') + @filter_ports = module_instance.autofilter_ports + end + if module_instance.respond_to?('autofilter_services') + @filter_services = module_instance.autofilter_services + end install_path = Msf::Config.install_root.to_s if (@path.to_s.include? (install_path)) @@ -118,6 +128,8 @@ class Obj 'platform' => @platform, 'arch' => @arch, 'rport' => @rport, + 'filter_ports' => @filter_ports, + 'filter_services' => @filter_services, 'targets' => @targets, 'mod_time' => @mod_time.to_s, 'path' => @path, From 2db32799562a1546fdcd28a88662b28250d4cec3 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Tue, 25 Sep 2018 15:04:26 -0500 Subject: [PATCH 2/2] use symbols and match filter keys to code --- lib/msf/core/modules/metadata/obj.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/msf/core/modules/metadata/obj.rb b/lib/msf/core/modules/metadata/obj.rb index c0adf24f5e..83717e9029 100644 --- a/lib/msf/core/modules/metadata/obj.rb +++ b/lib/msf/core/modules/metadata/obj.rb @@ -36,9 +36,9 @@ class Obj # @return [Integer] attr_reader :rport # @return [Array] - attr_reader :filter_ports + attr_reader :autofilter_ports # @return [Array] - attr_reader :filter_services + attr_reader :autofilter_services # @return [Array] attr_reader :targets # @return [Time] @@ -84,11 +84,11 @@ class Obj @path = module_instance.file_path @mod_time = ::File.mtime(@path) rescue Time.now @ref_name = module_instance.refname - if module_instance.respond_to?('autofilter_ports') - @filter_ports = module_instance.autofilter_ports + if module_instance.respond_to?(:autofilter_ports) + @autofilter_ports = module_instance.autofilter_ports end - if module_instance.respond_to?('autofilter_services') - @filter_services = module_instance.autofilter_services + if module_instance.respond_to?(:autofilter_services) + @autofilter_services = module_instance.autofilter_services end install_path = Msf::Config.install_root.to_s @@ -128,8 +128,8 @@ class Obj 'platform' => @platform, 'arch' => @arch, 'rport' => @rport, - 'filter_ports' => @filter_ports, - 'filter_services' => @filter_services, + 'autofilter_ports' => @autofilter_ports, + 'autofilter_services'=> @autofilter_services, 'targets' => @targets, 'mod_time' => @mod_time.to_s, 'path' => @path,