Module: Msf::Module::HasActions

Included in:
SessionCompatibility
Defined in:
lib/msf/core/module/has_actions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsObject

Allow access to the hash table of actions and the string containing the default action



52
53
54
# File 'lib/msf/core/module/has_actions.rb', line 52

def actions
  @actions
end

#default_actionObject

Allow access to the hash table of actions and the string containing the default action



52
53
54
# File 'lib/msf/core/module/has_actions.rb', line 52

def default_action
  @default_action
end

#passiveObject

Allow access to the hash table of actions and the string containing the default action



52
53
54
# File 'lib/msf/core/module/has_actions.rb', line 52

def passive
  @passive
end

#passive_actionsObject

Allow access to the hash table of actions and the string containing the default action



52
53
54
# File 'lib/msf/core/module/has_actions.rb', line 52

def passive_actions
  @passive_actions
end

Instance Method Details

#actionObject



16
17
18
19
20
21
# File 'lib/msf/core/module/has_actions.rb', line 16

def action
  sa = find_action(datastore['ACTION'])
  return find_action(default_action) unless sa

  sa
end

#find_action(name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/msf/core/module/has_actions.rb', line 23

def find_action(name)
  return nil if not name
  actions.each do |a|
    return a if a.name.downcase == name.downcase
  end
  return nil
end

#initialize(info = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/msf/core/module/has_actions.rb', line 4

def initialize(info={})
  super
  self.actions = Rex::Transformer.transform(
    info['Actions'], Array,
    [ Msf::Module::AuxiliaryAction ], 'AuxiliaryAction'
  )

  self.passive = (info['Stance'] and info['Stance'].include?(Msf::Exploit::Stance::Passive)) || false
  self.default_action = info['DefaultAction']
  self.passive_actions = info['PassiveActions'] || []
end

#passive?Boolean

Returns a boolean indicating whether this module should be run passively

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/msf/core/module/has_actions.rb', line 34

def passive?
  act = action
  return passive || passive_action?(act.name) if act

  passive
end

#passive_action?(name) ⇒ Boolean

Returns a boolean indicating whether this specific action should be run passively

Returns:

  • (Boolean)


44
45
46
# File 'lib/msf/core/module/has_actions.rb', line 44

def passive_action?(name)
  passive_actions.include?(name)
end