dump dump dump

git-svn-id: file:///home/svn/incoming/trunk@2700 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-07-10 00:49:12 +00:00
parent bbcc7d3abf
commit ddb75822ad
6 changed files with 104 additions and 26 deletions

View File

@ -17,26 +17,26 @@ class ReadableText
# Returns a formatted string that contains information about
# the supplied module instance.
#
def self.dump_module(mod)
def self.dump_module(mod, indent = " ")
case mod.type
when MODULE_PAYLOAD
return dump_payload_module(mod)
return dump_payload_module(mod, indent)
when MODULE_NOP
return dump_nop_module(mod, indent)
when MODULE_EXPLOIT
return dump_exploit_module(mod)
return dump_exploit_module(mod, indent)
else
return dump_generic_module(mod)
return dump_generic_module(mod, indent)
end
end
def self.dump_exploit_module(mod)
def self.dump_exploit_module(mod, indent)
end
#
# Dumps information about a payload module.
#
def self.dump_payload_module(mod)
indent = " "
def self.dump_payload_module(mod, indent)
# General
output = "\n"
output += " Name: #{mod.name}\n"
@ -55,15 +55,19 @@ class ReadableText
output += "\n"
# Options
output += "Available options:\n"
output += dump_options(mod)
output += "\n"
if (mod.options.has_options?)
output += "Available options:\n"
output += dump_options(mod)
output += "\n"
end
# Advanced options
output += "Advanced options:\n"
output += dump_advanced_options(mod)
output += "\n"
if (mod.options.has_advanced_options?)
output += "Advanced options:\n"
output += dump_advanced_options(mod)
output += "\n"
end
# Description
output += "Description:\n"
output += word_wrap(mod.description)
@ -72,7 +76,42 @@ class ReadableText
return output
end
def self.dump_generic_module(mod)
#
# Dumps information about a nop module.
#
def self.dump_nop_module(mod, indent)
# General
output = "\n"
output += " Name: #{mod.name}\n"
output += " Version: #{mod.version}\n"
#output += " Platform: #{mod.platform_to_s}\n"
output += " Arch: #{mod.arch.to_s}\n"
output += "\n"
# Authors
output += "Provided by:\n"
mod.each_author { |author|
output += indent + author.to_s + "\n"
}
output += "\n"
# Advanced options
if (mod.options.has_advanced_options?)
output += "Advanced options:\n"
output += dump_advanced_options(mod)
output += "\n"
end
# Description
output += "Description:\n"
output += word_wrap(mod.description)
output += "\n\n"
return output
end
def self.dump_generic_module(mod, indent)
end
#
@ -122,10 +161,12 @@ class ReadableText
end
#
# TODO: word wrapping
# Jacked from Ernest Ellingson <erne [at] powernav.com>, modified
# a bit to add indention
#
def self.word_wrap(str, indent = 4, col = 60)
return str
return str.gsub(/.{1,#{col - indent}}(?:\s|\Z)/){
( (" " * indent) + $& + 5.chr).gsub(/\n\005/,"\n").gsub(/\005/,"\n")}
end
end

View File

@ -212,5 +212,5 @@ end
end
require 'msf/core/exploit/remote/tcp'
require 'msf/core/exploit/remote/dcerpc'
require 'msf/core/exploit/tcp'
require 'msf/core/exploit/dcerpc'

View File

@ -31,7 +31,7 @@ class ModuleSet < Hash
# Enumerates each module class in the set
def each_module(opts = {}, &block)
each_value { |mod|
each_pair { |name, mod|
# Filter out incompatible architectures
if (opts['arch'])
if (!mod_arch_hash[mod])
@ -50,7 +50,7 @@ class ModuleSet < Hash
next if (mod_platform_hash[mod].include?(opts['platform']) == false)
end
block.call(mod)
block.call(name, mod)
}
end
@ -182,13 +182,15 @@ protected
# Substitute the base path
path_base = file.sub(path + File::SEPARATOR, '')
# Derive the name from the path with the exclusion of the .rb
name = path_base.match(/^(.+?)#{File::SEPARATOR}(.*)(.rb?)$/)[2]
# Chop off the file name
path_base.sub!(/(.+)(#{File::SEPARATOR}.+\.rb)$/, '\1')
path_base.sub!(/(.+)(#{File::SEPARATOR}.+)(.rb?)$/, '\1')
# 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)

View File

@ -12,6 +12,11 @@ module Msf
###
class Nop < Msf::Module
# NOP module, bitch!
def type
return MODULE_NOP
end
#
# Stub method for generating a sled with the provided arguments. Derived
# Nop implementations must supply a length and can supply one or more of

View File

@ -158,18 +158,24 @@ end
###
class OptionContainer < Hash
#
# Merges in the supplied options and converts them to a OptBase
# as necessary.
#
def initialize(opts = {})
add_options(opts)
end
#
# Return the value associated with the supplied name
#
def [](name)
return get(name)
end
#
# Return the option associated with the supplied name
#
def get(name)
begin
return fetch(name)
@ -177,6 +183,30 @@ class OptionContainer < Hash
end
end
#
# Returns whether or not the container has any options,
# excluding advanced.
#
def has_options?
each_option { |name, opt|
return true if (opt.advanced? == false)
}
return false
end
#
# Returns whether or not the container has any advanced
# options.
#
def has_advanced_options?
each_option { |name, opt|
return true if (opt.advanced? == true)
}
return false
end
# Adds one or more options
def add_options(opts, owner = nil, advanced = false)
return false if (opts == nil)

View File

@ -283,10 +283,10 @@ protected
}
})
module_set.each_module { |mod|
module_set.each_module { |name, mod|
instance = mod.new
tbl << [ instance.alias, instance.description ]
tbl << [ name, instance.description ]
}
print(tbl.to_s)