diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 5d016fbd8b..7da0632e19 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -503,6 +503,13 @@ protected print_error("Permission denied exec: #{line}") end self.busy = false + return + elsif framework.modules.create(method) + super + if prompt_yesno "This is a module we can load. Do you want to use #{method}?" + run_single "use #{method}" + end + return end end diff --git a/lib/rex/ui/text/shell.rb b/lib/rex/ui/text/shell.rb index 767dfedd7e..194b98392f 100644 --- a/lib/rex/ui/text/shell.rb +++ b/lib/rex/ui/text/shell.rb @@ -429,6 +429,18 @@ protected rlog(buf, log_source) if (log_source) end + # + # Prompt the user for input if possible. Special edition for use inside commands. + # + def prompt_yesno(query) + p = "#{query} [y/N]" + old_p = [self.prompt.sub(/#{self.prompt_char} $/, ''), self.prompt_char] + update_prompt p, ' ', true + /^y/ === get_input_line + ensure + update_prompt *old_p, true + end + attr_writer :input, :output # :nodoc: attr_accessor :stop_flag, :init_prompt, :cont_prompt # :nodoc: attr_accessor :prompt # :nodoc: