Land #10341, Add check method Boolean to module cache and info and search commands

This commit is contained in:
Wei Chen 2018-07-23 14:45:28 -05:00
commit dc43cc78b0
No known key found for this signature in database
GPG Key ID: 6E162ED2C01D9AAC
8 changed files with 24 additions and 19 deletions

View File

@ -183,6 +183,10 @@ class ReadableText
output << "Available targets:\n"
output << dump_exploit_targets(mod, indent)
# Check
output << "Check supported:\n"
output << "#{indent}#{mod.respond_to?(:check) ? 'Yes' : 'No'}\n\n"
# Options
if (mod.options.has_options?)
output << "Basic options:\n"
@ -241,6 +245,10 @@ class ReadableText
output << dump_module_actions(mod, indent)
end
# Check
output << "Check supported:\n"
output << "#{indent}#{mod.respond_to?(:check) ? 'Yes' : 'No'}\n\n"
# Options
if (mod.options.has_options?)
output << "Basic options:\n"

View File

@ -115,8 +115,8 @@ module Auxiliary
mod.setup
# Run check
mod.check
# Run check if it exists
mod.respond_to?(:check) ? mod.check : Msf::Exploit::CheckCode::Unsupported
end
#

View File

@ -185,8 +185,8 @@ module Exploit
mod.setup
# Run check
mod.check
# Run check if it exists
mod.respond_to?(:check) ? mod.check : Msf::Exploit::CheckCode::Unsupported
end
#

View File

@ -203,16 +203,6 @@ class Module
self.class.file_path
end
#
# Checks to see if the target is vulnerable, returning unsupported if it's
# not supported.
#
# This method is designed to be overriden by exploit modules.
#
def check
Msf::Exploit::CheckCode::Unsupported
end
#
# Returns the current workspace
#

View File

@ -26,6 +26,7 @@ class Obj
attr_reader :mod_time
attr_reader :is_install_path
attr_reader :ref_name
attr_reader :check
def initialize(module_instance, obj_hash = nil)
unless obj_hash.nil?
@ -49,7 +50,7 @@ class Obj
sort_platform_string
@arch = module_instance.arch_to_s
@rport = module_instance.datastore['RPORT'].to_s
@rport = module_instance.datastore['RPORT']
@path = module_instance.file_path
@mod_time = ::File.mtime(@path) rescue Time.now
@ref_name = module_instance.refname
@ -63,6 +64,9 @@ class Obj
@targets = module_instance.targets.map{|x| x.name}
end
# Store whether a module has a check method
@check = module_instance.respond_to?(:check) ? true : false
# Due to potentially non-standard ASCII we force UTF-8 to ensure no problem with JSON serialization
force_encoding(Encoding::UTF_8)
end
@ -89,7 +93,8 @@ class Obj
'mod_time' => @mod_time.to_s,
'path' => @path,
'is_install_path' => @is_install_path,
'ref_name' => @ref_name
'ref_name' => @ref_name,
'check' => @check
}.to_json(*args)
end
@ -135,6 +140,7 @@ class Obj
@path = obj_hash['path']
@is_install_path = obj_hash['is_install_path']
@targets = obj_hash['targets'].nil? ? [] : obj_hash['targets']
@check = obj_hash['check'] ? true : false
end
def sort_platform_string

View File

@ -88,7 +88,7 @@ module Msf::Modules::Metadata::Search
match = [t,w] if module_metadata.targets.any? { |t| t =~ r }
end
when 'port'
match = [t,w] if module_metadata.rport =~ r
match = [t,w] if module_metadata.rport.to_s =~ r
when 'type'
match = [t,w] if Msf::MODULE_TYPES.any? { |modt| w == modt and module_metadata.type == modt }
when 'app'

View File

@ -385,6 +385,7 @@ module Msf
m.full_name,
m.disclosure_date.nil? ? '' : m.disclosure_date.strftime("%Y-%m-%d"),
RankingName[m.rank].to_s,
m.check ? 'Yes' : 'No',
m.name
]
end
@ -1101,6 +1102,7 @@ module Msf
refname,
o.disclosure_date.nil? ? "" : o.disclosure_date.strftime("%Y-%m-%d"),
o.rank_to_s,
o.respond_to?(:check) ? 'Yes' : 'No',
o.name
]
end
@ -1117,7 +1119,7 @@ module Msf
'Header' => type,
'Prefix' => "\n",
'Postfix' => "\n",
'Columns' => [ 'Name', 'Disclosure Date', 'Rank', 'Description' ],
'Columns' => [ 'Name', 'Disclosure Date', 'Rank', 'Check', 'Description' ],
'SearchTerm' => search_term
)
end

View File

@ -7,7 +7,6 @@ RSpec.describe Msf::Module do
described_class.new
}
it { is_expected.to respond_to :check }
it { is_expected.to respond_to :debugging? }
it { is_expected.to respond_to :fail_with }
it { is_expected.to respond_to :file_path }