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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/msf/core/module/platform_list.rb', line 45

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



34
35
36
# File 'lib/msf/core/module/platform_list.rb', line 34

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
# File 'lib/msf/core/module/platform_list.rb', line 27

def self.transform(src)
  from_a(Array.wrap(src))
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



112
113
114
115
116
117
118
# File 'lib/msf/core/module/platform_list.rb', line 112

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)


85
86
87
# File 'lib/msf/core/module/platform_list.rb', line 85

def all?
  names.include? ''
end

#empty?Boolean

Checks to see if the platform list is empty.

Returns:

  • (Boolean)


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

def empty?
  return platforms.empty?
end

#index(needle) ⇒ Object



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

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

#namesObject

Returns an array of names contained within this platform list.



78
79
80
# File 'lib/msf/core/module/platform_list.rb', line 78

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)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/msf/core/module/platform_list.rb', line 93

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