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
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.
18 19 20 |
# File 'lib/nmap/os.rb', line 18 def initialize(node) @node = node end |
Instance Method Details
#classes ⇒ Array<OSClass>
Parses the OS class information.
51 52 53 |
# File 'lib/nmap/os.rb', line 51 def classes each_class.to_a end |
#each(&block) ⇒ Object
Parses the OS match information.
120 121 122 |
# File 'lib/nmap/os.rb', line 120 def each(&block) each_match(&block) end |
#each_class {|class| ... } ⇒ OS, Enumerator
Parses the OS class information.
35 36 37 38 39 40 41 42 43 |
# File 'lib/nmap/os.rb', line 35 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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nmap/os.rb', line 68 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.
111 112 113 |
# File 'lib/nmap/os.rb', line 111 def fingerprint @fingerprint ||= @node.at("osfingerprint/@fingerprint").inner_text end |
#matches ⇒ Array<OSMatch>
Parses the OS match information.
89 90 91 |
# File 'lib/nmap/os.rb', line 89 def matches each_match.to_a end |
#ports_used ⇒ Array<Integer>
Parses the ports used for guessing the OS.
99 100 101 102 103 |
# File 'lib/nmap/os.rb', line 99 def ports_used @ports_used ||= @node.xpath("portused/@portid").map do |port| port.inner_text.to_i end end |