Class: Nmap::OS
Instance Method Summary collapse
-
#classes ⇒ Array<OSClass>
Parses the OS class information.
-
#each(&block) ⇒ Object
Parses the OS match information.
-
#each_class {|class| ... } ⇒ OS
Parses the OS class information.
-
#each_match {|match| ... } ⇒ OS
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.
23 24 25 26 27 |
# File 'lib/nmap/os.rb', line 23 def initialize(node,&block) @node = node block.call(self) if block end |
Instance Method Details
#classes ⇒ Array<OSClass>
Parses the OS class information.
62 63 64 |
# File 'lib/nmap/os.rb', line 62 def classes Enumerator.new(self,:each_class).to_a end |
#each(&block) ⇒ Object
Parses the OS match information.
126 127 128 |
# File 'lib/nmap/os.rb', line 126 def each(&block) each_match(&block) end |
#each_class {|class| ... } ⇒ OS
Parses the OS class information.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nmap/os.rb', line 41 def each_class(&block) @node.xpath("osclass").map do |osclass| os_class = OSClass.new( osclass['type'].to_sym, osclass['vendor'], osclass['osfamily'].to_sym, osclass['accuracy'].to_i ) block.call(os_class) if block end return self end |
#each_match {|match| ... } ⇒ OS
Parses the OS match information.
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/nmap/os.rb', line 78 def each_match(&block) @node.xpath("osmatch").map do |osclass| os_match = OSMatch.new( osclass['name'], osclass['accuracy'].to_i ) block.call(os_match) if block end return self end |
#fingerprint ⇒ String
Parses the OS fingerprint used by Nmap.
117 118 119 |
# File 'lib/nmap/os.rb', line 117 def fingerprint @node.at("osfingerprint/@fingerprint").inner_text end |
#matches ⇒ Array<OSMatch>
Parses the OS match information.
97 98 99 |
# File 'lib/nmap/os.rb', line 97 def matches Enumerator.new(self,:each_match).to_a end |
#ports_used ⇒ Array<Integer>
Parses the ports used for guessing the OS.
107 108 109 |
# File 'lib/nmap/os.rb', line 107 def ports_used @node.xpath("portused/@portid").map { |port| port.inner_text.to_i } end |