2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2005-07-14 07:13:01 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Module that contains some most excellent banners.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Banner
|
2014-10-27 19:49:27 +00:00
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
#
|
2014-10-24 17:07:28 +00:00
|
|
|
# Returns a specific metasploit logo. If the specified file is a relative path
|
|
|
|
# then the file will be searched for first in the included local directory,
|
|
|
|
# then in the user-specific directory.
|
2013-08-30 21:28:33 +00:00
|
|
|
#
|
|
|
|
def self.readfile(fname)
|
2014-10-24 14:52:05 +00:00
|
|
|
pathname = fname
|
2014-10-24 17:07:28 +00:00
|
|
|
|
2014-10-24 14:52:05 +00:00
|
|
|
unless File.absolute_path(pathname) == pathname
|
2014-10-24 17:07:28 +00:00
|
|
|
if File.readable?(File.join(::Msf::Config.logos_directory, fname))
|
|
|
|
pathname = File.join(::Msf::Config.logos_directory, fname)
|
|
|
|
elsif File.readable?(File.join(::Msf::Config.user_logos_directory, fname))
|
|
|
|
pathname = File.join(::Msf::Config.user_logos_directory, fname)
|
|
|
|
end
|
2014-10-24 14:52:05 +00:00
|
|
|
end
|
2014-10-24 17:07:28 +00:00
|
|
|
|
2014-10-24 14:52:05 +00:00
|
|
|
fdata = "<< Missing banner: #{pathname} >>"
|
2013-08-30 21:28:33 +00:00
|
|
|
begin
|
|
|
|
raise ArgumentError unless File.readable?(pathname)
|
|
|
|
raise ArgumentError unless File.stat(pathname).size < 4096
|
|
|
|
fdata = File.open(pathname) {|f| f.read f.stat.size}
|
|
|
|
rescue SystemCallError, ArgumentError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
return fdata
|
|
|
|
end
|
2013-01-10 01:54:08 +00:00
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
def self.to_s
|
2014-10-24 17:07:28 +00:00
|
|
|
return self.readfile ENV['MSFLOGO'] if ENV['MSFLOGO']
|
|
|
|
|
|
|
|
logos = []
|
2014-10-27 19:49:27 +00:00
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
# Easter egg (always a cow themed logo): export/set GOCOW=1
|
|
|
|
if ENV['GOCOW']
|
2014-10-24 17:07:28 +00:00
|
|
|
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + 'cow*.txt'))
|
2014-10-31 04:35:12 +00:00
|
|
|
# Easter egg (always a halloween themed logo): export/set THISISHALLOWEEN=1
|
|
|
|
elsif ( ENV['THISISHALLOWEEN'] || Time.now.strftime("%m%d") == "1031" )
|
|
|
|
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.hwtxt'))
|
2013-08-30 21:28:33 +00:00
|
|
|
else
|
2014-10-24 17:07:28 +00:00
|
|
|
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.txt'))
|
|
|
|
logos.concat(Dir.glob(::Msf::Config.user_logos_directory + File::SEPARATOR + '*.txt'))
|
2013-08-30 21:28:33 +00:00
|
|
|
end
|
2014-10-24 17:07:28 +00:00
|
|
|
|
|
|
|
logos = logos.map { |f| File.absolute_path(f) }
|
|
|
|
self.readfile logos[rand(logos.length)]
|
2013-08-30 21:28:33 +00:00
|
|
|
end
|
2005-07-14 07:13:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-04-01 15:12:53 +00:00
|
|
|
end
|