From ce25403e1896c99962f0bba1e1c0445c9cc3beeb Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sat, 17 Oct 2009 05:25:29 +0000 Subject: [PATCH] Fixes #356. Delete poorly formatted reference entries, preventing bad reference objects from being stored in the actual module git-svn-id: file:///home/svn/framework3/trunk@7172 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/module.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/module.rb b/lib/msf/core/module.rb index d8489cef12..7a5a94dadf 100644 --- a/lib/msf/core/module.rb +++ b/lib/msf/core/module.rb @@ -109,13 +109,14 @@ class Module # Initialize module compatibility hashes init_compat + # Fixup module fields as needed + info_fixups + # Transform some of the fields to arrays as necessary self.author = Author.transform(module_info['Author']) - self.arch = Rex::Transformer.transform(module_info['Arch'], Array, - [ String ], 'Arch') + self.arch = Rex::Transformer.transform(module_info['Arch'], Array, [ String ], 'Arch') self.platform = PlatformList.transform(module_info['Platform']) - self.references = Rex::Transformer.transform(module_info['References'], Array, - [ SiteReference, Reference ], 'Ref') + self.references = Rex::Transformer.transform(module_info['References'], Array, [ SiteReference, Reference ], 'Ref') # Create and initialize the option container for this module self.options = OptionContainer.new @@ -578,6 +579,24 @@ protected c['Encoder'].update(module_info['EncoderCompat'] || {}) c['Nop'].update(module_info['NopCompat'] || {}) end + + # + # Register options with a specific owning class. + # + def info_fixups + # Each reference should be an array consisting of two elements + refs = module_info['References'] + if(refs and not refs.empty?) + refs.each_index do |i| + if(not (refs[i].respond_to?('[]') and refs[i].length == 2)) + refs[i] = nil + end + end + + # Purge invalid references + refs.delete(nil) + end + end # # Register options with a specific owning class.