Land #3628 - Add --ask option in msfconsole

bug/bundler_fix
sinn3r 2014-08-08 11:03:15 -05:00
commit 93174a818b
No known key found for this signature in database
GPG Key ID: 2384DB4EF06F730B
3 changed files with 20 additions and 0 deletions

View File

@ -670,6 +670,14 @@ class Core
if(framework.sessions.length > 0 and not forced)
print_status("You have active sessions open, to exit anyway type \"exit -y\"")
return
elsif(driver.confirm_exit and not forced)
print("Are you sure you want to exit Metasploit? [y/N]: ")
response = gets.downcase.chomp
if(response == "y" || response == "yes")
driver.stop
else
return
end
end
driver.stop

View File

@ -158,6 +158,9 @@ class Driver < Msf::Ui::Driver
# Whether or not command passthru should be allowed
self.command_passthru = (opts['AllowCommandPassthru'] == false) ? false : true
# Whether or not to confirm before exiting
self.confirm_exit = (opts['ConfirmExit'] == true) ? true : false
# Disables "dangerous" functionality of the console
@defanged = opts['Defanged'] == true
@ -592,6 +595,10 @@ class Driver < Msf::Ui::Driver
# The framework instance associated with this driver.
#
attr_reader :framework
#
# Whether or not to confirm before exiting
#
attr_reader :confirm_exit
#
# Whether or not commands can be passed through.
#
@ -628,6 +635,7 @@ class Driver < Msf::Ui::Driver
protected
attr_writer :framework # :nodoc:
attr_writer :confirm_exit # :nodoc:
attr_writer :command_passthru # :nodoc:
#

View File

@ -101,6 +101,10 @@ class OptsConsole
options['DisableBanner'] = true
end
opts.on("-a", "--ask", "Ask before exiting Metasploit or accept 'exit -y'") do |v|
options['ConfirmExit'] = true
end
opts.on("-x", "-x <command>", "Execute the specified string as console commands (use ; for multiples)") do |s|
options['XCommands'] ||= []
options['XCommands'] += s.split(/\s*;\s*/)