diff --git a/lib/msf/core/exploit/http/server.rb b/lib/msf/core/exploit/http/server.rb index d282b3cd1d..326ae2fd6a 100644 --- a/lib/msf/core/exploit/http/server.rb +++ b/lib/msf/core/exploit/http/server.rb @@ -80,6 +80,12 @@ module Exploit::Remote::HttpServer def print_debug(msg='') (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super end + # + # :category: print_* overrides + # Prepends client and module name if inside a thread with a #cli + def print_warning(msg='') + (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super + end # :category: print_* overrides # Prepends client and module name if inside a thread with a #cli @@ -101,6 +107,11 @@ module Exploit::Remote::HttpServer def vprint_debug(msg='') (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super end + # :category: print_* overrides + # Prepends client and module name if inside a thread with a #cli + def vprint_warning(msg='') + (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super + end # diff --git a/lib/msf/core/module.rb b/lib/msf/core/module.rb index a4449e04ab..40581a6e32 100644 --- a/lib/msf/core/module.rb +++ b/lib/msf/core/module.rb @@ -208,6 +208,10 @@ class Module super(print_prefix + msg) end + def print_warning(msg='') + super(print_prefix + msg) + end + # # Overwrite the Subscriber print_line to do custom prefixes @@ -241,6 +245,10 @@ class Module def vprint_debug(msg) print_debug(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE'] end + # Verbose version of #print_warning + def vprint_warning(msg) + print_warning(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE'] + end # # Returns the module's framework full reference name. This is the diff --git a/lib/msf/core/plugin.rb b/lib/msf/core/plugin.rb index 1afe44a62f..3a404ddd2c 100644 --- a/lib/msf/core/plugin.rb +++ b/lib/msf/core/plugin.rb @@ -140,6 +140,14 @@ class Plugin output.print_line(msg) if (output) end + # + # Prints a warning + # + def print_warning(msg='') + output.print_warning(msg) if (output) + end + + # # Prints a message with no decoration. # diff --git a/lib/rex/io/bidirectional_pipe.rb b/lib/rex/io/bidirectional_pipe.rb index d85a7d40ae..c79ed27715 100644 --- a/lib/rex/io/bidirectional_pipe.rb +++ b/lib/rex/io/bidirectional_pipe.rb @@ -98,6 +98,10 @@ class BidirectionalPipe < Rex::Ui::Text::Input print_line('[*] ' + msg) end + def print_warning(msg='') + print_warning('[!] ' + msg) + end + # # Wrappers for the pipe_input methods # diff --git a/lib/rex/script/base.rb b/lib/rex/script/base.rb index 2982817d78..5f0e9b9ef6 100644 --- a/lib/rex/script/base.rb +++ b/lib/rex/script/base.rb @@ -9,6 +9,7 @@ class Base def print_status(msg); end def print_good(msg); end def print_error(msg); end + def print_warning(msg); end end attr_accessor :client, :framework, :path, :error, :args diff --git a/lib/rex/ui/output.rb b/lib/rex/ui/output.rb index 220ec68831..53ec48aed1 100644 --- a/lib/rex/ui/output.rb +++ b/lib/rex/ui/output.rb @@ -45,6 +45,12 @@ class Output def print_line(msg='') end + # + # Prints a warning + # + def print_warning(msg='') + end + # # Prints a message with no decoration. # diff --git a/lib/rex/ui/subscriber.rb b/lib/rex/ui/subscriber.rb index 542da35181..0550883f52 100644 --- a/lib/rex/ui/subscriber.rb +++ b/lib/rex/ui/subscriber.rb @@ -66,6 +66,16 @@ module Subscriber end end + # + # Wraps user_output.print_warning + # + def print_warning(msg='') + if (user_output) + print_blank_line if user_output.prompting? + user_output.print_warning(msg) + end + end + # # Wraps user_output.print # diff --git a/lib/rex/ui/text/dispatcher_shell.rb b/lib/rex/ui/text/dispatcher_shell.rb index 2dd3f904e2..ea103a180c 100644 --- a/lib/rex/ui/text/dispatcher_shell.rb +++ b/lib/rex/ui/text/dispatcher_shell.rb @@ -81,6 +81,13 @@ module DispatcherShell shell.print_good(msg) end + # + # Wraps shell.print_warning + # + def print_warning(msg = '') + shell.print_warning(msg) + end + # # Wraps shell.print # diff --git a/lib/rex/ui/text/output.rb b/lib/rex/ui/text/output.rb index eb4704cdee..237a677000 100644 --- a/lib/rex/ui/text/output.rb +++ b/lib/rex/ui/text/output.rb @@ -67,6 +67,10 @@ class Output < Rex::Ui::Output print(msg + "\n") end + def print_warning(msg = '') + print_line("%bld%yel[!]%clr #{msg}") + end + def print(msg = '') print_raw(substitute_colors(msg)) end diff --git a/lib/rex/ui/text/shell.rb b/lib/rex/ui/text/shell.rb index 840fc3cd09..36718dfa60 100644 --- a/lib/rex/ui/text/shell.rb +++ b/lib/rex/ui/text/shell.rb @@ -303,6 +303,16 @@ module Shell log_output(output.print_line(msg)) end + # + # Prints a warning message to the output handle. + # + def print_warning(msg='') + return if (disable_output == true) + + self.on_print_proc.call(msg) if self.on_print_proc + log_output(output.print_warning(msg)) + end + # # Prints a raw message to the output handle. #