fb266d5eb9
[#36737359] Refactor the behavior of loading symbolic modules from cache by renaming methods so it's clearer what they do and ensure that cached modules from Fastlibs and directories can both be loaded, which was not previously possible since the demand_load_module only called load_module_from_file.
48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
# Concerns reloading modules
|
|
module Msf::ModuleManager::Reloading
|
|
# Reloads the module specified in mod. This can either be an instance of a module or a module class.
|
|
#
|
|
# @param [Msf::Module, Class] mod either an instance of a module or a module class
|
|
# @return (see Msf::Modules::Loader::Base#reload_module)
|
|
def reload_module(mod)
|
|
# if it's can instance, then get its class
|
|
if mod.is_a? Msf::Module
|
|
metasploit_class = mod.class
|
|
else
|
|
metasploit_class = mod
|
|
end
|
|
|
|
namespace_module = metasploit_class.parent
|
|
loader = namespace_module.loader
|
|
loader.reload_module(mod)
|
|
end
|
|
|
|
# Reloads modules from all module paths
|
|
#
|
|
# @return (see Msf::ModuleManager::Loading#load_modules)
|
|
def reload_modules
|
|
self.module_history = {}
|
|
self.clear
|
|
|
|
self.enablement_by_type.each_key do |type|
|
|
module_set_by_type[type].clear
|
|
init_module_set(type)
|
|
end
|
|
|
|
# default the count to zero the first time a type is accessed
|
|
count_by_type = Hash.new(0)
|
|
|
|
module_paths.each do |path|
|
|
path_count_by_type = load_modules(path, :force => true)
|
|
|
|
# merge count with count from other paths
|
|
path_count_by_type.each do |type, count|
|
|
count_by_type[type] += count
|
|
end
|
|
end
|
|
|
|
refresh_cache_from_module_files
|
|
|
|
count_by_type
|
|
end
|
|
end |