Class: Msf::Module::PlatformList

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PlatformList

Constructor, takes the entries are arguments



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/msf/core/module/platform_list.rb', line 49

def initialize(*args)
  self.platforms = [ ]

  args.each { |a|
    if a.kind_of?(String)
      platforms << Msf::Module::Platform.find_platform(a)
    elsif a.kind_of?(Range)
      b = Msf::Module::Platform.find_platform(a.begin)
      e = Msf::Module::Platform.find_platform(a.end)

      children = b.superclass.find_children
      r        = (b::Rank .. e::Rank)
      children.each { |c|
        platforms << c if r.include?(c::Rank)
      }
    else
      platforms << a
    end

  }

end

Instance Attribute Details

#platformsObject

Returns the value of attribute platforms.



13
14
15
# File 'lib/msf/core/module/platform_list.rb', line 13

def platforms
  @platforms
end

Class Method Details

.from_a(ary) ⇒ Object

Create an instance from an array



38
39
40
# File 'lib/msf/core/module/platform_list.rb', line 38

def self.from_a(ary)
  self.new(*ary)
end

.transform(src) ⇒ Object

Transformation method, just accept an array or a single entry. This is just to make defining platform lists in a module more convenient.



27
28
29
30
31
32
33
# File 'lib/msf/core/module/platform_list.rb', line 27

def self.transform(src)
  if (src.kind_of?(Array))
    from_a(src)
  else
    from_a([src])
  end
end

.win32Object

Returns the win32 platform list.



18
19
20
# File 'lib/msf/core/module/platform_list.rb', line 18

def self.win32
  transform('win')
end

Instance Method Details

#&(plist) ⇒ Object

used for say, building a payload from a stage and stager finds common subarchitectures between the arguments



116
117
118
119
120
121
122
# File 'lib/msf/core/module/platform_list.rb', line 116

def &(plist)
  l1 = platforms
  l2 = plist.platforms
  total = l1.find_all { |m| l2.find { |mm| m <= mm } } |
        l2.find_all { |m| l1.find { |mm| m <= mm } }
  Msf::Module::PlatformList.from_a(total)
end

#all?Boolean

Symbolic check to see if this platform list represents ‘all’ platforms.

Returns:

  • (Boolean)


89
90
91
# File 'lib/msf/core/module/platform_list.rb', line 89

def all?
  names.include? ''
end

#empty?Boolean

Checks to see if the platform list is empty.

Returns:

  • (Boolean)


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

def empty?
  return platforms.empty?
end

#index(needle) ⇒ Object



42
43
44
# File 'lib/msf/core/module/platform_list.rb', line 42

def index(needle)
  self.platforms.index(needle)
end

#namesObject

Returns an array of names contained within this platform list.



82
83
84
# File 'lib/msf/core/module/platform_list.rb', line 82

def names
  platforms.map { |m| m.realname }
end

#supports?(plist) ⇒ Boolean

Do I support plist (do I support all of they support?) use for matching say, an exploit and a payload

Returns:

  • (Boolean)


97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/msf/core/module/platform_list.rb', line 97

def supports?(plist)
  plist.platforms.each { |pl|
    supported = false
    platforms.each { |p|
      if p >= pl
        supported = true
        break
      end
    }
    return false if !supported
  }

  return true
end