Class: Metasploit::Framework::Command::Console

Inherits:
Base
  • Object
show all
Defined in:
lib/metasploit/framework/command/console.rb

Overview

Based on pattern used for lib/rails/commands in the railties gem.

Instance Attribute Summary

Attributes inherited from Base

#application, #parsed_options

Instance Method Summary collapse

Methods inherited from Base

#initialize, parsed_options, parsed_options_class, parsed_options_class_name, require_environment!, start

Constructor Details

This class inherits a constructor from Metasploit::Framework::Command::Base

Instance Method Details

#spinnerObject

Provides an animated spinner in a seperate thread.

See GitHub issue #4147, as this may be blocking some Windows instances, which is why Windows platforms should simply return immediately.


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/metasploit/framework/command/console.rb', line 17

def spinner
  return if Rex::Compat.is_windows
  return if Rex::Compat.is_cygwin
  return if $msf_spinner_thread
  $msf_spinner_thread = Thread.new do
    base_line = "[*] Starting the Metasploit Framework console..."
    cycle = 0
    loop do
      %q{/-\|}.each_char do |c|
        status = "#{base_line}#{c}\r"
        cycle += 1
        off    = cycle % base_line.length
        case status[off, 1]
        when /[a-z]/
          status[off, 1] = status[off, 1].upcase
        when /[A-Z]/
          status[off, 1] = status[off, 1].downcase
        end
        $stderr.print status
        ::IO.select(nil, nil, nil, 0.10)
      end
    end
  end
end

#startObject


42
43
44
45
46
47
48
49
50
# File 'lib/metasploit/framework/command/console.rb', line 42

def start
  case parsed_options.options.subcommand
  when :version
    $stderr.puts "Framework Version: #{Metasploit::Framework::VERSION}"
  else
    spinner unless parsed_options.options.console.quiet
    driver.run
  end
end