Use rex for color output

GSoC/Meterpreter_Web_Console
Erin Bleiweiss 2019-01-23 17:21:07 -06:00
parent b3b7d5205b
commit 424c249200
No known key found for this signature in database
GPG Key ID: F69B2138BD594660
1 changed files with 13 additions and 7 deletions

20
msfdb
View File

@ -13,6 +13,8 @@ require 'securerandom'
require 'uri' require 'uri'
require 'yaml' require 'yaml'
include Rex::Text::Color
msfbase = __FILE__ msfbase = __FILE__
while File.symlink?(msfbase) while File.symlink?(msfbase)
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase)) msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
@ -24,7 +26,6 @@ $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'msf/base/config' require 'msf/base/config'
require 'msf/util/helper' require 'msf/util/helper'
@script_name = File.basename(__FILE__) @script_name = File.basename(__FILE__)
@framework = File.expand_path(File.dirname(__FILE__)) @framework = File.expand_path(File.dirname(__FILE__))
@ -70,30 +71,35 @@ require 'msf/util/helper'
delete_existing_data: nil delete_existing_data: nil
} }
def supports_color?
return true if Rex::Compat.is_windows
term = Rex::Compat.getenv('TERM')
term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil
end
class String class String
def bold def bold
"\e[1m#{self}\e[0m" substitute_colors("%bld#{self}%clr")
end end
def underline def underline
"\e[4m#{self}\e[0m" substitute_colors("%und#{self}%clr")
end end
def red def red
"\e[91m#{self}\e[0m" substitute_colors("%red#{self}%clr")
end end
def green def green
"\e[92m#{self}\e[0m" substitute_colors("%grn#{self}%clr")
end end
def blue def blue
"\e[34m#{self}\e[0m" substitute_colors("%blu#{self}%clr")
end end
def cyan def cyan
"\e[36m#{self}\e[0m" substitute_colors("%cya#{self}%clr")
end end
end end