CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/ui/banner.rb
Views: 11780
1
# -*- coding: binary -*-
2
module Msf
3
module Ui
4
5
###
6
#
7
# Module that contains some most excellent banners.
8
#
9
###
10
module Banner
11
12
#
13
# Returns a specific metasploit logo. If the specified file is a relative path
14
# then the file will be searched for first in the included local directory,
15
# then in the user-specific directory.
16
#
17
def self.readfile(fname)
18
pathname = fname
19
20
unless File.absolute_path(pathname) == pathname
21
if File.readable?(File.join(::Msf::Config.logos_directory, fname))
22
pathname = File.join(::Msf::Config.logos_directory, fname)
23
elsif File.readable?(File.join(::Msf::Config.user_logos_directory, fname))
24
pathname = File.join(::Msf::Config.user_logos_directory, fname)
25
end
26
end
27
28
fdata = "<< Missing banner: #{pathname} >>"
29
begin
30
raise ArgumentError unless File.readable?(pathname)
31
raise ArgumentError unless File.stat(pathname).size < 65_536
32
fdata = File.open(pathname) {|f| f.read f.stat.size}
33
rescue SystemCallError, ArgumentError
34
nil
35
end
36
return fdata
37
end
38
39
def self.to_s
40
return self.readfile ENV['MSFLOGO'] if ENV['MSFLOGO']
41
42
logos = []
43
44
# Easter egg (always a cow themed logo): export/set GOCOW=1
45
if ENV['GOCOW']
46
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + 'cow*.txt'))
47
# Easter egg (always a halloween themed logo): export/set THISISHALLOWEEN=1
48
elsif ( ENV['THISISHALLOWEEN'] || Time.now.strftime("%m%d") == "1031" )
49
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.hwtxt'))
50
elsif ( ENV['APRILFOOLSPONIES'] || Time.now.strftime("%m%d") == "0401" )
51
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.aftxt'))
52
else
53
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.txt'))
54
logos.concat(Dir.glob(::Msf::Config.user_logos_directory + File::SEPARATOR + '*.txt'))
55
end
56
57
logos = logos.map { |f| File.absolute_path(f) }
58
self.readfile logos[rand(logos.length)]
59
end
60
end
61
62
end
63
end
64
65