made merging of info better

git-svn-id: file:///home/svn/incoming/trunk@2699 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-07-10 00:16:48 +00:00
parent 558b6300b1
commit bbcc7d3abf
5 changed files with 34 additions and 21 deletions

View File

@ -189,10 +189,12 @@ protected
# two
if (info[name].kind_of?(Array) == false)
curr = info[name]
info[name] = [ curr, val ]
info[name] = [ curr, val ] if (val != curr)
# Otherwise, just append this item to the array entry
else
info[name] << val
if (!info[name].find(val))
info[name] << val
end
end
# Otherwise, just set the value equal if no current value
# exists
@ -226,6 +228,13 @@ protected
merge_info_string(info, 'Description', val)
end
#
# Merge the module version
#
def merge_info_version(info, val)
merge_info_string(info, 'Version', val)
end
#
# Merges a given key in the info hash with a delimiter
#

View File

@ -37,6 +37,13 @@ class Msf::Module::Author
self.email = email
end
#
# Compares authors
#
def ==(tgt)
return (tgt.to_s == to_s)
end
#
# Serialize the author object to a string in form:
#

View File

@ -18,6 +18,13 @@ class Msf::Module::Reference
self.str = in_str
end
#
# Compares references
#
def ==(tgt)
return (tgt.to_s == to_s)
end
def to_s
return self.str
end

View File

@ -62,10 +62,9 @@ class ModuleSet < Hash
protected
# Adds a module with a supplied short name, full name, and associated
# module class
def add_module(module_class, alias_name = nil)
self[alias_name || module_class.new.alias] = module_class
# Adds a module with a the supplied name
def add_module(module_class, name)
self[name] = module_class
end
attr_writer :module_type
@ -189,6 +188,7 @@ protected
# Extract the module's namespace from its path
mod = mod_from_name(path_base)
type = path_base.match(/^(.+?)#{File::SEPARATOR}+?/)[1].sub(/s$/, '')
name = path_base.match(/^(.+?)#{File::SEPARATOR}(.*)$/)[2]
# Let's rock the house now...
dlog("Loading module from #{path_base}...", 'core', LEV_1)
@ -231,7 +231,7 @@ protected
# Do some processing on the loaded module to get it into the
# right associations
on_module_load(type, added)
on_module_load(added, type, name)
# Set this module type as needing recalculation
recalc[type] = true
@ -285,17 +285,7 @@ protected
# Called when a module is initially loaded such that it can be
# categorized accordingly
def on_module_load(type, mod)
# Extract the module name information
mod_full_name = mod.to_s.gsub('::', '/')
mod_full_name.sub!(/^Msf_/, '')
mod_short_name = mod_full_name
if ((md = mod_full_name.match(/^(.*)_(.*)$/)))
mod_short_name = md[2]
end
def on_module_load(mod, type, name)
# Payload modules require custom loading as the individual files
# may not directly contain a logical payload that a user would
# reference, such as would be the case with a payload stager or
@ -306,10 +296,10 @@ protected
if (type != MODULE_PAYLOAD)
# Add the module class to the list of modules and add it to the
# type separated set of module classes
add_module(mod)
add_module(mod, name)
end
module_sets[type].add_module(mod)
module_sets[type].add_module(mod, name)
end
attr_accessor :modules, :module_sets

View File

@ -123,7 +123,7 @@ class PayloadSet < ModuleSet
# set we simply create an instance of the class and do some magic to figure
# out if it's a single, stager, or stage. Depending on which it is, we
# add it to the appropriate list
def add_module(pmodule)
def add_module(pmodule, name)
# Duplicate the Payload base class and extend it with the module
# class that is passed in. This allows us to inspect the actual