Skip prompts with new use-defaults option

GSoC/Meterpreter_Web_Console
Erin Bleiweiss 2019-01-22 16:26:29 -06:00
parent 9ecc4b9d1c
commit 0bd21e9ba1
No known key found for this signature in database
GPG Key ID: F69B2138BD594660
1 changed files with 17 additions and 8 deletions

25
msfdb
View File

@ -66,6 +66,7 @@ require 'msf/util/helper'
retry_max: 10,
retry_delay: 5.0,
ws_user: nil,
use_defaults: false,
delete_existing_data: nil
}
@ -190,7 +191,7 @@ def start_db
if last_log =~ /not compatible/
puts 'Please attempt to upgrade the database manually using pg_upgrade.'
end
print_error "Your database may be corrupt. Try reinitializing by running #{'msfdb reinit --component database'.underline}."
print_error "Your database may be corrupt. Try reinitializing."
end
end
@ -458,13 +459,17 @@ def init_web_service
return false
end
if @options[:ws_user].nil?
@msf_ws_user = ask_value('Initial MSF web service account username?', @msf_ws_user)
else
@msf_ws_user = @options[:ws_user]
unless @options[:use_defaults]
if @options[:ws_user].nil?
@msf_ws_user = ask_value('Initial MSF web service account username?', @msf_ws_user)
else
@msf_ws_user = @options[:ws_user]
end
end
if @options[:ws_pass].nil?
if @options[:use_defaults]
@msf_ws_pass = pw_gen
elsif @options[:ws_pass].nil?
@msf_ws_pass = ask_password('Initial MSF web service account password? (Leave blank for random password)')
else
@msf_ws_pass = @options[:ws_pass]
@ -688,9 +693,9 @@ def output_web_service_information
end
def persist_data_service
if ask_yn('Add data service connection to local msfconsole and persist as default?')
if @options[:use_defaults] || ask_yn('Add data service connection to local msfconsole and persist as default?')
data_service_name = "local-#{@options[:ssl] ? 'https' : 'http'}-data-service"
data_service_name = ask_value('Data service connection name?', data_service_name)
data_service_name = ask_value('Data service connection name?', data_service_name) unless @options[:use_defaults]
# execute msfconsole commands to add and persist the data service connection
connect_cmd = get_db_connect_command(name: data_service_name)
cmd = "msfconsole -qx \"#{connect_cmd}; db_save; exit\""
@ -845,6 +850,9 @@ def parse_args(args)
puts opts
exit
}
opts.on('--use-defaults', 'Accept all defaults and do not prompt for options during an init') { |d|
@options[:use_defaults] = d
}
opts.separator('')
opts.separator('Database Options:')
@ -997,6 +1005,7 @@ end
def should_delete
return true if @options[:use_defaults]
ask_yn("Would you like to delete your existing data and configurations?")
end