Class: Rex::Parser::IP360XMLStreamParser
- Inherits:
-
Object
- Object
- Rex::Parser::IP360XMLStreamParser
- Defined in:
- lib/rex/parser/ip360_xml.rb
Instance Attribute Summary collapse
-
#on_found_host ⇒ Object
Returns the value of attribute on_found_host.
Instance Method Summary collapse
-
#attlist ⇒ Object
:nodoc:.
- #cdata(d) ⇒ Object
-
#comment(str) ⇒ Object
:nodoc:.
-
#initialize(&block) ⇒ IP360XMLStreamParser
constructor
A new instance of IP360XMLStreamParser.
-
#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(&block) ⇒ IP360XMLStreamParser
Returns a new instance of IP360XMLStreamParser.
13 14 15 16 |
# File 'lib/rex/parser/ip360_xml.rb', line 13 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.
11 12 13 |
# File 'lib/rex/parser/ip360_xml.rb', line 11 def on_found_host @on_found_host end |
Instance Method Details
#attlist ⇒ Object
:nodoc:
93 94 |
# File 'lib/rex/parser/ip360_xml.rb', line 93 def attlist # :nodoc: end |
#cdata(d) ⇒ Object
81 82 83 |
# File 'lib/rex/parser/ip360_xml.rb', line 81 def cdata(d) #do nothing end |
#comment(str) ⇒ Object
:nodoc:
89 90 |
# File 'lib/rex/parser/ip360_xml.rb', line 89 def comment(str) # :nodoc: end |
#instruction(name, instruction) ⇒ Object
:nodoc:
91 92 |
# File 'lib/rex/parser/ip360_xml.rb', line 91 def instruction(name, instruction) # :nodoc: end |
#reset_state ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rex/parser/ip360_xml.rb', line 18 def reset_state @host = {'hname' => nil, 'hid' => nil, 'addr' => nil, 'mac' => nil, 'os' => nil, 'vulns' => ['vuln' => {'vulnid' => nil, 'port' => nil, 'proto' => nil} ], 'apps' => ['app' => {'appid' => nil, 'svcid' => nil, 'port' => nil, 'proto' => nil } ], } @state = :generic_state end |
#tag_end(name) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rex/parser/ip360_xml.rb', line 70 def tag_end(name) case name when "host" on_found_host.call(@host) if on_found_host reset_state when "vulnerability" @host['vulns'].push @x end @state = :generic_state end |
#tag_start(name, attributes) ⇒ Object
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 |
# File 'lib/rex/parser/ip360_xml.rb', line 26 def tag_start(name, attributes) case name when "host" @host['hid'] = attributes['persistent_id'] when "ip" @state = :is_ip when "dnsName" @state = :is_fqdn when "macAddress" @state = :is_mac when "os" @host['os'] = attributes['id'] when "vulnerability" @x = Hash.new @x['vulnid'] = attributes['id'] when "port" @state = :is_port when "protocol" @state = :is_proto when "application" @y = Hash.new @y['appid'] = attributes['application_id'] @y['svcid'] = attributes['svcid'] @y['port'] = attributes['port'] @y['proto'] = attributes['protocol'] @host['apps'].push @y end end |
#text(str) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rex/parser/ip360_xml.rb', line 55 def text(str) case @state when :is_fqdn @host['hname'] = str when :is_ip @host['addr'] = str when :is_mac @host['mac'] = str when :is_port @x['port'] = str when :is_proto @x['proto'] = str end end |
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy
87 88 |
# File 'lib/rex/parser/ip360_xml.rb', line 87 def xmldecl(version, encoding, standalone) # :nodoc: end |