Class: Nmap::XML::OS
Overview
Wraps the os
XML element.
Instance Method Summary collapse
-
#classes ⇒ Array<OSClass>
Parses the OS class information.
-
#each(&block) ⇒ Object
Parses the OS match information.
-
#each_class {|class| ... } ⇒ OS, Enumerator
Parses the OS class information.
-
#each_match {|match| ... } ⇒ OS, Enumerator
Parses the OS match information.
-
#fingerprint ⇒ String
Parses the OS fingerprint used by Nmap.
-
#initialize(node) ⇒ OS
constructor
Creates a new OS object.
-
#matches ⇒ Array<OSMatch>
Parses the OS match information.
-
#ports_used ⇒ Array<Integer>
Parses the ports used for guessing the OS.
Constructor Details
#initialize(node) ⇒ OS
Creates a new OS object.
23 24 25 |
# File 'lib/nmap/xml/os.rb', line 23 def initialize(node) @node = node end |
Instance Method Details
#classes ⇒ Array<OSClass>
Parses the OS class information.
56 57 58 |
# File 'lib/nmap/xml/os.rb', line 56 def classes each_class.to_a end |
#each(&block) ⇒ Object
Parses the OS match information.
127 128 129 |
# File 'lib/nmap/xml/os.rb', line 127 def each(&block) each_match(&block) end |
#each_class {|class| ... } ⇒ OS, Enumerator
Parses the OS class information.
40 41 42 43 44 45 46 47 48 |
# File 'lib/nmap/xml/os.rb', line 40 def each_class return enum_for(__method__) unless block_given? @node.xpath("osmatch/osclass").each do |osclass| yield OSClass.new(osclass) end return self end |
#each_match {|match| ... } ⇒ OS, Enumerator
Parses the OS match information.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/nmap/xml/os.rb', line 73 def each_match return enum_for(__method__) unless block_given? @node.xpath("osmatch").each do |osclass| os_match = OSMatch.new( osclass['name'], osclass['accuracy'].to_i ) yield os_match end return self end |
#fingerprint ⇒ String
Parses the OS fingerprint used by Nmap.
116 117 118 119 120 |
# File 'lib/nmap/xml/os.rb', line 116 def fingerprint @fingerprint ||= if (fingerprint = @node.at_xpath("osfingerprint/@fingerprint")) fingerprint.inner_text end end |
#matches ⇒ Array<OSMatch>
Parses the OS match information.
94 95 96 |
# File 'lib/nmap/xml/os.rb', line 94 def matches each_match.to_a end |
#ports_used ⇒ Array<Integer>
Parses the ports used for guessing the OS.
104 105 106 107 108 |
# File 'lib/nmap/xml/os.rb', line 104 def ports_used @ports_used ||= @node.xpath("portused/@portid").map do |port| port.inner_text.to_i end end |