last of normalized docs from last night

git-svn-id: file:///home/svn/incoming/trunk@3030 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Miller 2005-11-15 15:11:43 +00:00
parent 95f8210853
commit 5676117bff
71 changed files with 905 additions and 242 deletions

View File

@ -45,42 +45,72 @@ class Config < Hash
#
##
#
# Returns the framework installation root.
#
def self.install_root
InstallRoot
end
#
# Calls the instance method.
#
def self.config_directory
self.new.config_directory
end
#
# Calls the instance method.
#
def self.module_directory
self.new.module_directory
end
#
# Calls the instance method.
#
def self.log_directory
self.new.log_directory
end
#
# Calls the instance method.
#
def self.session_log_directory
self.new.session_log_directory
end
#
# Calls the instance method.
#
def self.user_module_directory
self.new.user_module_directory
end
#
# Calls the instance method.
#
def self.config_file
self.new.config_file
end
#
# Calls the instance method.
#
def self.init
self.new.init
end
#
# Calls the instance method.
#
def self.load(path = nil)
self.new.load(path)
end
#
# Calls the instance method.
#
def self.save(opts)
self.new.save(opts)
end

View File

@ -11,7 +11,7 @@ module Msf
class Logging
#
# Initialize logging
# Initialize logging.
#
def self.init
if (@initialized != true)

View File

@ -54,7 +54,7 @@ class PersistentStorage
#
# This method adds a new storage class to the hash of storage classes that
# can be created through create
# can be created through create.
#
def self.add_storage_class(name, klass)
@@storage_classes[name] = klass

View File

@ -54,6 +54,10 @@ class ReadableText
tbl.to_s + "\n"
end
#
# Dumps the table of payloads that are compatible with the supplied
# exploit.
#
def self.dump_compatible_payloads(exploit, indent = '', h = nil)
tbl = Rex::Ui::Text::Table.new(
'Indent' => indent.length,
@ -284,6 +288,9 @@ class ReadableText
return tbl.to_s
end
#
# Dumps the advanced options associated with the supplied module.
#
def self.dump_advanced_options(mod, indent = '')
output = ''
pad = indent
@ -304,7 +311,7 @@ class ReadableText
end
#
# Dumps the contents of a datastore
# Dumps the contents of a datastore.
#
def self.dump_datastore(name, ds, indent = DefaultIndent, col = DefaultColumnWrap)
tbl = Rex::Ui::Text::Table.new(
@ -324,7 +331,7 @@ class ReadableText
end
#
# Dumps the list of active sessions
# Dumps the list of active sessions.
#
def self.dump_sessions(framework, indent = DefaultIndent, col = DefaultColumnWrap)
tbl = Rex::Ui::Text::Table.new(
@ -347,7 +354,7 @@ class ReadableText
end
#
# Dumps the list of running jobs
# Dumps the list of running jobs.
#
def self.dump_jobs(framework, indent = DefaultIndent, col = DefaultColumnWrap)
tbl = Rex::Ui::Text::Table.new(

View File

@ -22,41 +22,50 @@ class CommandShell
#
include Msf::Session::Provider::SingleCommandShell
#
# Returns the type of session.
#
def self.type
"shell"
end
#
# Returns the session description.
#
def desc
"Command shell"
end
#
# Calls the class method.
#
def type
self.class.type
end
#
# The shell will have been initialized by default
# The shell will have been initialized by default.
#
def init_shell
return true
end
#
# Read from the command shell
# Read from the command shell.
#
def read_shell(length = nil)
return rstream.read(length)
end
#
# Writes to the command shell
# Writes to the command shell.
#
def write_shell(buf)
rstream.write(buf)
end
#
# Closes the shell
# Closes the shell.
#
def close_shell()
rstream.close

View File

@ -20,6 +20,10 @@ class Meterpreter < Rex::Post::Meterpreter::Client
include Msf::Session::Interactive
include Msf::Session::Comm
#
# Initializes a meterpreter session instance using the supplied rstream
# that is to be used as the client's connection to the server.
#
def initialize(rstream)
super
@ -34,6 +38,9 @@ class Meterpreter < Rex::Post::Meterpreter::Client
self.console = Rex::Post::Meterpreter::Ui::Console.new(self)
end
#
# Returns the session type as being 'meterpreter'.
#
def self.type
"meterpreter"
end
@ -43,11 +50,17 @@ class Meterpreter < Rex::Post::Meterpreter::Client
# Msf::Session overrides
#
##
#
# Returns the session description.
#
def desc
"Meterpreter"
end
#
# Calls the class method.
#
def type
self.class.type
end
@ -59,7 +72,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client
##
#
# Initializes the console's I/O handles
# Initializes the console's I/O handles.
#
def init_ui(input, output)
console.init_ui(input, output)
@ -67,7 +80,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client
end
#
# Resets the console's I/O handles
# Resets the console's I/O handles.
#
def reset_ui
console.unset_log_source
@ -75,7 +88,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client
end
#
# Interacts with the meterpreter client at a user interface level
# Interacts with the meterpreter client at a user interface level.
#
def _interact
# Call the console interaction subsystem of the meterpreter client and
@ -112,7 +125,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client
protected
attr_accessor :rstream, :console
attr_accessor :rstream, :console # :nodoc:
end

View File

@ -13,7 +13,7 @@ module Simple
module Buffer
#
# Serializes a buffer to a provided format
# Serializes a buffer to a provided format.
#
def self.transform(buf, fmt = "ruby")
case fmt
@ -32,7 +32,7 @@ module Buffer
end
#
# Creates a comment using the supplied format
# Creates a comment using the supplied format.
#
def self.comment(buf, fmt = "ruby")
case fmt

View File

@ -3,7 +3,8 @@ module Simple
###
#
# A simplified encoder wrapper.
# A simplified encoder wrapper. Currently there is no simplification
# required. This is here because stuff is there.
#
###
module Encoder

View File

@ -13,7 +13,7 @@ module Exploit
include Module
#
# Wraps the exploitation process
# Wraps the exploitation process in a simple single method.
#
def self.exploit_simple(exploit, opts)
target_idx = opts['Target'] || exploit.default_target
@ -71,7 +71,7 @@ module Exploit
end
#
# Calls the class method
# Calls the class method.
#
def exploit_simple(opts)
Msf::Simple::Exploit.exploit_simple(self, opts)

View File

@ -37,7 +37,7 @@ module Framework
end
#
# Extends a framework object that may already exist
# Extends a framework object that may already exist.
#
def self.simplify(framework, opts)
framework.extend(Msf::Simple::Framework)
@ -99,7 +99,7 @@ module Framework
##
#
# Initializes the simplified interface
# Initializes the simplified interface.
#
def init_simplified
self.stats = Statistics.new(self)
@ -119,11 +119,14 @@ module Framework
self.datastore.to_file(Msf::Config.config_file, 'framework/core')
end
#
# Statistics.
#
attr_reader :stats
protected
attr_writer :stats
attr_writer :stats # :nodoc:
end

View File

@ -26,21 +26,21 @@ module Module
end
#
# Initializes the simplified interface
# Initializes the simplified interface.
#
def init_simplified
load_config
end
#
# Populates the datastore from the config file
# Populates the datastore from the config file.
#
def load_config
self.datastore.from_file(Msf::Config.config_file, self.refname)
end
#
# Saves the module's datastore to the file
# Saves the module's datastore to the file.
#
def save_config
self.datastore.to_file(Msf::Config.config_file, self.refname)

View File

@ -29,7 +29,7 @@ module Nop
end
#
# Calls the class method
# Calls the class method.
#
def generate_simple(length, opts)
Msf::Simple::Nop.generate_simple(self, length, opts)

View File

@ -79,7 +79,7 @@ module Payload
end
#
# Calls the class method
# Calls the class method.
#
def generate_simple(opts)
Msf::Simple::Payload.generate_simple(self, opts)

View File

@ -10,38 +10,65 @@ module Simple
class Statistics
include Msf::Framework::Offspring
#
# Initializes the framework statistics.
#
def initialize(framework)
self.framework = framework
end
#
# Returns the number of encoders in the framework.
#
def num_encoders
self.framework.encoders.length
end
#
# Returns the number of exploits in the framework.
#
def num_exploits
self.framework.exploits.length
end
#
# Returns the number of NOP generators in the framework.
#
def num_nops
self.framework.nops.length
end
#
# Returns the number of payloads in the framework.
#
def num_payloads
self.framework.payloads.length
end
#
# Returns the number of recon modules in the framework.
#
def num_recon
self.framework.recon.length
end
#
# Returns the number of stages in the framework.
#
def num_payload_stages
self.framework.payloads.stages.length
end
#
# Returns the number of stagers in the framework.
#
def num_payload_stagers
self.framework.payloads.stagers.length
end
#
# Returns the number of singles in the framework.
#
def num_payload_singles
self.framework.payloads.singles.length
end

View File

@ -28,7 +28,7 @@ class EncoderState
end
#
# Set the initial encoding key
# Set the initial encoding key.
#
def init_key(key)
self.key = key
@ -54,6 +54,10 @@ end
###
class Encoder < Module
#
# Initializes an encoder module instance using the supplied information
# hash.
#
def initialize(info)
super(info)
end

View File

@ -7,10 +7,16 @@ require 'msf/core'
###
class Msf::Encoder::Xor < Msf::Encoder
#
# Encodes a block using the XOR encoder from the Rex library.
#
def encode_block(state, block)
return Rex::Encoding::Xor::Dword.encode(block, [ state.key ].pack(state.decoder_key_pack))[0]
end
#
# Finds keys that are incompatible with the supplied bad character list.
#
def find_bad_keys(buf, badchars)
bad_keys = [ {}, {}, {}, {} ]
byte_idx = 0

View File

@ -11,6 +11,9 @@ class Msf::Encoder::XorAdditiveFeedback < Msf::Encoder::Xor
super(info)
end
#
# Encodes a block using the XOR additive feedback algorithm.
#
def encode_block(state, block)
# XOR the key with the current block
orig = block.unpack(decoder_key_pack)[0]
@ -23,6 +26,9 @@ class Msf::Encoder::XorAdditiveFeedback < Msf::Encoder::Xor
return [ oblock ].pack(decoder_key_pack)
end
#
# Finds a key that is compatible with the badchars list.
#
def find_key(buf, badchars)
key_bytes = integer_to_key_bytes(super(buf, badchars))
state = Msf::EncoderState.new

View File

@ -9,6 +9,9 @@ module Encoding
###
class Xor
#
# Encodes a block using XOR.
#
def Xor.encode_block(key, block, block_size = 4, block_pack = 'V')
offset = 0
oblock = ''

View File

@ -266,11 +266,11 @@ protected
}
end
attr_accessor :general_event_subscribers
attr_accessor :exploit_event_subscribers
attr_accessor :session_event_subscribers
attr_accessor :recon_event_subscribers
attr_accessor :subscribers_rwlock
attr_accessor :general_event_subscribers # :nodoc:
attr_accessor :exploit_event_subscribers # :nodoc:
attr_accessor :session_event_subscribers # :nodoc:
attr_accessor :recon_event_subscribers # :nodoc:
attr_accessor :subscribers_rwlock # :nodoc:
end

View File

@ -27,6 +27,11 @@ end
###
class Exploit < Msf::Module
##
#
# Default compatibility settings for exploit modules.
#
##
module CompatDefaults
#
# Default compatibility specifications for payloads
@ -39,9 +44,11 @@ class Exploit < Msf::Module
}
end
##
#
# The various check codes that can be returned from the ``check'' routine.
#
##
module CheckCode
#
@ -356,14 +363,16 @@ class Exploit < Msf::Module
end
#
# Returns if the exploit has a passive stance
# Returns if the exploit has a passive stance.
#
def passive?
(stance == Stance::Passive)
end
#
# Returns the active target for this exploit
# Returns the active target for this exploit. If not target has been
# defined, nil is returned. If no target was defined but there is a
# default target, that one will be automatically used.
#
def target
target_idx = datastore['TARGET']
@ -411,7 +420,6 @@ class Exploit < Msf::Module
# stack pointer prior to executing any code. The number of bytes to adjust
# is indicated to the routine through the payload 'StackAdjustment'
# attribute or through a target's payload 'StackAdjustment' attribute.
# This number is, in turn, translated into
#
def stack_adjustment
if (target and target.payload_stack_adjustment)

View File

@ -10,12 +10,16 @@ module Msf
###
module Exploit::Brute
#
# Initializes an instance of an exploit module that supports brute force
# targets.
#
def initialize(info = {})
super
#
# Register BruteWait and BruteStep as two advanced options for this
# exploit even though not all targets may be brute force targets
# exploit even though not all targets may be brute force targets.
#
register_advanced_options(
[
@ -135,7 +139,7 @@ module Exploit::Brute
end
#
# Waits for the provide delay
# Waits for the provide delay.
#
def brute_wait(delay)
sleep(delay)

View File

@ -12,6 +12,9 @@ module Exploit::Remote::Ftp
include Exploit::Remote::Tcp
#
# Creates an instance of an FTP exploit module.
#
def initialize(info = {})
super

View File

@ -10,6 +10,10 @@ module Msf
###
module Exploit::Remote::HttpClient
#
# Initializes an exploit module that exploits a vulnerability in an HTTP
# server.
#
def initialize(info = {})
super

View File

@ -10,6 +10,9 @@ module Msf
###
module Exploit::Seh
#
# Creates an instance of an exploit that uses an SEH overwrite.
#
def initialize(info = {})
super

View File

@ -7,7 +7,11 @@ module Msf
#
###
module Exploit::Remote::Tcp
#
# Initializes an instance of an exploit module that exploits a
# vulnerability in a TCP server.
#
def initialize(info = {})
super
@ -187,7 +191,7 @@ module Exploit::Remote::TcpServer
protected
attr_accessor :service
attr_accessor :service # :nodoc:
end

View File

@ -12,6 +12,9 @@ module Msf
###
class ExploitDriver
#
# Initializes the exploit driver using the supplied framework instance.
#
def initialize(framework)
self.payload = nil
self.exploit = nil
@ -20,7 +23,7 @@ class ExploitDriver
end
#
# Specification of the exploit target index
# Specification of the exploit target index.
#
def target_idx=(target_idx)
if (target_idx)
@ -35,7 +38,7 @@ class ExploitDriver
end
#
# This method returns the currently selected target index
# This method returns the currently selected target index.
#
def target_idx
@target_idx

View File

@ -4,9 +4,6 @@ module Msf
###
#
# Handler
# -------
#
# This module acts as a base for all handler pseudo-modules. They aren't
# really modules, so don't get the wrong idea champs! They're merely
# mixed into dynamically generated payloads to handle monitoring for
@ -31,15 +28,26 @@ module Msf
###
module Handler
##
#
# Constants used with the ``handler'' method to indicate whether or not the
# connection was used
# connection was used.
#
##
#
# Returned by handlers to indicate that a socket has been claimed for use
# by the payload.
#
Claimed = "claimed"
#
# Returned by handlers to indicate that a socket has not been claimed for
# use.
#
Unused = "unused"
#
# Returns the handler type
# Returns the handler type.
#
def self.handler_type
return "none"
@ -74,25 +82,25 @@ module Handler
end
#
# Sets up the connection handler
# Sets up the connection handler.
#
def setup_handler
end
#
# Terminates the connection handler
# Terminates the connection handler.
#
def cleanup_handler
end
#
# Start monitoring for a connection
# Start monitoring for a connection.
#
def start_handler
end
#
# Stop monitoring for a connection
# Stop monitoring for a connection.
#
def stop_handler
end
@ -126,7 +134,7 @@ module Handler
#
# Waits for a session to be created as the result of a handler connection
# coming in. The return value is a session object instance on success or
# nil if the timeout expires
# nil if the timeout expires.
#
def wait_for_session(t = wfs_delay)
session = nil

View File

@ -14,14 +14,25 @@ module BindTcp
include Msf::Handler
#
# Returns the handler specific string representation, in this case
# 'bind_tcp'.
#
def self.handler_type
return "bind_tcp"
end
#
# Returns the connection oriented general handler type, in this case bind.
#
def self.general_handler_type
"bind"
end
#
# Initializes a bind handler and adds the options common to all bind
# payloads, such as local port.
#
def initialize(info = {})
super
@ -34,7 +45,7 @@ module BindTcp
end
#
# No setup to speak of
# No setup to speak of for bind handlers.
#
def setup_handler
end
@ -110,7 +121,7 @@ module BindTcp
protected
attr_accessor :conn_threads
attr_accessor :conn_threads # :nodoc:
end

View File

@ -10,14 +10,26 @@ module FindPort
include Msf::Handler
#
# Returns the string representation of the handler type, in this case
# 'find_port'.
#
def self.handler_type
return "find_port"
end
#
# Returns the connection oriented general handler type, in this case
# 'find'.
#
def self.general_handler_type
"find"
end
#
# Initializes the find port handler and adds the client port option that is
# required for port-based findsock payloads to function.
#
def initialize(info = {})
super
@ -124,7 +136,7 @@ protected
end
end
attr_accessor :_handler_return_value
attr_accessor :_handler_return_value # :nodoc:
end

View File

@ -12,14 +12,26 @@ module FindTag
include FindPort
#
# Returns the string representation of the handler type, in this case
# 'find_tag'.
#
def self.handler_type
return "find_tag"
end
#
# Returns the connection oriented general handler type, in this case
# 'find'.
#
def self.general_handler_type
"find"
end
#
# Initializes the find tag handler with the option that is required for all
# find-tag based payloads, such as the TAG that will be searched for.
#
def initialize(info = {})
super
@ -40,7 +52,7 @@ module FindTag
protected
#
# Prefix the stage with this...
# Prefix the stage with this.
#
def _find_prefix(sock)
if (self.respond_to?('stage_prefix') == true)
@ -51,7 +63,7 @@ protected
end
#
# Transmits the tag
# Transmits the tag.
#
def _send_id(sock)
if (self.payload_type == Msf::Payload::Type::Single)

View File

@ -10,12 +10,16 @@ module None
include Msf::Handler
#
# Returns the handler type
# Returns the handler type of none since payloads that use this handler
# have no connection.
#
def self.handler_type
return "none"
end
#
# Returns none to indicate no connection.
#
def self.general_handler_type
return "none"
end

View File

@ -15,14 +15,26 @@ module ReverseTcp
include Msf::Handler
#
# Returns the string representation of the handler type, in this case
# 'reverse_tcp'.
#
def self.handler_type
return "reverse_tcp"
end
#
# Returns the connection-described general handler type, in this case
# 'reverse'.
#
def self.general_handler_type
"reverse"
end
#
# Initializes the reverse TCP handler and ads the options that are required
# for all reverse TCP payloads, like local host and local port.
#
def initialize(info = {})
super
@ -38,7 +50,7 @@ module ReverseTcp
#
# Starts the listener but does not actually attempt
# to accept a connection. Throws socket exceptions
# if it fails to start the listener
# if it fails to start the listener.
#
def setup_handler
self.listener_sock = Rex::Socket::TcpServer.create(
@ -48,7 +60,7 @@ module ReverseTcp
end
#
# Closes the listener socket if one was created
# Closes the listener socket if one was created.
#
def cleanup_handler
if (self.listener_sock)
@ -99,7 +111,7 @@ module ReverseTcp
end
#
# Stops monitoring for an inbound connection
# Stops monitoring for an inbound connection.
#
def stop_handler
# Terminate the listener thread
@ -116,9 +128,9 @@ module ReverseTcp
protected
attr_accessor :listener_sock
attr_accessor :listener_thread
attr_accessor :conn_threads
attr_accessor :listener_sock # :nodoc:
attr_accessor :listener_thread # :nodoc:
attr_accessor :conn_threads # :nodoc:
end

View File

@ -92,6 +92,10 @@ class Module
require 'msf/core/module/reference'
require 'msf/core/module/target'
#
# Creates an instance of an abstract module using the supplied information
# hash.
#
def initialize(info = {})
self.module_info = info
@ -177,21 +181,21 @@ class Module
end
#
# Return the module's description
# Return the module's description.
#
def description
module_info['Description']
end
#
# Return the module's version information
# Return the module's version information.
#
def version
module_info['Version']
end
#
# Returns the hash that describes this module's compatibilities
# Returns the hash that describes this module's compatibilities.
#
def compat
module_info['Compat'] || {}
@ -247,42 +251,42 @@ class Module
end
#
# Return the module's abstract type
# Return the module's abstract type.
#
def type
raise NotImplementedError
end
#
# Return a comma separated list of author for this module
# Return a comma separated list of author for this module.
#
def author_to_s
return author.collect { |author| author.to_s }.join(", ")
end
#
# Enumerate each author
# Enumerate each author.
#
def each_author(&block)
author.each(&block)
end
#
# Return a comma separated list of supported architectures, if any
# Return a comma separated list of supported architectures, if any.
#
def arch_to_s
return arch.join(", ")
end
#
# Enumerate each architecture
# Enumerate each architecture.
#
def each_arch(&block)
arch.each(&block)
end
#
# Return whether or not the module supports the supplied architecture
# Return whether or not the module supports the supplied architecture.
#
def arch?(what)
return true if (what == ARCH_ANY)
@ -291,14 +295,14 @@ class Module
end
#
# Return a comma separated list of supported platforms, if any
# Return a comma separated list of supported platforms, if any.
#
def platform_to_s
return (platform.all?) ? [ "All" ] : platform.names
end
#
# Returns whether or not the module requires or grants high privileges
# Returns whether or not the module requires or grants high privileges.
#
def privileged?
return (privileged == true)
@ -327,35 +331,81 @@ class Module
# Just some handy quick checks
#
##
#
# Returns true if this module is an exploit module.
#
def exploit?
return (type == MODULE_EXPLOIT)
end
#
# Returns true if this module is a payload module.
#
def payload?
return (type == MODULE_PAYLOAD)
end
#
# Returns true if this module is an encoder module.
#
def encoder?
return (type == MODULE_ENCODER)
end
#
# Returns true if this module is a nop module.
#
def nop?
return (type == MODULE_NOP)
end
#
# Returns true if this module is a recon module.
#
def recon?
return (type == MODULE_RECON)
end
attr_reader :author, :arch, :platform, :references, :datastore, :options
#
# The array of zero or more authors.
#
attr_reader :author
#
# The array of zero or more architectures.
#
attr_reader :arch
#
# The array of zero or more platforms.
#
attr_reader :platform
#
# The reference count for the module.
#
attr_reader :references
#
# The module-specific datastore instance.
#
attr_reader :datastore
#
# The module-specific options.
#
attr_reader :options
#
# Whether or not this module requires privileged access.
#
attr_reader :privileged
protected
#
# The list of options that support merging in an information hash.
#
UpdateableOptions = [ "Name", "Description", "Alias" ]
# Sets the modules unsupplied info fields to their default values
#
# Sets the modules unsupplied info fields to their default values.
#
def set_defaults
self.module_info = {
'Name' => 'No module name',
@ -398,7 +448,7 @@ protected
end
#
# Register options with a specific owning class
# Register options with a specific owning class.
#
def register_options(options, owner = self.class)
self.options.add_options(options, owner)
@ -406,7 +456,7 @@ protected
end
#
# Register advanced options with a specific owning class
# Register advanced options with a specific owning class.
#
def register_advanced_options(options, owner = self.class)
self.options.add_advanced_options(options, owner)
@ -415,7 +465,7 @@ protected
#
# Removes the supplied options from the module's option container
# and data store
# and data store.
#
def deregister_options(*names)
names.each { |name|
@ -470,7 +520,7 @@ protected
end
#
# Checks and merges the supplied key/value pair in the supplied hash
# Checks and merges the supplied key/value pair in the supplied hash.
#
def merge_check_key(info, name, val)
if (self.respond_to?("merge_info_#{name.downcase}"))
@ -505,35 +555,35 @@ protected
end
#
# Merge aliases with an underscore delimiter
# Merge aliases with an underscore delimiter.
#
def merge_info_alias(info, val)
merge_info_string(info, 'Alias', val, '_')
end
#
# Merges the module name
# Merges the module name.
#
def merge_info_name(info, val)
merge_info_string(info, 'Name', val, ', ', true)
end
#
# Merges the module description
# Merges the module description.
#
def merge_info_description(info, val)
merge_info_string(info, 'Description', val)
end
#
# Merge the module version
# 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
# Merges a given key in the info hash with a delimiter.
#
def merge_info_string(info, key, val, delim = ', ', inverse = false)
if (info[key])
@ -548,7 +598,7 @@ protected
end
#
# Merges options
# Merges options.
#
def merge_info_options(info, val, advanced = false)
key_name = ((advanced) ? 'Advanced' : '') + 'Options'
@ -567,15 +617,15 @@ protected
end
#
# Merges advanced options
# Merges advanced options.
#
def merge_info_advancedoptions(info, val)
merge_info_options(info, val, true)
end
attr_accessor :module_info
attr_writer :author, :arch, :platform, :references, :datastore, :options
attr_writer :privileged
attr_accessor :module_info # :nodoc:
attr_writer :author, :arch, :platform, :references, :datastore, :options # :nodoc:
attr_writer :privileged # :nodoc:
end

View File

@ -39,14 +39,14 @@ class Msf::Module::Platform
end
#
# Calls the class method
# Calls the class method.
#
def find_children
self.class.find_children
end
#
# The magic to try to build out a Platform from a string
# The magic to try to build out a Platform from a string.
#
def self.find_platform(str)
# remove any whitespace and downcase
@ -64,7 +64,7 @@ class Msf::Module::Platform
end
#
# Finds all inherited children from a given module
# Finds all inherited children from a given module.
#
def self.find_children
constants.map { |c|
@ -78,7 +78,7 @@ class Msf::Module::Platform
#
# Builds the abbreviation set for every module starting from
# a given point
# a given point.
#
def self.build_child_platform_abbrev(mod)
# Flush out any non-class and non-inherited children
@ -127,7 +127,7 @@ class Msf::Module::Platform
#
# Finds the module that best matches the supplied string (or a portion of
# the string)
# the string).
#
def self.find_portion(mod, str)
# Check to see if we've built the abbreviated cache
@ -170,8 +170,8 @@ class Msf::Module::Platform
return best
end
private_class_method :build_child_platform_abbrev
private_class_method :find_portion
private_class_method :build_child_platform_abbrev # :nodoc:
private_class_method :find_portion # :nodoc:
##
#

View File

@ -2,39 +2,55 @@ require 'msf/core'
###
#
# A reference to some sort of information.
# A reference to some sort of information. This is typically a URL, but could
# be any type of referential value that people could use to research a topic.
#
###
class Msf::Module::Reference
#
# Serialize a reference from a string.
#
def self.from_s(str)
return self.new(str)
end
#
# Initializes a reference from a string.
#
def initialize(in_str)
self.str = in_str
end
#
# Compares references
# Compares references to see if their equal.
#
def ==(tgt)
return (tgt.to_s == to_s)
end
#
# Returns the reference as a string.
#
def to_s
return self.str
end
#
# Serializes the reference instance from a string.
#
def from_s(in_str)
self.str = in_str
end
#
# The reference string.
#
attr_reader :str
protected
attr_writer :str
attr_writer :str # :nodoc:
end
@ -46,7 +62,7 @@ end
class Msf::Module::SiteReference < Msf::Module::Reference
#
# Class method that translates a URL into a site reference instance
# Class method that translates a URL into a site reference instance.
#
def self.from_s(str)
instance = self.new
@ -58,6 +74,10 @@ class Msf::Module::SiteReference < Msf::Module::Reference
return instance
end
#
# Initializes a site reference from an array. ary[0] is the site and
# ary[1] is the site context identifier, such as OSVDB.
#
def self.from_a(ary)
return nil if (ary.length < 2)
@ -65,7 +85,7 @@ class Msf::Module::SiteReference < Msf::Module::Reference
end
#
# Initialize the site reference
# Initialize the site reference.
#
def initialize(in_site = nil, in_ctx_id = nil)
self.ctx_id = in_ctx_id
@ -85,14 +105,14 @@ class Msf::Module::SiteReference < Msf::Module::Reference
end
#
# Returns the absolute site URL
# Returns the absolute site URL.
#
def to_s
return site || ''
end
#
# Serializes a site URL string
# Serializes a site URL string.
#
def from_s(str)
if (/(http:\/\/|https:\/\/|ftp:\/\/)/.match(str))
@ -104,7 +124,14 @@ class Msf::Module::SiteReference < Msf::Module::Reference
return true
end
attr_reader :site, :ctx_id
#
# The site being referenced.
#
attr_reader :site
#
# The context identifier of the site, such as OSVDB.
#
attr_reader :ctx_id
protected

View File

@ -9,15 +9,17 @@ class Msf::Module::Target
###
#
# Bruteforce
# ----------
#
# Target-specific brute force information, such as the addresses
# to step, the step size (if the framework default is bad), and
# other stuff.
#
###
class Bruteforce < Hash
#
# Initializes a brute force target from the supplied brute forcing
# information.
#
def initialize(hash)
update(hash)
end
@ -56,7 +58,9 @@ class Msf::Module::Target
end
#
# Returns the default step direction
# Returns the default step direction. -1 indicates that brute forcing
# should go toward lower addresses. 1 indicates that brute forcing
# should go toward higher addresses.
#
def default_direction
dd = self['DefaultDirection']
@ -77,7 +81,7 @@ class Msf::Module::Target
end
#
# Serialize from an array to a Target instance
# Serialize from an array to a Target instance.
#
def self.from_a(ary)
return nil if (ary.length < 2)
@ -86,14 +90,43 @@ class Msf::Module::Target
end
#
# Transforms the supplied source into an array of Target's
# Transforms the supplied source into an array of Targets.
#
def self.transform(src)
Rex::Transformer.transform(src, Array, [ self, String ], 'Target')
end
#
# Init it up!
# Initializes an instance of a bruteforce target from the supplied
# information. The hash of options that this constructor takes is as
# follows:
#
# Platform
#
# The platform(s) that this target is to operate against.
#
# SaveRegisters
#
# The registers that must be saved by NOP generators.
#
# Arch
#
# The architectures, if any, that this target is specific to (E.g.
# ARCH_X86).
#
# Bruteforce
#
# Settings specific to a target that supports brute forcing. See the
# BruteForce class.
#
# Ret
#
# The target-specific return address or addresses that will be used.
#
# Payload
#
# Payload-specific options, such as append, prepend, and other values that
# can be set on a per-exploit or per-target basis.
#
def initialize(name, opts)
opts = {} if (!opts)
@ -116,7 +149,7 @@ class Msf::Module::Target
end
#
# Index the options directly
# Index the options directly.
#
def [](key)
opts[key]
@ -136,41 +169,90 @@ class Msf::Module::Target
#
##
#
# Payload prepend information for this target.
#
def payload_prepend
opts['Payload'] ? opts['Payload']['Prepend'] : nil
end
#
# Payload append information for this target.
#
def payload_append
opts['Payload'] ? opts['Payload']['Append'] : nil
end
#
# Payload prepend encoder information for this target.
#
def payload_prepend_encoder
opts['Payload'] ? opts['Payload']['PrependEncoder'] : nil
end
#
# Payload stack adjustment information for this target.
#
def payload_stack_adjustment
opts['Payload'] ? opts['Payload']['StackAdjustment'] : nil
end
#
# Payload max nops information for this target.
#
def payload_max_nops
opts['Payload'] ? opts['Payload']['MaxNops'] : nil
end
#
# Payload min nops information for this target.
#
def payload_min_nops
opts['Payload'] ? opts['Payload']['MinNops'] : nil
end
#
# Payload space information for this target.
#
def payload_space
opts['Payload'] ? opts['Payload']['Space'] : nil
end
attr_reader :name, :platform, :arch, :opts, :ret, :save_registers
#
# The name of the target (E.g. Windows XP SP0/SP1)
#
attr_reader :name
#
# The platforms that this target is for.
#
attr_reader :platform
#
# The architectures, if any, that the target is specific to.
#
attr_reader :arch
#
# The target-specific options, like payload settings and other stuff like
# that.
#
attr_reader :opts
#
# An alias for the target 'Ret' option.
#
attr_reader :ret
#
# The list of registers that need to be saved.
#
attr_reader :save_registers
#
# The bruteforce target information that will be non-nil if a Bruteforce
# option is passed to the constructor of the class.
#
attr_reader :bruteforce
protected
attr_writer :name, :platform, :arch, :opts, :ret, :save_registers
attr_writer :bruteforce
attr_writer :name, :platform, :arch, :opts, :ret, :save_registers # :nodoc:
attr_writer :bruteforce # :nodoc:
end

View File

@ -13,6 +13,10 @@ class ModuleSet < Hash
include Framework::Offspring
#
# Initializes a module set that will contain modules of a specific type and
# expose the mechanism necessary to create instances of them.
#
def initialize(type = nil)
self.module_type = type
@ -59,7 +63,7 @@ class ModuleSet < Hash
end
#
# Enumerates each module class in the set
# Enumerates each module class in the set.
#
def each_module(opts = {}, &block)
mod_sorted = self.sort if (mod_sorted == nil)
@ -86,7 +90,7 @@ class ModuleSet < Hash
end
#
# Dummy placeholder to relcalculate aliases and other fun things
# Dummy placeholder to relcalculate aliases and other fun things.
#
def recalculate
end
@ -147,7 +151,7 @@ protected
end
#
# Adds a module with a the supplied name
# Adds a module with a the supplied name.
#
def add_module(module_class, name, file_path = nil)
# Duplicate the module class so that we can operate on a
@ -209,6 +213,10 @@ class ModuleManager < ModuleSet
include Framework::Offspring
#
# Initializes an instance of the overall module manager using the supplied
# framework instance.
#
def initialize(framework)
self.module_paths = []
self.module_history = {}
@ -234,7 +242,7 @@ class ModuleManager < ModuleSet
end
#
# Creates a module using the supplied name
# Creates a module using the supplied name.
#
def create(name)
# Check to see if it has a module type prefix. If it does,
@ -252,35 +260,35 @@ class ModuleManager < ModuleSet
#
#
# Returns the set of loaded encoder module classes
# Returns the set of loaded encoder module classes.
#
def encoders
return module_sets[MODULE_ENCODER]
end
#
# Returns the set of loaded exploit module classes
# Returns the set of loaded exploit module classes.
#
def exploits
return module_sets[MODULE_EXPLOIT]
end
#
# Returns the set of loaded nop module classes
# Returns the set of loaded nop module classes.
#
def nops
return module_sets[MODULE_NOP]
end
#
# Returns the set of loaded payload module classes
# Returns the set of loaded payload module classes.
#
def payloads
return module_sets[MODULE_PAYLOAD]
end
#
# Returns the set of loaded recon module classes
# Returns the set of loaded recon module classes.
#
def recon
return module_sets[MODULE_RECON]
@ -293,7 +301,7 @@ class ModuleManager < ModuleSet
##
#
# Adds a path to be searched for new modules
# Adds a path to be searched for new modules.
#
def add_module_path(path)
path.sub!(/#{File::SEPARATOR}$/, '')
@ -311,7 +319,7 @@ class ModuleManager < ModuleSet
end
#
# Removes a path from which to search for modules
# Removes a path from which to search for modules.
#
def remove_module_path(path)
module_paths.delete(path)
@ -383,7 +391,7 @@ protected
#
# Load all of the modules from the supplied module path (independent of
# module type)
# module type).
#
def load_modules(path)
loaded = {}
@ -461,7 +469,9 @@ protected
return counts
end
#
# Loads a module from the supplied file.
#
def load_module_from_file(path, file, loaded, recalc, counts)
# If the file doesn't end in the expected extension...
return if (!file.match(/\.rb$/))
@ -569,7 +579,7 @@ protected
#
# Checks to see if the supplied file has changed (if it's even in the
# cache)
# cache).
#
def has_module_file_changed?(file)
return (module_history_mtime[file] != File.new(file).mtime)
@ -577,7 +587,7 @@ protected
#
# Returns the module object that is associated with the supplied module
# name
# name.
#
def mod_from_name(name)
obj = Msf
@ -599,7 +609,7 @@ protected
#
# Called when a module is initially loaded such that it can be
# categorized accordingly
# categorized accordingly.
#
def on_module_load(mod, type, name, file_path)
# Payload modules require custom loading as the individual files
@ -663,9 +673,9 @@ protected
end
end
attr_accessor :modules, :module_sets
attr_accessor :module_paths
attr_accessor :module_history, :module_history_mtime
attr_accessor :modules, :module_sets # :nodoc:
attr_accessor :module_paths # :nodoc:
attr_accessor :module_history, :module_history_mtime # :nodoc:
end

View File

@ -10,6 +10,14 @@ module Msf
###
class OptBase
#
# Initializes a named option with the supplied attribute array.
# The array is composed of three values.
#
# attrs[0] = required (boolean type)
# attrs[1] = description (string)
# attrs[2] = default value
#
def initialize(in_name, attrs = [])
self.name = in_name
self.advanced = false
@ -18,35 +26,73 @@ class OptBase
self.default = attrs[2]
end
#
# Returns true if this is a required option.
#
def required?
return required
end
#
# Returns true if this is an advanced option.
#
def advanced?
return advanced
end
#
# Returns true if the supplied type is equivalent to this option's type.
#
def type?(in_type)
return (type == in_type)
end
#
# If it's required and the value is nil or empty, then it's not valid.
#
def valid?(value)
return (required? and (value == nil or value.to_s.empty?)) ? false : true
end
#
# Returns the value of the option as a string.
#
def to_s
return value.to_s
end
attr_reader :name, :required, :desc, :default
#
# The name of the option.
#
attr_reader :name
#
# Whether or not the option is required.
#
attr_reader :required
#
# The description of the option.
#
attr_reader :desc
#
# The default value of the option.
#
attr_reader :default
#
# Storing the name of the option.
#
attr_writer :name
#
# Whether or not this is an advanced option.
#
attr_accessor :advanced
#
# The module or entity that owns this option.
#
attr_accessor :owner
protected
attr_writer :required, :desc, :default
attr_writer :required, :desc, :default # :nodoc:
end
###
@ -63,18 +109,33 @@ end
#
###
###
#
# Mult-byte character string option.
#
###
class OptString < OptBase
def type
return 'string'
end
end
###
#
# Raw, arbitrary data option.
#
###
class OptRaw < OptBase
def type
return 'raw'
end
end
###
#
# Boolean option.
#
###
class OptBool < OptBase
def type
return 'bool'
@ -102,6 +163,11 @@ class OptBool < OptBase
end
end
###
#
# Network port option.
#
###
class OptPort < OptBase
def type
return 'port'
@ -117,6 +183,11 @@ class OptPort < OptBase
end
end
###
#
# Network address option.
#
###
class OptAddress < OptBase
def type
return 'address'
@ -135,6 +206,11 @@ class OptAddress < OptBase
end
end
###
#
# File system path option.
#
###
class OptPath < OptBase
def type
return 'path'
@ -150,6 +226,11 @@ class OptPath < OptBase
end
end
###
#
# Integer option.
#
###
class OptInt < OptBase
def type
return 'integer'
@ -189,14 +270,14 @@ class OptionContainer < Hash
end
#
# Return the value associated with the supplied name
# Return the value associated with the supplied name.
#
def [](name)
return get(name)
end
#
# Return the option associated with the supplied name
# Return the option associated with the supplied name.
#
def get(name)
begin
@ -230,7 +311,7 @@ class OptionContainer < Hash
end
#
# Removes an option
# Removes an option.
#
def remove_option(name)
delete(name)
@ -240,7 +321,7 @@ class OptionContainer < Hash
end
#
# Adds one or more options
# Adds one or more options.
#
def add_options(opts, owner = nil, advanced = false)
return false if (opts == nil)
@ -253,7 +334,7 @@ class OptionContainer < Hash
end
#
# Add options from a hash of names
# Add options from a hash of names.
#
def add_options_hash(opts, owner = nil, advanced = false)
opts.each_pair { |name, opt|
@ -262,7 +343,7 @@ class OptionContainer < Hash
end
#
# Add options from an array of option instances or arrays
# Add options from an array of option instances or arrays.
#
def add_options_array(opts, owner = nil, advanced = false)
opts.each { |opt|
@ -271,7 +352,7 @@ class OptionContainer < Hash
end
#
# Adds an option
# Adds an option.
#
def add_option(option, name = nil, owner = nil, advanced = false)
if (option.kind_of?(Array))
@ -292,7 +373,7 @@ class OptionContainer < Hash
end
#
# Alias to add advanced options that sets the proper state flag
# Alias to add advanced options that sets the proper state flag.
#
def add_advanced_options(opts, owner = nil)
return false if (opts == nil)
@ -302,7 +383,7 @@ class OptionContainer < Hash
#
# Make sures that each of the options has a value of a compatible
# format and that all the required options are set
# format and that all the required options are set.
#
def validate(datastore)
errors = []
@ -345,11 +426,14 @@ class OptionContainer < Hash
each_pair(&block)
end
#
# The sorted array of options.
#
attr_reader :sorted
protected
attr_writer :sorted
attr_writer :sorted # :nodoc:
end

View File

@ -17,9 +17,11 @@ class Payload < Msf::Module
# Platform specific includes
require 'msf/core/payload/windows'
##
#
# Payload types
#
##
module Type
#
# Single payload type. These types of payloads are self contained and
@ -42,6 +44,9 @@ class Payload < Msf::Module
Stage = (1 << 2)
end
#
# Creates an instance of a payload module using the supplied information.
#
def initialize(info = {})
super

View File

@ -10,6 +10,9 @@ require 'msf/core'
###
module Msf::Payload::Single
#
# Sets the payload type to that of a single payload.
#
def payload_type
return Msf::Payload::Type::Single
end

View File

@ -7,6 +7,9 @@ require 'msf/core'
###
module Msf::Payload::Stager
#
# Sets the payload type to a stager.
#
def payload_type
return Msf::Payload::Type::Stager
end

View File

@ -11,7 +11,7 @@ require 'msf/core'
module Msf::Payload::Windows
#
# ROR hash associations for some of the exit technique routines
# ROR hash associations for some of the exit technique routines.
#
@@exit_types =
{
@ -20,6 +20,12 @@ module Msf::Payload::Windows
'process' => 0x73e2d87e, # ExitProcess
}
#
# This mixin is chained within payloads that target the Windows platform.
# It provides special variable substitution for things like EXITFUNC and
# automatically adds it as a required option for exploits that use windows
# payloads.
#
def initialize(info = {})
if (info['Alias'])
info['Alias'] = 'windows/' + info['Alias']

View File

@ -15,6 +15,10 @@ module Msf
###
class PayloadSet < ModuleSet
#
# Creates an instance of a payload set which is just a specialized module
# set class that has custom handling for payloads.
#
def initialize(manager)
super(MODULE_PAYLOAD)

View File

@ -11,6 +11,11 @@ module Msf
###
module ReconEvent
###
#
# The types of changes an entity can undergo.
#
###
module EntityChangeType
Add = 1
Update = 2

View File

@ -99,7 +99,7 @@ module Container
protected
attr_accessor :_attr_hash
attr_accessor :_attr_hash # :nodoc:
end

View File

@ -30,6 +30,10 @@ class Group
}
end
#
# Initializes the attribute group which is simply a container of
# attributes.
#
def initialize
initialize_attributes
end

View File

@ -17,9 +17,11 @@ class Recon
###
class Discoverer < Msf::Recon
##
#
# The types of discoverer recon modules that are known about by default.
#
##
module Type
#
@ -39,10 +41,12 @@ class Discoverer < Msf::Recon
end
##
#
# The set of flags that discoverer modules can use to instruct the
# framework (or themselves) on how to operate.
#
#
module Flags
#
# This flag is used to indicate that a discoverer supports multithreaded
@ -54,6 +58,11 @@ class Discoverer < Msf::Recon
require 'msf/core/recon/discoverer/host'
require 'msf/core/recon/discoverer/service'
#
# Initializes the base of a recon discoverer module and adds any advanced
# options that may be useful, like the number of threads the framework
# should use for scanning.
#
def initialize(info = {})
super
@ -267,9 +276,9 @@ protected
}
end
attr_accessor :discovery_threads
attr_accessor :discovery_thread_mutex
attr_accessor :discovery_thread_event
attr_accessor :discovery_threads # :nodoc:
attr_accessor :discovery_thread_mutex # :nodoc:
attr_accessor :discovery_thread_event # :nodoc:
end

View File

@ -13,6 +13,10 @@ class Discoverer
###
class Host < Msf::Recon::Discoverer
#
# Initializes an instance of a host discoverer recon module and adds
# options that are common to all host discoverers, like subnet and netmask.
#
def initialize(info = {})
super
@ -197,8 +201,8 @@ protected
1
end
attr_accessor :swalker
attr_accessor :swalker_mutex
attr_accessor :swalker # :nodoc:
attr_accessor :swalker_mutex # :nodoc:
end
@ -213,6 +217,10 @@ end
#
###
class HostAttribute < Msf::Recon::Discoverer
#
# Returns Type::HostAttribute.
#
def discoverer_type
Type::HostAttribute
end

View File

@ -10,6 +10,11 @@ class Discoverer
###
class Service < Msf::Recon::Discoverer
#
# Initializes a service discoverer recon module that is responsible for
# locating running services or information about services that are running
# on hosts.
#
def initialize(info = {})
super

View File

@ -47,7 +47,7 @@ class Entity
'unknown'
end
attr_accessor :needs_register
attr_accessor :needs_register # :nodoc:
end

View File

@ -14,7 +14,10 @@ require 'msf/core/recon/entity/container'
class Group
include Container
#
# Initializes an entity group which is simply an entity container.
#
def initialize
initialize_entities
end
@ -30,6 +33,11 @@ end
###
class ServiceGroup < Group
#
# Initializes a group of services and breaks them down into their
# sub-protocols which can be accessed through the 'tcp' and 'udp'
# attributes.
#
def initialize
super
@ -38,11 +46,18 @@ class ServiceGroup < Group
self.udp = Group.new
end
attr_reader :tcp, :udp
#
# This attribute is a sub-group that contains all TCP services.
#
attr_reader :tcp
#
# This attribute is a sub-group that contains all UDP services.
#
attr_reader :udp
protected
attr_writer :tcp, :udp
attr_writer :tcp, :udp # :nodoc:
end

View File

@ -38,6 +38,10 @@ class Host < Entity
end
#
# Initializes a host entity with the supplied address after being found
# during recon.
#
def initialize(address)
super()

View File

@ -13,6 +13,9 @@ class Entity
###
class Service < Entity
#
# Initializes a service entity that has been found to be running on a host.
#
def initialize(proto, port = nil)
super()

View File

@ -9,11 +9,15 @@ module Msf
###
module SessionEvent
# Called when a session is opened
#
# Called when a session is opened.
#
def on_session_open(session)
end
# Called when a session is closed
#
# Called when a session is closed.
#
def on_session_close(session)
end
@ -61,38 +65,38 @@ module Session
end
#
# Sets the session's name
# Sets the session's name.
#
def name=(name)
self.sname = name
end
#
# Returns the description of the session
# Returns the description of the session.
#
def desc
end
#
# Returns the type of session in use
# Returns the type of session in use.
#
def type
end
#
# Returns the local side of the tunnel
# Returns the local side of the tunnel.
#
def tunnel_local
end
#
# Returns the peer side of the tunnel
# Returns the peer side of the tunnel.
#
def tunnel_peer
end
#
# Returns a pretty representation of the tunnel
# Returns a pretty representation of the tunnel.
#
def tunnel_to_s
"#{(tunnel_local || '??').to_s} -> #{(tunnel_peer || '??').to_s}"
@ -146,7 +150,7 @@ module Session
##
#
# Sets the vector through which this session was realized
# Sets the vector through which this session was realized.
#
def set_via(opts)
self.via = opts || {}
@ -181,11 +185,22 @@ module Session
false
end
attr_accessor :framework, :sid, :sname
#
# The framework instance that created this session.
#
attr_accessor :framework
#
# The session unique identifier.
#
attr_accessor :sid
#
# The session name.
#
attr_accessor :sname
protected
attr_accessor :via
attr_accessor :via # :nodoc:
end

View File

@ -13,14 +13,14 @@ module Basic
include Interactive
#
# Description of the session
# Description of the session.
#
def desc
"Basic I/O"
end
#
# Basic session
# Basic session.
#
def type
"basic"

View File

@ -18,7 +18,7 @@ module Interactive
include Rex::Ui::Interactive
#
# Initialize's the session
# Initializes the session.
#
def initialize(rstream)
self.rstream = rstream
@ -33,14 +33,14 @@ module Interactive
end
#
# Returns the local information
# Returns the local information.
#
def tunnel_local
rstream.localinfo
end
#
# Returns the remote peer information
# Returns the remote peer information.
#
def tunnel_peer
begin
@ -66,20 +66,20 @@ module Interactive
protected
#
# Stub method that is meant to handler interaction
# Stub method that is meant to handler interaction.
#
def _interact
end
#
# Check to see if the user wants to abort
# Check to see if the user wants to abort.
#
def _interrupt
user_want_abort?
end
#
# Check to see if we should suspnd
# Check to see if we should suspend.
#
def _suspend
# Ask the user if they would like to background the session
@ -96,7 +96,7 @@ protected
end
#
# Checks to see if the user wants to abort
# Checks to see if the user wants to abort.
#
def user_want_abort?
prompt_yesno("Abort session #{name}?")

View File

@ -9,7 +9,6 @@ module Provider
# MultiCommandShell classes must also provide a mechanism by which they can
# implement the SingleCommandShell interface.
#
#
###
module MultiCommandShell
@ -17,14 +16,14 @@ module MultiCommandShell
#
# Initializes the default command shell as expected from
# SingleCommandShell
# SingleCommandShell.
#
def init_shell()
raise NotImplementedError
end
#
# Opens a new command shell context and returns the handle
# Opens a new command shell context and returns the handle.
#
def open_shell()
raise NotImplementedError

View File

@ -17,19 +17,19 @@ module SingleCommandExecution
end
#
# Reads output from the command
# Reads output from the command.
#
def read_cmd(length = nil)
end
#
# Writes input to the command
# Writes input to the command.
#
def write_cmd(buf)
end
#
# Closes the command that was executed
# Closes the command that was executed.
#
def close_cmd()
end

View File

@ -11,28 +11,28 @@ module Provider
module SingleCommandShell
#
# Initializes the command shell
# Initializes the command shell.
#
def init_shell()
raise NotImplementedError
end
#
# Reads data from the command shell
# Reads data from the command shell.
#
def read_shell(length = nil)
raise NotImplementedError
end
#
# Writes data to the command shell
# Writes data to the command shell.
#
def write_shell(buf)
raise NotImplementedError
end
#
# Closes the command shell
# Closes the command shell.
#
def close_shell()
raise NotImplementedError

View File

@ -55,7 +55,7 @@ class SessionManager < Hash
end
#
# Deregisters the supplied session object with the framework
# Deregisters the supplied session object with the framework.
#
def deregister(session)
# Tell the framework that we have a parting session
@ -75,7 +75,7 @@ class SessionManager < Hash
end
#
# Returns the session associated with the supplied sid, if any
# Returns the session associated with the supplied sid, if any.
#
def get(sid)
return self[sid.to_i]
@ -83,7 +83,7 @@ class SessionManager < Hash
protected
attr_accessor :sid_pool, :sessions
attr_accessor :sid_pool, :sessions # :nodoc:
end

View File

@ -107,6 +107,9 @@ _| _| _|\___|\__|\__,_|____/ .__/ _|\___/ _|\__|
'
]
#
# Returns a random metasploit logo.
#
def self.to_s
Logos[rand(Logos.length)]
end

View File

@ -2,28 +2,51 @@ module Msf
module Ui
module Console
###
#
# The common command dispatcher base class that is shared for component-specific
# command dispatching.
#
###
module CommandDispatcher
include Rex::Ui::Text::DispatcherShell::CommandDispatcher
#
# Initializes a command dispatcher instance.
#
def initialize(driver)
super
self.driver = driver
end
#
# Returns the framework instance associated with this command dispatcher.
#
def framework
return driver.framework
end
#
# Returns the active module if one has been selected, otherwise nil is
# returned.
#
def active_module
driver.active_module
end
#
# Sets the active module for this driver instance.
#
def active_module=(mod)
driver.active_module = mod
end
#
# Logs an error message to the screen and the log file. The callstack is
# also printed.
#
def log_error(err)
print_error(err)
@ -33,18 +56,32 @@ module CommandDispatcher
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_1)
end
#
# The driver that this command dispatcher is associated with.
#
attr_accessor :driver
end
###
#
# Module-specific command dispatcher.
#
###
module ModuleCommandDispatcher
include Msf::Ui::Console::CommandDispatcher
#
# The active driver module, if any.
#
def mod
return driver.active_module
end
#
# Sets the active driver module.
#
def mod=(m)
self.driver.active_module = m
end

View File

@ -9,6 +9,12 @@ module Ui
module Console
module CommandDispatcher
###
#
# Command dispatcher for core framework commands, such as module loading,
# session interaction, and other general things.
#
###
class Core
include Msf::Ui::Console::CommandDispatcher
@ -56,6 +62,9 @@ class Core
}
end
#
# Returns the name of the command dispatcher.
#
def name
"Core"
end
@ -80,7 +89,7 @@ class Core
end
#
# Display one of the fabulous banners
# Display one of the fabulous banners.
#
def cmd_banner(*args)
banner = Banner.to_s + "\n\n"
@ -100,7 +109,7 @@ class Core
end
#
# Instructs the driver to stop executing
# Instructs the driver to stop executing.
#
def cmd_exit(*args)
driver.stop
@ -109,14 +118,14 @@ class Core
alias cmd_quit cmd_exit
#
# Displays the command help banner
# Displays the command help banner.
#
def cmd_help(*args)
print(driver.help_to_s)
end
#
# Displays information about one or more module
# Displays information about one or more module.
#
def cmd_info(*args)
if (args.length == 0)
@ -351,7 +360,7 @@ class Core
end
#
# Adds one or more search paths
# Adds one or more search paths.
#
def cmd_search(*args)
if (args.length == 0)
@ -467,7 +476,7 @@ class Core
end
#
# Sets a name to a value in a context aware environment
# Sets a name to a value in a context aware environment.
#
def cmd_set(*args)
@ -526,7 +535,7 @@ class Core
end
#
# Sets the supplied variables in the global datastore
# Sets the supplied variables in the global datastore.
#
def cmd_setg(*args)
args.unshift('-g')
@ -536,7 +545,7 @@ class Core
#
# Displays the list of modules based on their type, or all modules if
# no type is provided
# no type is provided.
#
def cmd_show(*args)
mod = self.active_module
@ -578,7 +587,7 @@ class Core
end
#
# Unsets a value if it's been set
# Unsets a value if it's been set.
#
def cmd_unset(*args)
@ -619,7 +628,7 @@ class Core
end
#
# Unsets variables in the global data store
# Unsets variables in the global data store.
#
def cmd_unsetg(*args)
args.unshift('-g')
@ -628,7 +637,7 @@ class Core
end
#
# Uses a module
# Uses a module.
#
def cmd_use(*args)
if (args.length == 0)
@ -711,7 +720,7 @@ class Core
protected
#
# Recalculates the tab completion list
# Recalculates the tab completion list.
#
def recalculate_tab_complete
self.tab_complete_items = []
@ -726,19 +735,19 @@ protected
# Module list enumeration
#
def show_encoders
def show_encoders # :nodoc:
show_module_set("Encoders", framework.encoders)
end
def show_nops
def show_nops # :nodoc:
show_module_set("NOP Generators", framework.nops)
end
def show_exploits
def show_exploits # :nodoc:
show_module_set("Exploits", framework.exploits)
end
def show_payloads
def show_payloads # :nodoc:
# If an active module has been selected and it's an exploit, get the
# list of compatible payloads and display them
if (active_module and active_module.exploit? == true)
@ -754,11 +763,11 @@ protected
end
end
def show_recon
def show_recon # :nodoc:
show_module_set("Recon", framework.recon)
end
def show_options(mod)
def show_options(mod) # :nodoc:
print("\n" + Serializer::ReadableText.dump_options(mod) + "\n")
# If it's an exploit and a payload is defined, create it and
@ -779,11 +788,11 @@ protected
end
end
def show_advanced_options(mod)
def show_advanced_options(mod) # :nodoc:
print("\n" + Serializer::ReadableText.dump_advanced_options(mod) + "\n")
end
def show_module_set(type, module_set)
def show_module_set(type, module_set) # :nodoc:
tbl = generate_module_table(type)
module_set.each_module { |refname, mod|
@ -795,7 +804,7 @@ protected
print(tbl.to_s)
end
def generate_module_table(type)
def generate_module_table(type) # :nodoc:
Table.new(
Table::Style::Default,
'Header' => type,

View File

@ -3,10 +3,18 @@ module Ui
module Console
module CommandDispatcher
###
#
# Command dispatcher for encoder modules.
#
###
class Encoder
include Msf::Ui::Console::ModuleCommandDispatcher
#
# Returns the name of the command dispatcher.
#
def name
"Encoder"
end

View File

@ -3,6 +3,11 @@ module Ui
module Console
module CommandDispatcher
###
#
# Exploit module command dispatcher.
#
###
class Exploit
include Msf::Ui::Console::ModuleCommandDispatcher
@ -17,6 +22,9 @@ class Exploit
"-t" => [ true, "The target index to use. If none is specified, TARGET is used." ],
"-z" => [ false, "Do not interact with the session after successful exploitation." ])
#
# Returns the hash of exploit module specific commands.
#
def commands
{
"check" => "Check to see if a target is vulnerable",
@ -26,12 +34,15 @@ class Exploit
}
end
#
# Returns the name of the command dispatcher.
#
def name
"Exploit"
end
#
# Checks to see if a target is vulnerable
# Checks to see if a target is vulnerable.
#
def cmd_check(*args)
begin
@ -61,7 +72,7 @@ class Exploit
end
#
# Launches an exploitation attempt
# Launches an exploitation attempt.
#
def cmd_exploit(*args)
opt_str = nil
@ -145,7 +156,8 @@ class Exploit
end
#
# Reloads an exploit module and checks the target to see if it's vulnerable
# Reloads an exploit module and checks the target to see if it's
# vulnerable.
#
def cmd_rcheck(*args)
begin
@ -158,7 +170,7 @@ class Exploit
end
#
# Reloads an exploit module and launches an exploit
# Reloads an exploit module and launches an exploit.
#
def cmd_rexploit(*args)
begin

View File

@ -5,6 +5,11 @@ module Ui
module Console
module CommandDispatcher
###
#
# NOP module command dispatcher.
#
###
class Nop
include Msf::Ui::Console::ModuleCommandDispatcher
@ -15,18 +20,24 @@ class Nop
"-s" => [ true, "The comma separated list of registers to save." ],
"-t" => [ true, "The output type: ruby, perl, c, or raw." ])
#
# Returns the hash of supported commands.
#
def commands
{
"generate" => "Generates a NOP sled",
}
end
#
# Returns the name of the command dispatcher.
#
def name
"Nop"
end
#
# Generates a NOP sled
# Generates a NOP sled.
#
def cmd_generate(*args)

View File

@ -5,6 +5,11 @@ module Ui
module Console
module CommandDispatcher
###
#
# Payload module command dispatcher.
#
###
class Payload
include Msf::Ui::Console::ModuleCommandDispatcher
@ -17,18 +22,24 @@ class Payload
"-s" => [ true, "NOP sled length." ],
"-t" => [ true, "The output type: ruby, perl, c, or raw." ])
#
# Returns the hash of commands specific to payload modules.
#
def commands
{
"generate" => "Generates a payload",
}
end
#
# Returns the command dispatcher name.
#
def name
return "Payload"
end
#
# Generates a payload
# Generates a payload.
#
def cmd_generate(*args)

View File

@ -3,14 +3,18 @@ module Ui
module Console
module CommandDispatcher
###
#
# Recon module command dispatcher.
#
###
class Recon
include Msf::Ui::Console::ModuleCommandDispatcher
def name
"Recon"
end
#
# Returns the hash of commands specific to recon modules.
#
def commands
{
"discover" => "Initiates the recon discovery process for this module",
@ -18,6 +22,13 @@ class Recon
end
#
#
# Returns the command dispatcher name.
#
def name
"Recon"
end
# Starts discovering like a good recon module should.
#
def cmd_discover(*args)

View File

@ -31,6 +31,10 @@ class Driver < Msf::Ui::Driver
#
include Rex::Ui::Text::DispatcherShell
#
# Initializes a console driver instance with the supplied prompt string and
# prompt character.
#
def initialize(prompt = "%umsf", prompt_char = ">%c")
# Call the parent
super
@ -84,7 +88,7 @@ class Driver < Msf::Ui::Driver
end
#
# Loads configuration for the console
# Loads configuration for the console.
#
def load_config
begin
@ -106,7 +110,7 @@ class Driver < Msf::Ui::Driver
end
#
# Saves configuration for the console
# Saves configuration for the console.
#
def save_config
# Build out the console config group
@ -128,7 +132,7 @@ class Driver < Msf::Ui::Driver
#
# TODO:
#
# Processes the resource script file for the console
# Processes the resource script file for the console.
#
def process_rc_file
end
@ -185,12 +189,18 @@ class Driver < Msf::Ui::Driver
end
end
#
# The framework instance associated with this driver.
#
attr_reader :framework
#
# The active module associated with the driver.
#
attr_accessor :active_module
protected
attr_writer :framework
attr_writer :framework # :nodoc:
##
#
@ -199,7 +209,7 @@ protected
##
#
# SessionLogging
# SessionLogging.
#
def handle_session_logging(val)
if (val =~ /^(yes|y|true|t|1)/i)
@ -212,7 +222,7 @@ protected
end
#
# ConsoleLogging
# ConsoleLogging.
#
def handle_console_logging(val)
if (val =~ /^(yes|y|true|t|1)/i)

View File

@ -10,11 +10,16 @@ module Console
###
class Table < Rex::Ui::Text::Table
# Default table styles
#
# Default table styles.
#
module Style
Default = 0
end
#
# Initializes a wrappered table with the supplied style and options.
#
def initialize(style, opts = {})
self.style = style
@ -31,7 +36,9 @@ class Table < Rex::Ui::Text::Table
end
end
# Print nothing if there are no rows if the style is default
#
# Print nothing if there are no rows if the style is default.
#
def to_s
if (style == Style::Default)
return '' if (rows.length == 0)
@ -42,7 +49,7 @@ class Table < Rex::Ui::Text::Table
protected
attr_accessor :style
attr_accessor :style # :nodoc:
end

View File

@ -12,16 +12,22 @@ class Driver
def initialize
end
# Executes the user interface, optionally in an asynchronous fashion
#
# Executes the user interface, optionally in an asynchronous fashion.
#
def run
raise NotImplementedError
end
# Stops executing the user interface
#
# Stops executing the user interface.
#
def stop
end
# Cleans up any resources associated with the UI driver
#
# Cleans up any resources associated with the UI driver.
#
def cleanup
end