From e11266f0a0c81c3db2d2c339a222ea472fc06dfa Mon Sep 17 00:00:00 2001 From: William Vu Date: Wed, 15 Aug 2018 20:55:28 -0500 Subject: [PATCH] Land #10464, prompt to use plain module name --- lib/msf/ui/console/driver.rb | 7 +++++++ lib/rex/ui/text/shell.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 32e956717a..b059800a70 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -543,6 +543,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: