add support for actions in post modules. fixes #3965~

git-svn-id: file:///home/svn/framework3/trunk@12008 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2011-03-17 05:39:30 +00:00
parent 382e63e16e
commit ded3ff9c75
4 changed files with 65 additions and 46 deletions

View File

@ -14,6 +14,8 @@ class Auxiliary < Msf::Module
require 'msf/core/auxiliary/mixins'
include HasActions
#
# Returns MODULE_AUX to indicate that this is an auxiliary module.
#
@ -37,16 +39,8 @@ class Auxiliary < Msf::Module
# to the information hash.
super(info)
self.actions = Rex::Transformer.transform(
info['Actions'], Array,
[ AuxiliaryAction ], 'AuxiliaryAction'
)
self.passive = (info['Passive'] and info['Passive'] == true) || false
self.default_action = info['DefaultAction']
self.sockets = Array.new
self.queue = Array.new
self.passive_actions = info['PassiveActions'] || []
end
#
@ -65,36 +59,6 @@ class Auxiliary < Msf::Module
return { }
end
def action
sa = datastore['ACTION']
return find_action(default_action) if not sa
return find_action(sa)
end
def find_action(name)
return nil if not name
actions.each do |a|
return a if a.name == name
end
return nil
end
#
# Returns a boolean indicating whether this module should be run passively
#
def passive?
act = action()
return passive_action?(act.name) if act
return self.passive
end
#
# Returns a boolean indicating whether this specific action should be run passively
#
def passive_action?(name)
passive_actions.include?(name)
end
#
# Performs last-minute sanity checking of auxiliary parameters. This method
# is called during automated exploitation attempts and allows an
@ -190,19 +154,12 @@ class Auxiliary < Msf::Module
}
end
#
# Allow access to the hash table of actions and the string containing
# the default action
#
attr_reader :actions, :default_action, :passive, :passive_actions
attr_accessor :queue
protected
attr_writer :actions, :default_action
attr_accessor :sockets
attr_writer :passive, :passive_actions
attr_writer :passive
end

View File

@ -102,6 +102,7 @@ class Module
require 'msf/core/module/reference'
require 'msf/core/module/target'
require 'msf/core/module/auxiliary_action'
require 'msf/core/module/has_actions'
#
# Creates an instance of an abstract module using the supplied information

View File

@ -0,0 +1,54 @@
require 'msf/core/module/auxiliary_action'
module Msf::Module::HasActions
def initialize(info={})
super
self.actions = Rex::Transformer.transform(
info['Actions'], Array,
[ Msf::Module::AuxiliaryAction ], 'AuxiliaryAction'
)
self.passive = (info['Passive'] and info['Passive'] == true) || false
self.default_action = info['DefaultAction']
self.passive_actions = info['PassiveActions'] || []
end
def action
sa = datastore['ACTION']
return find_action(default_action) if not sa
return find_action(sa)
end
def find_action(name)
return nil if not name
actions.each do |a|
return a if a.name == name
end
return nil
end
#
# Returns a boolean indicating whether this module should be run passively
#
def passive?
act = action()
return passive_action?(act.name) if act
return self.passive
end
#
# Returns a boolean indicating whether this specific action should be run passively
#
def passive_action?(name)
passive_actions.include?(name)
end
#
# Allow access to the hash table of actions and the string containing
# the default action
#
attr_reader :actions, :default_action, :passive, :passive_actions
protected
attr_writer :actions, :default_action, :passive, :passive_actions
end

View File

@ -6,6 +6,8 @@ class Post < Msf::Module
include Msf::Auxiliary::Report
include Msf::Module::HasActions
def self.type
MODULE_POST
end
@ -153,8 +155,13 @@ class Post < Msf::Module
return true
end
#
# True when this module is passive, false when active
#
attr_reader :passive
protected
attr_writer :passive
def session_changed?