2005-07-14 22:45:10 +00:00
|
|
|
require 'rex/ui'
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Ui
|
|
|
|
module Text
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements text-based output but is not
|
|
|
|
# tied to an output medium.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Output < Rex::Ui::Output
|
|
|
|
|
2011-05-12 20:03:55 +00:00
|
|
|
require 'rex/ui/text/output/stdio'
|
|
|
|
require 'rex/ui/text/output/socket'
|
|
|
|
require 'rex/ui/text/output/buffer'
|
|
|
|
require 'rex/ui/text/output/file'
|
2011-06-25 18:51:07 +00:00
|
|
|
require 'rex/ui/text/output/tee'
|
2011-05-12 20:03:55 +00:00
|
|
|
require 'rex/ui/text/color'
|
2009-11-10 03:27:48 +00:00
|
|
|
|
|
|
|
include Rex::Ui::Text::Color
|
2005-07-14 22:45:10 +00:00
|
|
|
|
2009-11-10 06:58:01 +00:00
|
|
|
def initialize
|
|
|
|
@config = {
|
|
|
|
:color => :auto, # true, false, :auto
|
|
|
|
}
|
|
|
|
super
|
|
|
|
end
|
|
|
|
attr_reader :config
|
2009-11-10 15:59:49 +00:00
|
|
|
|
2009-11-10 06:58:01 +00:00
|
|
|
def disable_color
|
|
|
|
@config[:color] = false
|
|
|
|
end
|
2009-11-10 15:59:49 +00:00
|
|
|
|
2009-11-10 06:58:01 +00:00
|
|
|
def enable_color
|
|
|
|
@config[:color] = true
|
|
|
|
end
|
2009-11-10 15:59:49 +00:00
|
|
|
|
2009-11-10 06:58:01 +00:00
|
|
|
def auto_color
|
|
|
|
@config[:color] = :auto
|
|
|
|
end
|
|
|
|
|
2009-11-10 16:10:39 +00:00
|
|
|
def update_prompt(prompt = nil)
|
|
|
|
return if prompt.nil?
|
2010-04-07 23:37:49 +00:00
|
|
|
substitute_colors(prompt, true)
|
2009-11-10 06:58:01 +00:00
|
|
|
end
|
|
|
|
|
2005-07-14 22:45:10 +00:00
|
|
|
def print_error(msg = '')
|
2009-11-10 16:49:26 +00:00
|
|
|
print_line("%bld%red[-]%clr #{msg}")
|
2005-07-14 22:45:10 +00:00
|
|
|
end
|
2009-11-10 03:27:48 +00:00
|
|
|
|
2005-07-14 22:45:10 +00:00
|
|
|
def print_good(msg = '')
|
2009-11-10 16:49:26 +00:00
|
|
|
print_line("%bld%grn[+]%clr #{msg}")
|
2005-07-14 22:45:10 +00:00
|
|
|
end
|
|
|
|
|
2010-02-02 21:03:07 +00:00
|
|
|
def print_debug(msg = '')
|
|
|
|
print_line("%bld%cya[!]%clr #{msg}")
|
|
|
|
end
|
|
|
|
|
2005-07-14 22:45:10 +00:00
|
|
|
def print_status(msg = '')
|
2009-11-10 16:49:26 +00:00
|
|
|
print_line("%bld%blu[*]%clr #{msg}")
|
2005-07-14 22:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def print_line(msg = '')
|
|
|
|
print(msg + "\n")
|
|
|
|
end
|
|
|
|
|
2009-11-10 03:27:48 +00:00
|
|
|
def print(msg = '')
|
2009-11-10 06:58:01 +00:00
|
|
|
print_raw(substitute_colors(msg))
|
2009-11-10 03:27:48 +00:00
|
|
|
end
|
|
|
|
|
2005-07-14 22:58:09 +00:00
|
|
|
def reset
|
|
|
|
end
|
|
|
|
|
2005-07-14 22:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2009-11-10 03:27:48 +00:00
|
|
|
end
|
2009-11-10 15:59:49 +00:00
|
|
|
|