Skip to content

Commit d50644f

Browse files
committed
Removing leftover files
1 parent 119e487 commit d50644f

File tree

1 file changed

+7
-81
lines changed

1 file changed

+7
-81
lines changed

lib/msf/core/module_manager/reloading.rb

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,40 @@
11
# -*- coding: binary -*-
2-
32
# Concerns reloading modules
4-
53
module Msf::ModuleManager::Reloading
64
# Reloads the module specified in mod. This can either be an instance of a module or a module class.
75
#
86
# @param [Msf::Module, Class] mod either an instance of a module or a module class
97
# @return (see Msf::Modules::Loader::Base#reload_module)
108
def reload_module(mod)
11-
# if it's an instance, then get its class
9+
# if it's can instance, then get its class
1210
if mod.is_a? Msf::Module
1311
metasploit_class = mod.class
1412
else
1513
metasploit_class = mod
1614
end
1715

18-
if aliased_as = inv_aliases[metasploit_class.fullname]
16+
if aliased_as = self.inv_aliases[metasploit_class.fullname]
1917
aliased_as.each do |a|
20-
aliases.delete a
18+
self.aliases.delete a
2119
end
22-
inv_aliases.delete metasploit_class.fullname
23-
end
24-
25-
if mod.payload?
26-
return reload_payload_module(mod)
27-
end
28-
29-
if aliased_as = inv_aliases[metasploit_class.fullname]
30-
aliased_as.each do |a|
31-
aliases.delete a
32-
end
33-
inv_aliases.delete metasploit_class.fullname
20+
self.inv_aliases.delete metasploit_class.fullname
3421
end
3522

3623
namespace_module = metasploit_class.module_parent
37-
38-
# Check if the namespace module has a loader
39-
unless namespace_module.respond_to?(:loader)
40-
elog('Module does not have loader')
41-
return mod
42-
end
43-
4424
loader = namespace_module.loader
4525
loader.reload_module(mod)
4626
end
4727

48-
def manual_reload(parent_path, type, ref_name)
49-
loaders.each { |loader| loader.load_module(parent_path, type, ref_name, { force: true }) }
50-
end
51-
52-
# Reload payload module, separately from other categories. This is due to complexity of payload module and due to the fact they don't follow class structure as rest of the modules.
53-
# @param [Msf::Module, Class] mod either an instance of a module or a module class
54-
# @return (see Msf::Modules::Loader::Base#reload_module)
55-
def reload_payload_module(mod)
56-
if mod.is_a? Msf::Module
57-
metasploit_class = mod.class
58-
original_instance = mod
59-
else
60-
metasploit_class = mod
61-
original_instance = nil
62-
end
63-
if (module_set = module_set_by_type.fetch(metasploit_class.type, nil))
64-
module_set.delete(metasploit_class.refname)
65-
end
66-
module_info = module_info_by_path[metasploit_class.file_path]
67-
unless module_info && (parent_path = module_info[:parent_path])
68-
elog('Failed to get parent_path from module object')
69-
return mod
70-
end
71-
72-
# reload adapters if any
73-
manual_reload(parent_path, module_info[:type], File.join('adapters', mod.adapter_refname)) if mod.adapter_refname
74-
75-
# reload stagers if any
76-
manual_reload(parent_path, module_info[:type], File.join('stagers', mod.stager_refname)) if mod.stager_refname
77-
78-
# reload stages if any
79-
manual_reload(parent_path, module_info[:type], File.join('stages', mod.stage_refname)) if mod.stage_refname
80-
81-
# reload single if any
82-
manual_reload(parent_path, module_info[:type], File.join('singles', module_info[:reference_name])) if original_instance.payload_type == Msf::Payload::Type::Single
83-
84-
# Get reloaded module
85-
new_instance = framework.modules.create(metasploit_class.fullname)
86-
87-
if new_instance.blank?
88-
elog('Failed create new instance')
89-
return mod
90-
end
91-
92-
# Restore the datastore
93-
new_instance.datastore.merge!(original_instance.datastore)
94-
95-
# Return the new instance, which the framework will make the active module.
96-
return new_instance
97-
rescue StandardError => e
98-
elog("Failed to reload payload #{fullname}: #{e.message}")
99-
return mod
100-
end
101-
10228
# Reloads modules from all module paths
10329
#
10430
# @return (see Msf::ModuleManager::Loading#load_modules)
10531
def reload_modules
106-
enablement_by_type.each_key do |type|
32+
self.enablement_by_type.each_key do |type|
10733
module_set_by_type[type].clear
10834
init_module_set(type)
10935
end
110-
aliases.clear
111-
inv_aliases.clear
36+
self.aliases.clear
37+
self.inv_aliases.clear
11238

11339
# default the count to zero the first time a type is accessed
11440
count_by_type = Hash.new(0)

0 commit comments

Comments
 (0)