Class: Msf::Module::PlatformList
- Inherits:
-
Object
- Object
- Msf::Module::PlatformList
- Defined in:
- lib/msf/core/module/platform_list.rb
Overview
This is a helper to an easy way to specify support platforms. It will take a list of strings or Msf::Module::Platform objects and build them into a list of Msf::Module::Platform objects. It also supports ranges based on relative ranks…
Instance Attribute Summary collapse
-
#platforms ⇒ Object
Returns the value of attribute platforms.
Class Method Summary collapse
-
.from_a(ary) ⇒ Object
Create an instance from an array.
-
.transform(src) ⇒ Object
Transformation method, just accept an array or a single entry.
-
.win32 ⇒ Object
Returns the win32 platform list.
Instance Method Summary collapse
-
#&(other) ⇒ Object
used for say, building a payload from a stage and stager finds common subarchitectures between the arguments.
-
#all? ⇒ Boolean
Symbolic check to see if this platform list represents ‘all’ platforms.
-
#empty? ⇒ Boolean
Checks to see if the platform list is empty.
- #index(needle) ⇒ Object
-
#initialize(*args) ⇒ PlatformList
constructor
Constructor, takes the entries as arguments.
-
#names ⇒ Object
Returns an array of names contained within this platform list.
-
#supports?(platform_list) ⇒ Boolean
Do I support platform list (do I support all of they support?) use for matching say, an exploit and a payload.
Constructor Details
#initialize(*args) ⇒ PlatformList
Constructor, takes the entries as arguments
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/msf/core/module/platform_list.rb', line 42 def initialize(*args) self.platforms = [] args.each do |a| if a.is_a?(String) platforms << Msf::Module::Platform.find_platform(a) elsif a.is_a?(Range) a_begin = Msf::Module::Platform.find_platform(a.begin) a_end = Msf::Module::Platform.find_platform(a.end) range = (a_begin::Rank..a_end::Rank) a_begin.superclass.find_children.each do |c| platforms << c if range.include?(c::Rank) end else platforms << a end end end |
Instance Attribute Details
#platforms ⇒ Object
Returns the value of attribute platforms.
10 11 12 |
# File 'lib/msf/core/module/platform_list.rb', line 10 def platforms @platforms end |
Class Method Details
.from_a(ary) ⇒ Object
Create an instance from an array
31 32 33 |
# File 'lib/msf/core/module/platform_list.rb', line 31 def self.from_a(ary) 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.
24 25 26 |
# File 'lib/msf/core/module/platform_list.rb', line 24 def self.transform(src) from_a(Array.wrap(src)) end |
.win32 ⇒ Object
Returns the win32 platform list.
15 16 17 |
# File 'lib/msf/core/module/platform_list.rb', line 15 def self.win32 transform('win') end |
Instance Method Details
#&(other) ⇒ Object
used for say, building a payload from a stage and stager finds common subarchitectures between the arguments
106 107 108 109 110 111 112 |
# File 'lib/msf/core/module/platform_list.rb', line 106 def &(other) l1 = platforms l2 = other.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.
79 80 81 |
# File 'lib/msf/core/module/platform_list.rb', line 79 def all? names.include?('') end |
#empty? ⇒ Boolean
Checks to see if the platform list is empty.
65 66 67 |
# File 'lib/msf/core/module/platform_list.rb', line 65 def empty? platforms.empty? end |
#index(needle) ⇒ Object
35 36 37 |
# File 'lib/msf/core/module/platform_list.rb', line 35 def index(needle) platforms.index(needle) end |
#names ⇒ Object
Returns an array of names contained within this platform list.
72 73 74 |
# File 'lib/msf/core/module/platform_list.rb', line 72 def names platforms.map(&:realname) end |
#supports?(platform_list) ⇒ Boolean
Do I support platform list (do I support all of they support?) use for matching say, an exploit and a payload
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/msf/core/module/platform_list.rb', line 87 def supports?(platform_list) platform_list.platforms.each do |pl| supported = false platforms.each do |p| if p >= pl supported = true break end end return false unless supported end true end |