Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/metasploit/framework/command/console.rb
Views: 11784
#1# Project2#34require 'metasploit/framework/command'5require 'metasploit/framework/command/base'6require 'rex/text'78# Based on pattern used for lib/rails/commands in the railties gem.9class Metasploit::Framework::Command::Console < Metasploit::Framework::Command::Base1011# Provides an animated spinner in a separate thread.12#13# See GitHub issue #4147, as this may be blocking some14# Windows instances, which is why Windows platforms15# should simply return immediately.1617def spinner18return if Rex::Compat.is_windows19return if Rex::Compat.is_cygwin20return if $msf_spinner_thread21$msf_spinner_thread = Thread.new do22base_line = "[*] Starting the Metasploit Framework console..."23cycle = 024loop do25%q{/-\|}.each_char do |c|26status = "#{base_line}#{c}\r"27cycle += 128off = cycle % base_line.length29case status[off, 1]30when /[a-z]/31status[off, 1] = status[off, 1].upcase32when /[A-Z]/33status[off, 1] = status[off, 1].downcase34end35$stderr.print status36::IO.select(nil, nil, nil, 0.10)37end38end39end40end4142def start43case parsed_options.options.subcommand44when :version45$stderr.puts "Framework Version: #{Metasploit::Framework::VERSION}"46else47unless parsed_options.options.console.quiet48colorizor = Struct.new(:supports_color?).new(false).extend(Rex::Text::Color)49$stdout.print colorizor.substitute_colors(Rex::Text.wordwrap("Metasploit tip: #{Msf::Ui::Tip.sample}\n", indent = 0, cols = 80))50spinner51end5253driver.run54end55end5657private5859# The console UI driver.60#61# @return [Msf::Ui::Console::Driver]62def driver63unless @driver6465@driver = Msf::Ui::Console::Driver.new(66Msf::Ui::Console::Driver::DefaultPrompt,67Msf::Ui::Console::Driver::DefaultPromptChar,68driver_options69)70end7172@driver73end7475def driver_options76unless @driver_options77options = parsed_options.options7879driver_options = {}80driver_options['Config'] = options.framework.config81driver_options['ConfirmExit'] = options.console.confirm_exit82driver_options['DatabaseEnv'] = options.environment83driver_options['DatabaseMigrationPaths'] = options.database.migrations_paths84driver_options['DatabaseYAML'] = options.database.config85driver_options['DeferModuleLoads'] = options.modules.defer_loads86driver_options['DisableBanner'] = options.console.quiet87driver_options['DisableDatabase'] = options.database.disable88driver_options['HistFile'] = options.console.histfile89driver_options['LocalOutput'] = options.console.local_output90driver_options['Logger'] = options.console.logger91driver_options['ModulePath'] = options.modules.path92driver_options['Plugins'] = options.console.plugins93driver_options['Readline'] = options.console.readline94driver_options['RealReadline'] = options.console.real_readline95driver_options['Resource'] = options.console.resources96driver_options['XCommands'] = options.console.commands9798@driver_options = driver_options99end100101@driver_options102end103end104105106