Class: Rex::Parser::NessusXMLStreamParser
- Inherits:
-
Object
- Object
- Rex::Parser::NessusXMLStreamParser
- Defined in:
- lib/rex/parser/nessus_xml.rb
Instance Attribute Summary collapse
-
#on_found_host ⇒ Object
Returns the value of attribute on_found_host.
Instance Method Summary collapse
- #attlist ⇒ Object
- #cdata ⇒ Object
- #comment(str) ⇒ Object
-
#initialize(&block) ⇒ NessusXMLStreamParser
constructor
A new instance of NessusXMLStreamParser.
- #instruction(name, instruction) ⇒ Object
- #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(&block) ⇒ NessusXMLStreamParser
Returns a new instance of NessusXMLStreamParser.
12 13 14 15 |
# File 'lib/rex/parser/nessus_xml.rb', line 12 def initialize(&block) reset_state on_found_host = block if block end |
Instance Attribute Details
#on_found_host ⇒ Object
Returns the value of attribute on_found_host.
10 11 12 |
# File 'lib/rex/parser/nessus_xml.rb', line 10 def on_found_host @on_found_host end |
Instance Method Details
#attlist ⇒ Object
113 |
# File 'lib/rex/parser/nessus_xml.rb', line 113 def attlist; end |
#cdata ⇒ Object
110 |
# File 'lib/rex/parser/nessus_xml.rb', line 110 def cdata; end |
#comment(str) ⇒ Object
111 |
# File 'lib/rex/parser/nessus_xml.rb', line 111 def comment(str); end |
#instruction(name, instruction) ⇒ Object
112 |
# File 'lib/rex/parser/nessus_xml.rb', line 112 def instruction(name, instruction); end |
#reset_state ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rex/parser/nessus_xml.rb', line 17 def reset_state @host = {'hname' => nil, 'addr' => nil, 'mac' => nil, 'os' => nil, 'ports' => [ 'port' => {'port' => nil, 'svc_name' => nil, 'proto' => nil, 'severity' => nil, 'nasl' => nil, 'description' => nil, 'cve' => [], 'bid' => [], 'xref' => [], 'msf' => nil } ] } @state = :generic_state end |
#tag_end(name) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rex/parser/nessus_xml.rb', line 93 def tag_end(name) case name when "ReportHost" on_found_host.call(@host) if on_found_host reset_state when "ReportItem" @x['cve'] = @cve @x['bid'] = @bid @x['xref'] = @xref @host['ports'].push @x end @state = :generic_state end |
#tag_start(name, attributes) ⇒ Object
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 66 67 |
# File 'lib/rex/parser/nessus_xml.rb', line 24 def tag_start(name, attributes) case name when "tag" if attributes['name'] == "mac-address" @state = :is_mac end if attributes['name'] == "host-fqdn" @state = :is_fqdn end if attributes['name'] == "ip-addr" @state = :is_ip end if attributes['name'] == "host-ip" @state = :is_ip end if attributes['name'] == "operating-system" @state = :is_os end when "ReportHost" @host['hname'] = attributes['name'] when "ReportItem" @cve = Array.new @bid = Array.new @xref = Array.new @x = Hash.new @x['nasl'] = attributes['pluginID'] @x['port'] = attributes['port'] @x['proto'] = attributes['protocol'] @x['svc_name'] = attributes['svc_name'] @x['severity'] = attributes['severity'] when "description" @state = :is_desc when "cve" @state = :is_cve when "bid" @state = :is_bid when "xref" @state = :is_xref when "solution" @state = :is_solution when "metasploit_name" @state = :msf end end |
#text(str) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rex/parser/nessus_xml.rb', line 69 def text(str) case @state when :is_fqdn @host['hname'] = str when :is_ip @host['addr'] = str when :is_os @host['os'] = str when :is_mac @host['mac'] = str when :is_desc @x['description'] = str when :is_cve @cve.push str when :is_bid @bid.push str when :is_xref @xref.push str when :msf #p str @x['msf'] = str end end |
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy
109 |
# File 'lib/rex/parser/nessus_xml.rb', line 109 def xmldecl(version, encoding, standalone); end |