Module: Msf::Ui::Banner

Defined in:
lib/msf/ui/banner.rb

Overview

Module that contains some most excellent banners.

Class Method Summary collapse

Class Method Details

.readfile(fname) ⇒ Object

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.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/msf/ui/banner.rb', line 17

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

.to_sObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/msf/ui/banner.rb', line 39

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