Skip to content

Commit 6b4e021

Browse files
committed
Make ModuleManager Enumerable
Fixes tools/module_* and probably some other lurking bugs
1 parent ceb6f81 commit 6b4e021

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/msf/core/module_manager.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ModuleManager < ModuleSet
3232
include Msf::ModuleManager::ModuleSets
3333
include Msf::ModuleManager::Reloading
3434

35+
include Enumerable
36+
3537
#
3638
# CONSTANTS
3739
#
@@ -91,6 +93,19 @@ def create(name)
9193
end
9294

9395

96+
# Iterate over all modules in all sets
97+
#
98+
# @yieldparam name [String] The module's reference name
99+
# @yieldparam mod_class [Msf::Module] A module class
100+
def each
101+
module_set_by_type.each do |type, set|
102+
set.each do |name, mod_class|
103+
yield name, mod_class
104+
end
105+
end
106+
end
107+
108+
94109
# @param [Msf::Framework] framework The framework for which this instance is managing the modules.
95110
# @param [Array<String>] types List of module types to load. Defaults to all module types in {Msf::MODULE_TYPES}.
96111
def initialize(framework, types=Msf::MODULE_TYPES)
@@ -151,5 +166,6 @@ def auto_subscribe_module(mod)
151166
framework.events.add_session_subscriber((inst) ? inst : (inst = mod.new))
152167
end
153168
end
169+
154170
end
155171
end

0 commit comments

Comments
 (0)