Class: Msf::Module::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/module/platform.rb

Overview

This is the definitions of which Platforms the framework knows about. The relative ranks are used to support ranges, and the Short names are used to allow for more convenient specification of the platforms.…

Defined Under Namespace

Classes: AIX, Android, Apple_iOS, Arista, BSD, BSDi, Brocade, Cisco, Firefox, FreeBSD, HPUX, Hardware, Irix, Java, JavaScript, Juniper, Linux, Mainframe, Mikrotik, Multi, NetBSD, Netware, NodeJS, OSX, OpenBSD, PHP, Python, R, Ruby, Solaris, Unifi, Unix, Unknown, Windows

Constant Summary collapse

Rank =
0
Short =

actually, having an argument of ” is what to do for wanting ‘all’

"all"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.full_nameObject

Returns the value of attribute full_name.



17
18
19
# File 'lib/msf/core/module/platform.rb', line 17

def full_name
  @full_name
end

Class Method Details

.find_childrenObject

Finds all inherited children from a given module.



70
71
72
73
# File 'lib/msf/core/module/platform.rb', line 70

def self.find_children
  @subclasses ||= []
  @subclasses.sort_by { |a| a::Rank }
end

.find_platform(str) ⇒ Object

The magic to try to build out a Platform from a string.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/msf/core/module/platform.rb', line 52

def self.find_platform(str)
  # remove any whitespace and downcase
  str = str.gsub(' ', '').downcase

  # Start at the base platform module
  mod = ::Msf::Module::Platform

  # Scan forward, trying to find the end module
  while str.length > 0
    mod, str = find_portion(mod, str)
  end

  return mod
end

.inherited(subclass) ⇒ Object



75
76
77
78
# File 'lib/msf/core/module/platform.rb', line 75

def self.inherited(subclass)
  @subclasses ||= []
  @subclasses << subclass
end

.realnameObject

Returns the “real” name of the module instance, accounting for potentially aliased class names.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/msf/core/module/platform.rb', line 24

def self.realname
  # Use the cached version if one has been set
  return full_name if (full_name)

  # Otherwise, generate it and cache it
  names = []
  c     = Msf::Module::Platform
  name.split('::')[3 .. -1].each { |part|
    c = c.const_get(part)
    if (c.const_defined?('RealName') == true)
      names << c.const_get('RealName')
    else
      names << part
    end
  }
  full_name = names.join(' ')
end

Instance Method Details

#find_childrenObject

Calls the class method.



45
46
47
# File 'lib/msf/core/module/platform.rb', line 45

def find_children
  self.class.find_children
end