Class: Rex::Parser::NexposeXMLStreamParser
- Inherits:
-
Object
- Object
- Rex::Parser::NexposeXMLStreamParser
- Defined in:
- lib/rex/parser/nexpose_xml.rb
Overview
XXX doesn’t tie services to vulns
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
Instance Method Summary collapse
-
#attlist ⇒ Object
:nodoc:.
-
#cdata ⇒ Object
:nodoc:.
-
#comment(str) ⇒ Object
:nodoc:.
-
#initialize(callback = nil) ⇒ NexposeXMLStreamParser
constructor
A new instance of NexposeXMLStreamParser.
-
#instruction(name, instruction) ⇒ Object
:nodoc:.
- #reset_state ⇒ Object
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
- #text(str) ⇒ Object
-
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy.
Constructor Details
#initialize(callback = nil) ⇒ NexposeXMLStreamParser
Returns a new instance of NexposeXMLStreamParser.
9 10 11 12 |
# File 'lib/rex/parser/nexpose_xml.rb', line 9 def initialize(callback = nil) reset_state self.callback = callback if callback end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
7 8 9 |
# File 'lib/rex/parser/nexpose_xml.rb', line 7 def callback @callback end |
Instance Method Details
#attlist ⇒ Object
:nodoc:
98 99 |
# File 'lib/rex/parser/nexpose_xml.rb', line 98 def attlist # :nodoc: end |
#cdata ⇒ Object
:nodoc:
92 93 |
# File 'lib/rex/parser/nexpose_xml.rb', line 92 def cdata # :nodoc: end |
#comment(str) ⇒ Object
:nodoc:
94 95 |
# File 'lib/rex/parser/nexpose_xml.rb', line 94 def comment(str) # :nodoc: end |
#instruction(name, instruction) ⇒ Object
:nodoc:
96 97 |
# File 'lib/rex/parser/nexpose_xml.rb', line 96 def instruction(name, instruction) # :nodoc: end |
#reset_state ⇒ Object
14 15 16 17 18 |
# File 'lib/rex/parser/nexpose_xml.rb', line 14 def reset_state @state = :generic_state @host = { "status" => nil, "endpoints" => [], "names" => [], "vulns" => {} } @vuln = { "refs" => [] } end |
#tag_end(name) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rex/parser/nexpose_xml.rb', line 76 def tag_end(name) case name when "node" callback.call(:host, @host) if callback reset_state when "vulnerability" callback.call(:vuln, @vuln) if callback reset_state when "service","reference","names" @state = :generic_state end end |
#tag_start(name, attributes) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rex/parser/nexpose_xml.rb', line 20 def tag_start(name, attributes) case name when "node" @host["hardware-address"] = attributes["hardware-address"] @host["addr"] = attributes["address"] @host["status"] = attributes["status"] when "os" # Take only the highest certainty if not @host["os_certainty"] or (@host["os_certainty"].to_f < attributes["certainty"].to_f) @host["os_vendor"] = attributes["vendor"] @host["os_family"] = attributes["family"] @host["os_product"] = attributes["product"] @host["os_version"] = attributes["version"] @host["arch"] = attributes["arch"] @host["os_certainty"] = attributes["certainty"] end when "name" #@host["names"].push attributes["name"] @state = :in_name when "endpoint" # This is a port in NeXpose parlance @host["endpoints"].push(attributes) when "service" @state = :in_service # Store any service info with the associated port. There shouldn't # be any collisions on attribute names here, so just merge them. @host["endpoints"].last.merge!(attributes) when "fingerprint" if @state == :in_service @host["endpoints"].last.merge!(attributes) end when "test" if attributes["status"] == "vulnerable-exploited" or attributes["status"] == "vulnerable-version" @host["vulns"][attributes["id"]] = attributes.dup if attributes["key"] @host["notes"] ||= [] @host["notes"] << [attributes["id"], attributes["key"]] end end when "vulnerability" @vuln.merge! attributes when "reference" @state = :in_reference @vuln["refs"].push attributes end end |
#text(str) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/rex/parser/nexpose_xml.rb', line 67 def text(str) case @state when :in_name @host["names"].push str when :in_reference @vuln["refs"].last["value"] = str end end |
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy
90 91 |
# File 'lib/rex/parser/nexpose_xml.rb', line 90 def xmldecl(version, encoding, standalone) # :nodoc: end |