@@ -50,18 +50,21 @@ def [](key)
50
50
module_set = module_set_by_type [ type ]
51
51
52
52
module_reference_name = names . join ( "/" )
53
- module_set . create ( module_reference_name )
53
+ module_set [ module_reference_name ]
54
54
end
55
55
56
56
# Creates a module instance using the supplied reference name.
57
57
#
58
- # @param [String] name a module reference name. It may optionally be prefixed with a "<type>/", in which case the
59
- # module will be created from the {Msf::ModuleSet} for the given <type>.
58
+ # @param name [String] A module reference name. It may optionally
59
+ # be prefixed with a "<type>/", in which case the module will be
60
+ # created from the {Msf::ModuleSet} for the given <type>.
61
+ # Otherwise, we step through all sets until we find one that
62
+ # matches.
60
63
# @return (see Msf::ModuleSet#create)
61
64
def create ( name )
62
65
# Check to see if it has a module type prefix. If it does,
63
66
# try to load it from the specific module set for that type.
64
- names = name . split ( File :: SEPARATOR )
67
+ names = name . split ( "/" )
65
68
potential_type_or_directory = names . first
66
69
67
70
# if first name is a type
@@ -72,20 +75,31 @@ def create(name)
72
75
type = TYPE_BY_DIRECTORY [ potential_type_or_directory ]
73
76
end
74
77
78
+ m = nil
75
79
if type
76
80
module_set = module_set_by_type [ type ]
77
81
78
- module_reference_name = names [ 1 .. - 1 ] . join ( File :: SEPARATOR )
79
- module_set . create ( module_reference_name )
80
- # Otherwise, just try to load it by name.
82
+ # First element in names is the type, so skip it
83
+ module_reference_name = names [ 1 .. - 1 ] . join ( "/" )
84
+ m = module_set . create ( module_reference_name )
81
85
else
82
- super
86
+ # Then we don't have a type, so we have to step through each set
87
+ # to see if we can create this module.
88
+ module_set_by_type . each do |_ , set |
89
+ module_reference_name = names . join ( "/" )
90
+ m = set . create ( module_reference_name )
91
+ break if m
92
+ end
83
93
end
94
+
95
+ m
84
96
end
85
97
86
98
87
- # @param framework [Msf::Framework] The framework for which this instance is managing the modules.
88
- # @param [Array<String>] types List of module types to load. Defaults to all module types in {Msf::MODULE_TYPES}.
99
+ # @param framework [Msf::Framework] The framework for which this
100
+ # instance is managing the modules.
101
+ # @param types [Array<String>] List of module types to load.
102
+ # Defaults to all module types in {Msf::MODULE_TYPES}.
89
103
def initialize ( framework , types = Msf ::MODULE_TYPES )
90
104
#
91
105
# defaults
0 commit comments