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


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

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


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

def platforms
  @platforms
end

Class Method Details

.from_a(ary) ⇒ Object

Create an instance from an array


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

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, skape's a girl like that.


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

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

.win32Object

Returns the win32 platform list.


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

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


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

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)

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

def all?
  names.include? ''
end

#empty?Boolean

Checks to see if the platform list is empty.

Returns:

  • (Boolean)

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

def empty?
  return platforms.empty?
end

#index(needle) ⇒ Object


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

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

#namesObject

Returns an array of names contained within this platform list.


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

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)

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

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