Skip to content

Commit c1a61e3

Browse files
committed
Support an MSFLOGO env var and logo enumeration
1 parent 82f41d5 commit c1a61e3

File tree

2 files changed

+19
-33
lines changed

2 files changed

+19
-33
lines changed
File renamed without changes.

lib/msf/ui/banner.rb

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,22 @@ module Ui
88
#
99
###
1010
module Banner
11-
12-
Logos =
13-
%w{
14-
branded-longhorn.txt
15-
cow-head.txt
16-
cowsay.txt
17-
figlet.txt
18-
i-heart-shells.txt
19-
metasploit-shield.txt
20-
missile-command.txt
21-
ninja.txt
22-
null-pointer-deref.txt
23-
r7-metasploit.txt
24-
wake-up-neo.txt
25-
workflow.txt
26-
3kom-superhack.txt
27-
metasploit-park.txt
28-
}
29-
3011
#
31-
# Returns a random metasploit logo.
12+
# Returns a specific metasploit logo. If the specified file is a relative path
13+
# then the file will be searched for first in the included local directory,
14+
# then in the user-specific directory.
3215
#
3316
def self.readfile(fname)
3417
pathname = fname
18+
3519
unless File.absolute_path(pathname) == pathname
36-
pathname = File.join(::Msf::Config.logos_directory, fname)
20+
if File.readable?(File.join(::Msf::Config.logos_directory, fname))
21+
pathname = File.join(::Msf::Config.logos_directory, fname)
22+
elsif File.readable?(File.join(::Msf::Config.user_logos_directory, fname))
23+
pathname = File.join(::Msf::Config.user_logos_directory, fname)
24+
end
3725
end
26+
3827
fdata = "<< Missing banner: #{pathname} >>"
3928
begin
4029
raise ArgumentError unless File.readable?(pathname)
@@ -47,22 +36,19 @@ def self.readfile(fname)
4736
end
4837

4938
def self.to_s
39+
return self.readfile ENV['MSFLOGO'] if ENV['MSFLOGO']
40+
41+
logos = []
5042
# Easter egg (always a cow themed logo): export/set GOCOW=1
5143
if ENV['GOCOW']
52-
case rand(3)
53-
when 0
54-
# branded-longhorn
55-
self.readfile Logos[0]
56-
when 1
57-
# cow-head
58-
self.readfile Logos[1]
59-
else
60-
# cowsay
61-
self.readfile Logos[2]
62-
end
44+
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + 'cow*.txt'))
6345
else
64-
self.readfile Logos[rand(Logos.length)]
46+
logos.concat(Dir.glob(::Msf::Config.logos_directory + File::SEPARATOR + '*.txt'))
47+
logos.concat(Dir.glob(::Msf::Config.user_logos_directory + File::SEPARATOR + '*.txt'))
6548
end
49+
50+
logos = logos.map { |f| File.absolute_path(f) }
51+
self.readfile logos[rand(logos.length)]
6652
end
6753
end
6854

0 commit comments

Comments
 (0)