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.config_directory, '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, #load_config, #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, included, #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, #unknown_command, #update_prompt

Instance Method Details

#cmd_beholder_conf(*args) ⇒ Object



270
271
272
273
274
275
276
277
# File 'plugins/beholder.rb', line 270

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



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'plugins/beholder.rb', line 279

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



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

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



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

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

#nameObject



248
249
250
# File 'plugins/beholder.rb', line 248

def name
  'Beholder'
end

#parse_config(*args) ⇒ Object



302
303
304
305
306
307
308
309
310
311
# File 'plugins/beholder.rb', line 302

def parse_config(*args)
  new_config = args.map { |x| x.split('=', 2) }
  new_config.each do |c|
    unless @@beholder_config.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



318
319
320
# File 'plugins/beholder.rb', line 318

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

#stop_beholderObject



313
314
315
316
# File 'plugins/beholder.rb', line 313

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