Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/parser/ip360_xml.rb
Views: 11780
# -*- coding: binary -*-1require 'rexml/document'23module Rex4module Parser567class IP360XMLStreamParser89attr_accessor :on_found_host1011def initialize(&block)12reset_state13on_found_host = block if block14end1516def reset_state17@host = {'hname' => nil, 'hid' => nil, 'addr' => nil, 'mac' => nil, 'os' => nil,18'vulns' => ['vuln' => {'vulnid' => nil, 'port' => nil, 'proto' => nil} ],19'apps' => ['app' => {'appid' => nil, 'svcid' => nil, 'port' => nil, 'proto' => nil } ],20}21@state = :generic_state22end2324def tag_start(name, attributes)25case name26when "host"27@host['hid'] = attributes['persistent_id']28when "ip"29@state = :is_ip30when "dnsName"31@state = :is_fqdn32when "macAddress"33@state = :is_mac34when "os"35@host['os'] = attributes['id']36when "vulnerability"37@x = Hash.new38@x['vulnid'] = attributes['id']39when "port"40@state = :is_port41when "protocol"42@state = :is_proto43when "application"44@y = Hash.new45@y['appid'] = attributes['application_id']46@y['svcid'] = attributes['svcid']47@y['port'] = attributes['port']48@y['proto'] = attributes['protocol']49@host['apps'].push @y50end51end5253def text(str)54case @state55when :is_fqdn56@host['hname'] = str57when :is_ip58@host['addr'] = str59when :is_mac60@host['mac'] = str61when :is_port62@x['port'] = str63when :is_proto64@x['proto'] = str65end66end6768def tag_end(name)69case name70when "host"71on_found_host.call(@host) if on_found_host72reset_state73when "vulnerability"74@host['vulns'].push @x75end76@state = :generic_state77end7879def cdata(d)80#do nothing81end8283# We don't need these methods, but they're necessary to keep REXML happy84#85def xmldecl(version, encoding, standalone) # :nodoc:86end87def comment(str) # :nodoc:88end89def instruction(name, instruction) # :nodoc:90end91def attlist # :nodoc:92end93end9495end96end979899