Class: Rex::Parser::RetinaXMLStreamParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/parser/retina_xml.rb

Overview

XXX - Retina XML does not include ANY service/port information export

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(on_found_host = nil) ⇒ RetinaXMLStreamParser

Returns a new instance of RetinaXMLStreamParser.



10
11
12
13
# File 'lib/rex/parser/retina_xml.rb', line 10

def initialize(on_found_host = nil)
  reset_state
  self.on_found_host = on_found_host if on_found_host
end

Instance Attribute Details

#on_found_hostObject

Returns the value of attribute on_found_host.



8
9
10
# File 'lib/rex/parser/retina_xml.rb', line 8

def on_found_host
  @on_found_host
end

Instance Method Details

#attlistObject



81
# File 'lib/rex/parser/retina_xml.rb', line 81

def attlist; end

#cdataObject



78
# File 'lib/rex/parser/retina_xml.rb', line 78

def cdata; end

#comment(str) ⇒ Object



79
# File 'lib/rex/parser/retina_xml.rb', line 79

def comment(str); end

#instruction(name, instruction) ⇒ Object



80
# File 'lib/rex/parser/retina_xml.rb', line 80

def instruction(name, instruction); end

#reset_audit_stateObject



21
22
23
# File 'lib/rex/parser/retina_xml.rb', line 21

def reset_audit_state
  @audit = { 'refs' => [] }
end

#reset_stateObject



15
16
17
18
19
# File 'lib/rex/parser/retina_xml.rb', line 15

def reset_state
  @state = :generic_state
  @host  = { 'vulns' => [] }
  reset_audit_state
end

#tag_end(name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/rex/parser/retina_xml.rb', line 65

def tag_end(name)
  case name
  when "host"
    on_found_host.call(@host) if on_found_host
    reset_state
  when "audit"
    @host['vulns'].push @audit
    reset_audit_state
  end
end

#tag_start(name, attributes) ⇒ Object



25
26
27
# File 'lib/rex/parser/retina_xml.rb', line 25

def tag_start(name, attributes)
  @state = "in_#{name.downcase}".intern
end

#text(str) ⇒ Object



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
# File 'lib/rex/parser/retina_xml.rb', line 29

def text(str)
  case @state
  when :in_ip
    @host["address"] = str
  when :in_dnsname
    @host["hostname"] = str.split(/\s+/).first
  when :in_netbiosname
    @host["netbios"] = str
  when :in_mac
    @host["mac"] = str
  when :in_os
    @host["os"] = str
  when :in_rthid
    @audit['refs'].push(['RETINA', str])
  when :in_cve
    str.split(",").each do |cve|
      cve = cve.to_s.strip
      next if cve.empty?
      pre,val = cve.split('-', 2)
      next if not val
      next if pre != "CVE"
      @audit['refs'].push( ['CVE', val] )
    end
  when :in_name
    @audit['name'] = str
  when :in_description
    @audit['description'] = str
  when :in_risk
    @audit['risk'] = str
  when :in_cce
    @audit['cce'] = str
  when :in_date
    @audit['data'] = str
  end
end

#xmldecl(version, encoding, standalone) ⇒ Object

We don’t need these methods, but they’re necessary to keep REXML happy



77
# File 'lib/rex/parser/retina_xml.rb', line 77

def xmldecl(version, encoding, standalone); end