class Rex::Parser::IP360XMLStreamParser

Attributes

on_found_host[RW]

Public Class Methods

new(&block) click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 12
def initialize(&block)
  reset_state
  on_found_host = block if block
end

Public Instance Methods

cdata(d) click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 80
def cdata(d)
  #do nothing
end
reset_state() click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 17
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) click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 69
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) click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 25
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) click to toggle source
# File lib/rex/parser/ip360_xml.rb, line 54
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