fixed the module loader a bit, still needs more work

git-svn-id: file:///home/svn/incoming/trunk@2698 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-07-09 23:48:41 +00:00
parent ffbfe73260
commit 558b6300b1
5 changed files with 22 additions and 41 deletions

View File

@ -183,30 +183,18 @@ protected
# Substitute the base path
path_base = file.sub(path + File::SEPARATOR, '')
# Extract the type of module
md = path_base.match(/^(.*?)#{File::SEPARATOR}/)
# Chop off the file name
path_base.sub!(/(.+)(#{File::SEPARATOR}.+\.rb)$/, '\1')
next if (!md)
# Extract the module's namespace from its path
mod = mod_from_name(path_base)
type = path_base.match(/^(.+?)#{File::SEPARATOR}+?/)[1].sub(/s$/, '')
# Use the de-pluralized version of the type as necessary
type = md[1].sub(/s$/, '').downcase
md = path_base.match(/^(.*)#{File::SEPARATOR}(.*?)$/)
next if (!md)
# Prefix Msf to the namespace
namespace = 'Msf::' + md[1].gsub(File::SEPARATOR, "::")
dlog("Loading #{type} module from #{path_base}...", 'core', LEV_1)
# Let's rock the house now...
dlog("Loading module from #{path_base}...", 'core', LEV_1)
# Get the module and grab the current number of constants
old_constants = []
mod = mod_from_name(namespace)
if (mod)
old_constants = mod.constants
end
# Load the file
begin
@ -219,14 +207,6 @@ protected
next
end
# Incase we hadn't gotten the module yet...
mod = mod_from_name(namespace)
if (!mod)
elog("Load did not create expected namespace #{namespace}.")
next
end
added = mod.constants - old_constants
if (added.length > 1)
@ -286,14 +266,17 @@ protected
# Returns the module object that is associated with the supplied module
# name
def mod_from_name(name)
obj = Object
obj = Msf
name.split(File::SEPARATOR).each { |m|
# Up-case the first letter and any prefixed by _
m.gsub!(/^[a-z]/) { |s| s.upcase }
m.gsub!(/(_[a-z])/) { |s| s[1..1].upcase }
name.split('::').each { |m|
begin
obj = obj.const_get(m)
rescue NameError
obj = nil
break
obj = obj.const_set(m, ::Module.new)
end
}
@ -304,7 +287,7 @@ protected
# categorized accordingly
def on_module_load(type, mod)
# Extract the module name information
mod_full_name = mod.to_s.gsub('::', '_')
mod_full_name = mod.to_s.gsub('::', '/')
mod_full_name.sub!(/^Msf_/, '')
mod_short_name = mod_full_name

View File

@ -2,7 +2,7 @@ require 'msf/core'
module Msf
module Encoders
module IA32
module Ia32
class JmpCallAdditive < Msf::Encoder::XorAdditiveFeedback

View File

@ -2,7 +2,7 @@ require 'msf/core'
module Msf
module Nops
module IA32
module Ia32
###
#

View File

@ -2,9 +2,8 @@ require 'msf/core'
module Msf
module Payloads
module Stagers
module Windows
module IA32
module Stager
module ReverseTcp
@ -52,4 +51,4 @@ module ReverseTcp
end
end end end end end
end end end end

View File

@ -2,9 +2,8 @@ require 'msf/core'
module Msf
module Payloads
module Stages
module Windows
module IA32
module Stage
module Shell
@ -42,4 +41,4 @@ module Shell
end
end end end end end
end end end end