metasploit-framework/lib/msf/ui/banner.rb

64 lines
2.0 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
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
#
# 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)
pathname = fname
unless File.absolute_path(pathname) == pathname
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
end
fdata = "<< Missing banner: #{pathname} >>"
2013-08-30 21:28:33 +00:00
begin
raise ArgumentError unless File.readable?(pathname)
2015-03-31 18:59:37 +00:00
raise ArgumentError unless File.stat(pathname).size < 16384
2013-08-30 21:28:33 +00:00
fdata = File.open(pathname) {|f| f.read f.stat.size}
rescue SystemCallError, ArgumentError
nil
end
return fdata
end
2013-08-30 21:28:33 +00:00
def self.to_s
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']
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + 'cow*.txt'))
# 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'))
2015-03-31 18:59:37 +00:00
elsif ( ENV['APRILFOOLSPONIES'] || Time.now.strftime("%m%d") == "0401" )
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.aftxt'))
2013-08-30 21:28:33 +00:00
else
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
logos = logos.map { |f| File.absolute_path(f) }
self.readfile logos[rand(logos.length)]
2013-08-30 21:28:33 +00:00
end
end
end
end