Module: Msf::Simple::Auxiliary

Includes:
Module
Defined in:
lib/msf/base/simple/auxiliary.rb

Overview

A simplified auxiliary wrapper.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Module

#_import_extra_options, #init_simplified, #inspect, #load_config, #save_config

Class Method Details

.check_simple(mod, opts) ⇒ Object

Initiates a check, setting up the exploit to be used. The following options can be specified:

LocalInput

The local input handle that data can be read in from.

LocalOutput

The local output through which data can be displayed.


107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/msf/base/simple/auxiliary.rb', line 107

def self.check_simple(mod, opts)
  if opts['LocalInput']
    mod.init_ui(opts['LocalInput'], opts['LocalOutput'])
  end

  # Validate the option container state so that options will
  # be normalized
  mod.validate

  # Run check
  mod.check
end

.run_simple(omod, opts = {}) {|mod| ... } ⇒ Object

Wraps the auxiliary process in a simple single method. The options hash can have the following values passed in it:

Action

The selected action name.

OptionStr

A string of comma separated option values that should be imported into the datastore.

Options

A hash of values to be imported directly into the datastore.

LocalInput

The local input handle that data can be read in from.

LocalOutput

The local output through which data can be displayed.

RunAsJob

Whether or not the exploit should be run in the context of a background job.

Yields:

  • (mod)

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/msf/base/simple/auxiliary.rb', line 44

def self.run_simple(omod, opts = {}, &block)

  # Clone the module to prevent changes to the original instance
  mod = omod.replicant
  Msf::Simple::Framework.simplify_module( mod, false )
  yield(mod) if block_given?

  # Import options from the OptionStr or Option hash.
  mod._import_extra_options(opts)

  mod.datastore['ACTION'] = opts['Action'] if opts['Action']

  # Verify the ACTION
  if (mod.actions.length > 0 and not mod.action)
    raise MissingActionError, "You must specify a valid Action", caller
  end

  # Verify the options
  mod.options.validate(mod.datastore)

  # Initialize user interaction
  if ! opts['Quiet']
    mod.init_ui(opts['LocalInput'] || mod.user_input, opts['LocalOutput'] || mod.user_output)
  else
    mod.init_ui(nil, nil)
  end

  ctx = [ mod ]
  if(mod.passive? or opts['RunAsJob'])
    mod.job_id = mod.framework.jobs.start_bg_job(
      "Auxiliary: #{mod.refname}",
      ctx,
      Proc.new { |ctx_| self.job_run_proc(ctx_) },
      Proc.new { |ctx_| self.job_cleanup_proc(ctx_) }
    )
    # Propagate this back to the caller for console mgmt
    omod.job_id = mod.job_id
  else
    self.job_run_proc(ctx)
    self.job_cleanup_proc(ctx)
  end

end

Instance Method Details

#check_simple(opts) ⇒ Object

Calls the class method.


123
124
125
# File 'lib/msf/base/simple/auxiliary.rb', line 123

def check_simple(opts)
  Msf::Simple::Auxiliary.check_simple(self, opts)
end

#run_simple(opts = {}, &block) ⇒ Object

Calls the class method.


91
92
93
# File 'lib/msf/base/simple/auxiliary.rb', line 91

def run_simple(opts = {}, &block)
  Msf::Simple::Auxiliary.run_simple(self, opts, &block)
end