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
|
|
|
|
|
|
|
|
require 'rex/ui/text/output/stdio'
|
2005-11-28 16:36:06 +00:00
|
|
|
require 'rex/ui/text/output/socket'
|
2005-07-14 22:58:09 +00:00
|
|
|
require 'rex/ui/text/output/buffer'
|
2010-03-11 18:58:20 +00:00
|
|
|
require 'rex/ui/text/output/file'
|
2009-11-10 03:27:48 +00:00
|
|
|
require 'rex/ui/text/color'
|
|
|
|
|
|
|
|
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?
|
2009-11-10 06:58:01 +00:00
|
|
|
substitute_colors(prompt)
|
|
|
|
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
|
|
|
|