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
115 |
# File 'lib/rex/parser/nessus_xml.rb', line 115 def attlist; end |
#cdata ⇒ Object
112 |
# File 'lib/rex/parser/nessus_xml.rb', line 112 def cdata; end |
#comment(str) ⇒ Object
113 |
# File 'lib/rex/parser/nessus_xml.rb', line 113 def comment(str); end |
#instruction(name, instruction) ⇒ Object
114 |
# File 'lib/rex/parser/nessus_xml.rb', line 114 def instruction(name, instruction); end |
#reset_state ⇒ Object
17 18 19 20 21 22 23 |
# 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, 'nasl_name' => nil, 'description' => nil, 'cve' => [], 'bid' => [], 'xref' => [], 'msf' => nil } ] } @state = :generic_state end |
#tag_end(name) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rex/parser/nessus_xml.rb', line 95 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
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 68 69 |
# File 'lib/rex/parser/nessus_xml.rb', line 25 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['nasl_name'] = attributes['pluginName'] @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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rex/parser/nessus_xml.rb', line 71 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
111 |
# File 'lib/rex/parser/nessus_xml.rb', line 111 def xmldecl(version, encoding, standalone); end |