Class: Nmap::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| ... } ⇒ 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| ... } ⇒ OS
Creates a new OS object.
24 25 26 27 28 |
# File 'lib/nmap/os.rb', line 24 def initialize(node) @node = node yield self if block_given? end |
Instance Method Details
#classes ⇒ Array<OSClass>
Parses the OS class information.
66 67 68 |
# File 'lib/nmap/os.rb', line 66 def classes each_class.to_a end |
#each(&block) ⇒ Object
Parses the OS match information.
135 136 137 |
# File 'lib/nmap/os.rb', line 135 def each(&block) each_match(&block) end |
#each_class {|class| ... } ⇒ OS, Enumerator
Parses the OS class information.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nmap/os.rb', line 43 def each_class return enum_for(__method__) unless block_given? @node.xpath("osclass").map do |osclass| os_class = OSClass.new( osclass['type'].to_sym, osclass['vendor'], osclass['osfamily'].to_sym, osclass['accuracy'].to_i ) yield os_class end return self end |
#each_match {|match| ... } ⇒ OS, Enumerator
Parses the OS match information.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/nmap/os.rb', line 83 def each_match return enum_for(__method__) unless block_given? @node.xpath("osmatch").map 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.
126 127 128 |
# File 'lib/nmap/os.rb', line 126 def fingerprint @fingerprint ||= @node.at("osfingerprint/@fingerprint").inner_text end |
#matches ⇒ Array<OSMatch>
Parses the OS match information.
104 105 106 |
# File 'lib/nmap/os.rb', line 104 def matches each_match.to_a end |
#ports_used ⇒ Array<Integer>
Parses the ports used for guessing the OS.
114 115 116 117 118 |
# File 'lib/nmap/os.rb', line 114 def ports_used @ports_used ||= @node.xpath("portused/@portid").map do |port| port.inner_text.to_i end end |