Improved CTRL-C edge case, Invalid Options edge case, help output, version output
parent
65b0d9555f
commit
7e5214fef5
|
@ -39,7 +39,13 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
#
|
||||
|
||||
def initialize(arguments=ARGV)
|
||||
@positional = option_parser.parse(arguments)
|
||||
begin
|
||||
@positional = option_parser.parse(arguments)
|
||||
rescue OptionParser::InvalidOption
|
||||
puts "ERROR: Invalid command line option provided."
|
||||
puts option_parser
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
# Translates {#options} to the `application`'s config
|
||||
|
@ -102,20 +108,19 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
def option_parser
|
||||
@option_parser ||= OptionParser.new { |option_parser|
|
||||
option_parser.separator ''
|
||||
option_parser.separator 'Common options'
|
||||
option_parser.separator 'Common options:'
|
||||
|
||||
option_parser.on(
|
||||
'-E',
|
||||
'--environment ENVIRONMENT',
|
||||
%w{development production test},
|
||||
"The Rails environment. Will use RAIL_ENV environment variable if that is set. " \
|
||||
"Defaults to production if neither option not RAILS_ENV environment variable is set."
|
||||
"Set Rails environment, defaults to RAIL_ENV environment variable or 'production'"
|
||||
) do |environment|
|
||||
options.environment = environment
|
||||
end
|
||||
|
||||
option_parser.separator ''
|
||||
option_parser.separator 'Database options'
|
||||
option_parser.separator 'Database options:'
|
||||
|
||||
option_parser.on(
|
||||
'-M',
|
||||
|
@ -138,7 +143,7 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
end
|
||||
|
||||
option_parser.separator ''
|
||||
option_parser.separator 'Framework options'
|
||||
option_parser.separator 'Framework options:'
|
||||
|
||||
|
||||
option_parser.on('-c', '-c FILE', 'Load the specified configuration file') do |file|
|
||||
|
@ -146,7 +151,7 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
end
|
||||
|
||||
option_parser.on(
|
||||
'-v',
|
||||
'-v','-V',
|
||||
'--version',
|
||||
'Show version'
|
||||
) do
|
||||
|
@ -154,7 +159,7 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
end
|
||||
|
||||
option_parser.separator ''
|
||||
option_parser.separator 'Module options'
|
||||
option_parser.separator 'Module options:'
|
||||
|
||||
option_parser.on(
|
||||
'--defer-module-loads',
|
||||
|
@ -166,7 +171,7 @@ class Metasploit::Framework::ParsedOptions::Base
|
|||
option_parser.on(
|
||||
'-m',
|
||||
'--module-path DIRECTORY',
|
||||
'An additional module path'
|
||||
'Load an additional module path'
|
||||
) do |directory|
|
||||
options.modules.path = directory
|
||||
end
|
||||
|
|
|
@ -33,7 +33,6 @@ class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::Par
|
|||
super.tap { |option_parser|
|
||||
option_parser.banner = "Usage: #{option_parser.program_name} [options]"
|
||||
|
||||
option_parser.separator ''
|
||||
option_parser.separator 'Console options:'
|
||||
|
||||
option_parser.on('-a', '--ask', "Ask before exiting Metasploit or accept 'exit -y'") do
|
||||
|
@ -67,7 +66,7 @@ class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::Par
|
|||
option_parser.on(
|
||||
'-x',
|
||||
'--execute-command COMMAND',
|
||||
'Execute the specified string as console commands (use ; for multiples)'
|
||||
'Execute the specified console commands (use ; for multiples)'
|
||||
) do |commands|
|
||||
options.console.commands += commands.split(/\s*;\s*/)
|
||||
end
|
||||
|
|
13
msfconsole
13
msfconsole
|
@ -42,7 +42,12 @@ end
|
|||
#
|
||||
|
||||
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/generators/rails/app/templates/script/rails#L3-L5
|
||||
require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
|
||||
require 'metasploit/framework/command/console'
|
||||
require 'msf/core/payload_generator'
|
||||
Metasploit::Framework::Command::Console.start
|
||||
begin
|
||||
require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
|
||||
require 'metasploit/framework/command/console'
|
||||
require 'msf/core/payload_generator'
|
||||
Metasploit::Framework::Command::Console.start
|
||||
rescue Interrupt
|
||||
puts "\nAborting..."
|
||||
exit(1)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue