Module: Metasploit::Model::Platform
- Extended by:
- ActiveModel::Naming, ActiveSupport::Concern
- Includes:
- Translation
- Defined in:
- lib/metasploit/model/platform.rb
Overview
Code shared between Mdm::Platform
and Metasploit::Framework::Platform
.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- SEED_RELATIVE_NAME_TREE =
Platforms are seeded in a hierarchy with deeper levels refining higher levels, so 'Windows 98 SE' is a refinement of 'Windows 98', which is a refinement of 'Windows'.
{ 'AIX' => nil, 'Android' => nil, 'BSD' => nil, 'BSDi' => nil, 'Cisco' => nil, 'Firefox' => nil, 'FreeBSD' => nil, 'HPUX' => nil, 'IRIX' => nil, 'Java' => nil, 'Javascript' => nil, 'Linux' => nil, 'NetBSD' => nil, 'Netware' => nil, 'NodeJS' => nil, 'OpenBSD' => nil, 'OSX' => nil, 'PHP' => nil, 'Python' => nil, 'Ruby' => nil, 'Solaris' => { '4' => nil, '5' => nil, '6' => nil, '7' => nil, '8' => nil, '9' => nil, '10' => nil }, 'Windows' => { '95' => nil, '98' => { 'FE' => nil, 'SE' => nil }, 'ME' => nil, 'NT' => { 'SP0' => nil, 'SP1' => nil, 'SP2' => nil, 'SP3' => nil, 'SP4' => nil, 'SP5' => nil, 'SP6' => nil, 'SP6a' => nil }, '2000' => { 'SP0' => nil, 'SP1' => nil, 'SP2' => nil, 'SP3' => nil, 'SP4' => nil }, 'XP' => { 'SP0' => nil, 'SP1' => nil, 'SP2' => nil, 'SP3' => nil }, '2003' => { 'SP0' => nil, 'SP1' => nil }, 'Vista' => { 'SP0' => nil, 'SP1' => nil }, '7' => nil }, 'UNIX' => nil }
Instance Attribute Summary collapse
-
#fully_qualified_name ⇒ String
The fully qualified name of this platform, as would be used in the platform list in a metasploit-framework module.
-
#parent ⇒ nil, Metasploit::Model::Platform
The parent platform of this platform.
-
#relative_name ⇒ String
The name of this platform relative to the #fully_qualified_name of #parent.
Class Method Summary collapse
- .each_seed_attributes(options = {}) {|attributes| ... } ⇒ void
-
.fully_qualified_name_set ⇒ Array<String>
List of valid #fully_qualified_name derived from SEED_RELATIVE_NAME_TREE.
Instance Method Summary collapse
-
#derived_fully_qualified_name ⇒ nil, String
Derives #fully_qualified_name from #parent's #fully_qualified_name and this platform's #relative_name.
Instance Attribute Details
#fully_qualified_name ⇒ String
The fully qualified name of this platform, as would be used in the platform list in a metasploit-framework module.
|
# File 'lib/metasploit/model/platform.rb', line 142
|
#parent ⇒ nil, Metasploit::Model::Platform
The parent platform of this platform. For example, Windows is parent of Windows 98, which is the parent of Windows 98 FE.
|
# File 'lib/metasploit/model/platform.rb', line 148
|
#relative_name ⇒ String
The name of this platform relative to the #fully_qualified_name of #parent.
|
# File 'lib/metasploit/model/platform.rb', line 155
|
Class Method Details
.each_seed_attributes(options = {}) {|attributes| ... } ⇒ void
Not defined in ClassMethods
because consumers should always refer back to Metasploit::Model::Platform
when seeding.
This method returns an undefined value.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/metasploit/model/platform.rb', line 194 def self.each_seed_attributes(={}, &block) .assert_valid_keys(:parent, :grandchildren_by_child_relative_name) parent = [:parent] grandchildren_by_child_relative_name = .fetch( :grandchildren_by_child_relative_name, SEED_RELATIVE_NAME_TREE ) grandchildren_by_child_relative_name.each do |child_relative_name, great_grandchildren_by_grandchild_relative_name| attributes = { parent: parent, relative_name: child_relative_name } child = block.call(attributes) if great_grandchildren_by_grandchild_relative_name each_seed_attributes( grandchildren_by_child_relative_name: great_grandchildren_by_grandchild_relative_name, parent: child, &block ) end end end |
.fully_qualified_name_set ⇒ Array<String>
List of valid #fully_qualified_name derived from SEED_RELATIVE_NAME_TREE.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/metasploit/model/platform.rb', line 223 def self.fully_qualified_name_set unless instance_variable_defined? :@fully_qualified_name_set @fully_qualified_name_set = Set.new each_seed_attributes do |attributes| parent = attributes.fetch(:parent) relative_name = attributes.fetch(:relative_name) if parent fully_qualified_name = "#{parent} #{relative_name}" else fully_qualified_name = relative_name end @fully_qualified_name_set.add fully_qualified_name # yieldreturn fully_qualified_name end @fully_qualified_name_set.freeze end @fully_qualified_name_set end |
Instance Method Details
#derived_fully_qualified_name ⇒ nil, String
Derives #fully_qualified_name from #parent's #fully_qualified_name and this platform's #relative_name.
169 170 171 172 173 174 175 176 177 |
# File 'lib/metasploit/model/platform.rb', line 169 def derived_fully_qualified_name if relative_name.present? if parent "#{parent.fully_qualified_name} #{relative_name}" else relative_name end end end |