Skip to content

Commit ed3f87b

Browse files
committed
Merge branch 'wchen-r7-print_warning' into rapid7
[Closes rapid7#899]
2 parents de26743 + ffa4373 commit ed3f87b

File tree

10 files changed

+69
-0
lines changed

10 files changed

+69
-0
lines changed

lib/msf/core/exploit/http/server.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def print_error(msg='')
8080
def print_debug(msg='')
8181
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
8282
end
83+
#
84+
# :category: print_* overrides
85+
# Prepends client and module name if inside a thread with a #cli
86+
def print_warning(msg='')
87+
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
88+
end
8389

8490
# :category: print_* overrides
8591
# Prepends client and module name if inside a thread with a #cli
@@ -101,6 +107,11 @@ def vprint_error(msg='')
101107
def vprint_debug(msg='')
102108
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
103109
end
110+
# :category: print_* overrides
111+
# Prepends client and module name if inside a thread with a #cli
112+
def vprint_warning(msg='')
113+
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
114+
end
104115

105116

106117
#

lib/msf/core/module.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def print_good(msg='')
208208
super(print_prefix + msg)
209209
end
210210

211+
def print_warning(msg='')
212+
super(print_prefix + msg)
213+
end
214+
211215

212216
#
213217
# Overwrite the Subscriber print_line to do custom prefixes
@@ -241,6 +245,10 @@ def vprint_line(msg)
241245
def vprint_debug(msg)
242246
print_debug(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE']
243247
end
248+
# Verbose version of #print_warning
249+
def vprint_warning(msg)
250+
print_warning(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE']
251+
end
244252

245253
#
246254
# Returns the module's framework full reference name. This is the

lib/msf/core/plugin.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ def print_line(msg='')
140140
output.print_line(msg) if (output)
141141
end
142142

143+
#
144+
# Prints a warning
145+
#
146+
def print_warning(msg='')
147+
output.print_warning(msg) if (output)
148+
end
149+
150+
143151
#
144152
# Prints a message with no decoration.
145153
#

lib/rex/io/bidirectional_pipe.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def print_status(msg='')
9898
print_line('[*] ' + msg)
9999
end
100100

101+
def print_warning(msg='')
102+
print_warning('[!] ' + msg)
103+
end
104+
101105
#
102106
# Wrappers for the pipe_input methods
103107
#

lib/rex/script/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def print_line(msg); end
99
def print_status(msg); end
1010
def print_good(msg); end
1111
def print_error(msg); end
12+
def print_warning(msg); end
1213
end
1314

1415
attr_accessor :client, :framework, :path, :error, :args

lib/rex/ui/output.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ def print_status(msg='')
4545
def print_line(msg='')
4646
end
4747

48+
#
49+
# Prints a warning
50+
#
51+
def print_warning(msg='')
52+
end
53+
4854
#
4955
# Prints a message with no decoration.
5056
#

lib/rex/ui/subscriber.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ def print_debug(msg='')
6666
end
6767
end
6868

69+
#
70+
# Wraps user_output.print_warning
71+
#
72+
def print_warning(msg='')
73+
if (user_output)
74+
print_blank_line if user_output.prompting?
75+
user_output.print_warning(msg)
76+
end
77+
end
78+
6979
#
7080
# Wraps user_output.print
7181
#

lib/rex/ui/text/dispatcher_shell.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ def print_good(msg = '')
8181
shell.print_good(msg)
8282
end
8383

84+
#
85+
# Wraps shell.print_warning
86+
#
87+
def print_warning(msg = '')
88+
shell.print_warning(msg)
89+
end
90+
8491
#
8592
# Wraps shell.print
8693
#

lib/rex/ui/text/output.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def print_line(msg = '')
6767
print(msg + "\n")
6868
end
6969

70+
def print_warning(msg = '')
71+
print_line("%bld%yel[!]%clr #{msg}")
72+
end
73+
7074
def print(msg = '')
7175
print_raw(substitute_colors(msg))
7276
end

lib/rex/ui/text/shell.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ def print_line(msg='')
303303
log_output(output.print_line(msg))
304304
end
305305

306+
#
307+
# Prints a warning message to the output handle.
308+
#
309+
def print_warning(msg='')
310+
return if (disable_output == true)
311+
312+
self.on_print_proc.call(msg) if self.on_print_proc
313+
log_output(output.print_warning(msg))
314+
end
315+
306316
#
307317
# Prints a raw message to the output handle.
308318
#

0 commit comments

Comments
 (0)