2014-07-29 19:07:14 +00:00
|
|
|
#
|
|
|
|
# Project
|
|
|
|
#
|
|
|
|
|
|
|
|
require 'metasploit/framework/command'
|
|
|
|
require 'metasploit/framework/command/base'
|
|
|
|
|
|
|
|
# Based on pattern used for lib/rails/commands in the railties gem.
|
|
|
|
class Metasploit::Framework::Command::Console < Metasploit::Framework::Command::Base
|
2014-10-14 19:54:45 +00:00
|
|
|
|
2014-12-30 16:17:56 +00:00
|
|
|
# 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.
|
|
|
|
|
2014-10-14 19:59:57 +00:00
|
|
|
def spinner
|
2014-12-30 16:17:56 +00:00
|
|
|
return if Rex::Compat.is_windows
|
|
|
|
return if Rex::Compat.is_cygwin
|
2014-10-14 19:54:45 +00:00
|
|
|
return if $msf_spinner_thread
|
|
|
|
$msf_spinner_thread = Thread.new do
|
2014-10-17 18:13:30 +00:00
|
|
|
$stderr.print "[*] Starting the Metasploit Framework console..."
|
2014-10-14 19:54:45 +00:00
|
|
|
loop do
|
|
|
|
%q{/-\|}.each_char do |c|
|
2014-10-17 18:13:30 +00:00
|
|
|
$stderr.print c
|
|
|
|
$stderr.print "\b"
|
2014-10-14 19:54:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-29 19:07:14 +00:00
|
|
|
def start
|
2014-08-22 15:33:50 +00:00
|
|
|
case parsed_options.options.subcommand
|
|
|
|
when :version
|
|
|
|
$stderr.puts "Framework Version: #{Metasploit::Framework::VERSION}"
|
|
|
|
else
|
2014-10-17 17:32:28 +00:00
|
|
|
spinner unless parsed_options.options.console.quiet
|
2014-08-22 15:33:50 +00:00
|
|
|
driver.run
|
|
|
|
end
|
2014-07-29 19:07:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# The console UI driver.
|
|
|
|
#
|
|
|
|
# @return [Msf::Ui::Console::Driver]
|
|
|
|
def driver
|
|
|
|
unless @driver
|
|
|
|
# require here so minimum loading is done before {start} is called.
|
|
|
|
require 'msf/ui'
|
|
|
|
|
|
|
|
@driver = Msf::Ui::Console::Driver.new(
|
|
|
|
Msf::Ui::Console::Driver::DefaultPrompt,
|
|
|
|
Msf::Ui::Console::Driver::DefaultPromptChar,
|
|
|
|
driver_options
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
@driver
|
|
|
|
end
|
|
|
|
|
|
|
|
def driver_options
|
|
|
|
unless @driver_options
|
|
|
|
options = parsed_options.options
|
|
|
|
|
|
|
|
driver_options = {}
|
|
|
|
driver_options['Config'] = options.framework.config
|
2014-08-22 15:33:50 +00:00
|
|
|
driver_options['ConfirmExit'] = options.console.confirm_exit
|
2014-07-29 19:07:14 +00:00
|
|
|
driver_options['DatabaseEnv'] = options.environment
|
|
|
|
driver_options['DatabaseMigrationPaths'] = options.database.migrations_paths
|
|
|
|
driver_options['DatabaseYAML'] = options.database.config
|
2014-12-02 20:41:32 +00:00
|
|
|
driver_options['DeferModuleLoads'] = options.modules.defer_loads
|
2014-07-29 19:07:14 +00:00
|
|
|
driver_options['Defanged'] = options.console.defanged
|
|
|
|
driver_options['DisableBanner'] = options.console.quiet
|
|
|
|
driver_options['DisableDatabase'] = options.database.disable
|
|
|
|
driver_options['LocalOutput'] = options.console.local_output
|
|
|
|
driver_options['ModulePath'] = options.modules.path
|
|
|
|
driver_options['Plugins'] = options.console.plugins
|
|
|
|
driver_options['RealReadline'] = options.console.real_readline
|
2014-08-12 15:49:35 +00:00
|
|
|
driver_options['Resource'] = options.console.resources
|
2014-07-29 19:07:14 +00:00
|
|
|
driver_options['XCommands'] = options.console.commands
|
|
|
|
|
|
|
|
@driver_options = driver_options
|
|
|
|
end
|
|
|
|
|
|
|
|
@driver_options
|
|
|
|
end
|
|
|
|
end
|