Class: Msf::Plugin::Beholder::BeholderCommandDispatcher

Inherits:
Object
  • Object
show all
Includes:
Ui::Console::CommandDispatcher
Defined in:
plugins/beholder.rb

Overview

Command Dispatcher

Constant Summary collapse

@@beholder_config =
{
  screenshot: true,
  webcam: false,
  keystrokes: true,
  automigrate: true,
  base: ::File.join(Msf::Config.get_config_root, "beholder", Time.now.strftime("%Y-%m-%d.%s")),
  freq: 30,
  # TODO: Only capture when the idle threshold has been reached
  idle: 0,
}
@@beholder_worker =
nil

Instance Attribute Summary

Attributes included from Ui::Console::CommandDispatcher

#driver

Attributes included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from Ui::Console::CommandDispatcher

#active_module, #active_module=, #active_session, #active_session=, #build_range_array, #docs_dir, #framework, #initialize, #log_error, #remove_lines

Methods included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #update_prompt

Instance Method Details

#cmd_beholder_conf(*args) ⇒ Object


259
260
261
262
263
264
265
266
# File 'plugins/beholder.rb', line 259

def cmd_beholder_conf(*args)
  parse_config(*args)
  print_status("Beholder Configuration")
  print_status("----------------------")
  @@beholder_config.each_pair do |k,v|
    print_status("  #{k}: #{v}")
  end
end

#cmd_beholder_start(*args) ⇒ Object


268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'plugins/beholder.rb', line 268

def cmd_beholder_start(*args)
  opts = Rex::Parser::Arguments.new(
    "-h"   => [ false,  "This help menu"],
  )

  opts.parse(args) do |opt, idx, val|
    case opt
    when "-h"
      print_line("Usage: beholder_start [base=</path/to/directory>] [screenshot=<true|false>] [webcam=<true|false>] [keystrokes=<true|false>] [automigrate=<true|false>] [freq=30]")
      print_line(opts.usage)
      return
    end
  end

  if @@beholder_worker
    print_error("Error: Beholder is already active, use beholder_stop to terminate")
    return
  end

  parse_config(*args)
  start_beholder
end

#cmd_beholder_stop(*args) ⇒ Object


249
250
251
252
253
254
255
256
257
# File 'plugins/beholder.rb', line 249

def cmd_beholder_stop(*args)
  unless @@beholder_worker
    print_error("Error: Beholder is not active")
    return
  end

  print_status("Beholder is shutting down...")
  stop_beholder
end

#commandsObject


241
242
243
244
245
246
247
# File 'plugins/beholder.rb', line 241

def commands
  {
    'beholder_start'         => "Start capturing data",
    'beholder_stop'          => "Stop capturing data",
    'beholder_conf'          => "Configure capture parameters",
  }
end

#nameObject


237
238
239
# File 'plugins/beholder.rb', line 237

def name
  "Beholder"
end

#parse_config(*args) ⇒ Object


291
292
293
294
295
296
297
298
299
300
# File 'plugins/beholder.rb', line 291

def parse_config(*args)
  new_config = args.map{|x| x.split("=", 2) }
  new_config.each do |c|
    unless @@beholder_config.has_key?(c.first.to_sym)
      print_error("Invalid configuration option: #{c.first}")
      next
    end
    @@beholder_config[c.first.to_sym] = c.last
  end
end

#start_beholderObject


307
308
309
# File 'plugins/beholder.rb', line 307

def start_beholder
  @@beholder_worker = BeholderWorker.new(framework, @@beholder_config, driver)
end

#stop_beholderObject


302
303
304
305
# File 'plugins/beholder.rb', line 302

def stop_beholder
  @@beholder_worker.stop if @@beholder_worker
  @@beholder_worker = nil
end