-
Notifications
You must be signed in to change notification settings - Fork 13.9k
/
banner.rb
63 lines (54 loc) · 2.02 KB
/
banner.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: binary -*-
module Msf
module Ui
###
#
# Module that contains some most excellent banners.
#
###
module Banner
#
# 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.
#
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} >>"
begin
raise ArgumentError unless File.readable?(pathname)
raise ArgumentError unless File.stat(pathname).size < 65_536
fdata = File.open(pathname) {|f| f.read f.stat.size}
rescue SystemCallError, ArgumentError
nil
end
return fdata
end
def self.to_s
return self.readfile ENV['MSFLOGO'] if ENV['MSFLOGO']
logos = []
# 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'))
elsif ( ENV['APRILFOOLSPONIES'] || Time.now.strftime("%m%d") == "0401" )
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.aftxt'))
else
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.txt'))
logos.concat(Dir.glob(::Msf::Config.user_logos_directory + File::SEPARATOR + '*.txt'))
end
logos = logos.map { |f| File.absolute_path(f) }
self.readfile logos[rand(logos.length)]
end
end
end
end