@@ -8,33 +8,22 @@ module Ui
8
8
#
9
9
###
10
10
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
-
30
11
#
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.
32
15
#
33
16
def self . readfile ( fname )
34
17
pathname = fname
18
+
35
19
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
37
25
end
26
+
38
27
fdata = "<< Missing banner: #{ pathname } >>"
39
28
begin
40
29
raise ArgumentError unless File . readable? ( pathname )
@@ -47,22 +36,19 @@ def self.readfile(fname)
47
36
end
48
37
49
38
def self . to_s
39
+ return self . readfile ENV [ 'MSFLOGO' ] if ENV [ 'MSFLOGO' ]
40
+
41
+ logos = [ ]
50
42
# Easter egg (always a cow themed logo): export/set GOCOW=1
51
43
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' ) )
63
45
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' ) )
65
48
end
49
+
50
+ logos = logos . map { |f | File . absolute_path ( f ) }
51
+ self . readfile logos [ rand ( logos . length ) ]
66
52
end
67
53
end
68
54
0 commit comments