Lands #5270, improvements to Msf::ModuleSet
commit
b1b8f86aae
|
@ -57,6 +57,8 @@ class Msf::ModuleSet < Hash
|
||||||
# Notify any general subscribers of the creation event
|
# Notify any general subscribers of the creation event
|
||||||
if instance
|
if instance
|
||||||
self.framework.events.on_module_created(instance)
|
self.framework.events.on_module_created(instance)
|
||||||
|
else
|
||||||
|
self.delete(reference_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
@ -112,9 +114,7 @@ class Msf::ModuleSet < Hash
|
||||||
def each_module_ranked(opts = {}, &block)
|
def each_module_ranked(opts = {}, &block)
|
||||||
demand_load_modules
|
demand_load_modules
|
||||||
|
|
||||||
self.mod_ranked = rank_modules
|
each_module_list(rank_modules, opts, &block)
|
||||||
|
|
||||||
each_module_list(mod_ranked, opts, &block)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Forces all modules in this set to be loaded.
|
# Forces all modules in this set to be loaded.
|
||||||
|
@ -138,7 +138,6 @@ class Msf::ModuleSet < Hash
|
||||||
self.architectures_by_module = {}
|
self.architectures_by_module = {}
|
||||||
self.platforms_by_module = {}
|
self.platforms_by_module = {}
|
||||||
self.mod_sorted = nil
|
self.mod_sorted = nil
|
||||||
self.mod_ranked = nil
|
|
||||||
self.mod_extensions = []
|
self.mod_extensions = []
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -292,11 +291,6 @@ class Msf::ModuleSet < Hash
|
||||||
#
|
#
|
||||||
# @return [Hash{Class => Array<String>}] Maps module class to Array of platform Strings.
|
# @return [Hash{Class => Array<String>}] Maps module class to Array of platform Strings.
|
||||||
attr_accessor :platforms_by_module
|
attr_accessor :platforms_by_module
|
||||||
# @!attribute [rw] mod_ranked
|
|
||||||
# Array of module names and module classes ordered by their Rank with the higher Ranks first.
|
|
||||||
#
|
|
||||||
# @return (see #rank_modules)
|
|
||||||
attr_accessor :mod_ranked
|
|
||||||
# @!attribute [rw] mod_sorted
|
# @!attribute [rw] mod_sorted
|
||||||
# Array of module names and module classes ordered by their names.
|
# Array of module names and module classes ordered by their names.
|
||||||
#
|
#
|
||||||
|
@ -315,14 +309,7 @@ class Msf::ModuleSet < Hash
|
||||||
# @return [Array<Array<String, Class>>] Array of arrays where the inner array is a pair of the module reference name
|
# @return [Array<Array<String, Class>>] Array of arrays where the inner array is a pair of the module reference name
|
||||||
# and the module class.
|
# and the module class.
|
||||||
def rank_modules
|
def rank_modules
|
||||||
self.mod_ranked = self.sort { |a_pair, b_pair|
|
self.sort_by { |pair| module_rank(*pair) }.reverse!
|
||||||
a_rank = module_rank(*a_pair)
|
|
||||||
b_rank = module_rank(*b_pair)
|
|
||||||
|
|
||||||
# Compare their relevant rankings. Since we want highest to lowest,
|
|
||||||
# we compare b_rank to a_rank in terms of higher/lower precedence
|
|
||||||
b_rank <=> a_rank
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Retrieves the rank from a loaded, not-yet-loaded, or unloadable Metasploit Module.
|
# Retrieves the rank from a loaded, not-yet-loaded, or unloadable Metasploit Module.
|
||||||
|
|
Loading…
Reference in New Issue