Class: Msf::Plugin::ThreadTest::ConsoleCommandDispatcher

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

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_list_thread(*_args) ⇒ Object



44
45
46
47
48
49
# File 'plugins/thread.rb', line 44

def cmd_list_thread(*_args)
  Thread.list.each do |t|
    print_line(format('Thread: 0x%.8x (%s/%d) (%s)', t.object_id, t.status, t.priority, t.tsource))
    print_line('')
  end
end

#cmd_start_thread(*_args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'plugins/thread.rb', line 18

def cmd_start_thread(*_args)
  if @mythread
    print_line('Test thread is already running')
    return
  end

  @mythread = ::Thread.new do
    loop do
      print_line('--- test thread ---')
      select(nil, nil, nil, 5)
    end
  end
  print_line('Test thread created')
end

#cmd_stop_thread(*_args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'plugins/thread.rb', line 33

def cmd_stop_thread(*_args)
  if !@mythread
    print_line('No test thread is running')
    return
  end

  @mythread.kill
  @mythread = nil
  print_line('Test thread stopped')
end

#commandsObject



10
11
12
13
14
15
16
# File 'plugins/thread.rb', line 10

def commands
  {
    'start_thread' => 'Start a background thread that writes to the console',
    'stop_thread' => 'Stop a background thread',
    'list_thread' => 'List running threads'
  }
end

#nameObject



6
7
8
# File 'plugins/thread.rb', line 6

def name
  'ThreadTest'
end