class Rex::Parser::Outpost24Document

Public Instance Methods

collect_host() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 135
def collect_host
  @host[:host] = @state[:host]
  @host[:name] = @state[:hname]
  @host[:os_name] = @state[:os_name]
  @host[:info] = @state[:pinfo]
  @report_data[:hosts] << @host
end
collect_host_data(name) click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 172
def collect_host_data(name)
  @state[:has_text] = false
  if name == "name"
    @state[:hname] = @text.strip if @text
  elsif name == "platform"
    if @text
      @state[:os_name] = @text.strip
    else
      @state[:os_name] = Msf::OperatingSystems::UNKNOWN
    end
  end
  @text = nil
end
collect_ip() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 166
def collect_ip
  @state[:has_text] = false
  @state[:host] = @text.strip if @text
  @text = nil
end
collect_product() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 160
def collect_product
  @state[:has_text] = false
  @state[:pinfo] = @text.strip if @text
  @text = nil
end
collect_service() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 143
def collect_service
  @service[:host] = @state[:host]
  @service[:port] = @state[:port]
  @service[:proto] = @state[:proto]
  @service[:name] = @state[:sname]
  @service[:info] = @state[:pinfo]
  @report_data[:services] << @service
end
collect_service_data(name) click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 186
def collect_service_data(name)
  @state[:has_text] = false
  if name == "portnumber"
    @state[:port] = @text.strip if @text
  elsif name == "protocol"
    @state[:proto] = @text.strip.downcase if @text
  elsif name == "service"
    @state[:sname] = @text.strip if @text
  end
  @text = nil
end
collect_vuln() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 152
def collect_vuln
  @vuln[:host] = @state[:host]
  @vuln[:name] = @state[:vname]
  @vuln[:info] = @state[:vinfo]
  @vuln[:refs] = @refs
  @report_data[:vulns] << @vuln
end
collect_vuln_data(name) click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 198
def collect_vuln_data(name)
  @state[:has_text] = false
  if name == "name"
    @state[:vname] = @text.strip if @text
  elsif name == "description"
    @state[:vinfo] = @text.strip if @text
  elsif name == "information"
    @state[:vinfo] << " #{@text.strip if @text}"
  elsif name == "id"
    @state[:ref] = @text.strip if @text
    @refs << normalize_ref("CVE", @state[:ref])
  end
  @text = nil
end
end_element(name) click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 56
def end_element(name)
  case name
  when "description", "information"
    return unless in_tag("detaillist")
    return unless in_tag("detail")
    collect_vuln_data(name)
  when "detail"
    return unless in_tag("detaillist")
    collect_vuln
  when "detaillist"
    report_vulns
  when "host"
    return unless in_tag("hostlist")
    collect_host
  when "hostlist"
    report_hosts
  when "id"
    return unless in_tag("detaillist")
    return unless in_tag("detail")
    return unless in_tag("cve")
    collect_vuln_data(name)
  when "ip"
    collect_ip
  when "name"
    if in_tag("hostlist") && in_tag("host")
      collect_host_data(name)
    elsif in_tag("detaillist") && in_tag("detail")
      collect_vuln_data(name)
    end
  when "platform"
    return unless in_tag("hostlist")
    return unless in_tag("host")
    collect_host_data(name)
  when "portinfo"
    return unless in_tag("portlist")
    return unless in_tag("portlist-host")
    collect_service
  when "portlist"
    report_services
  when "portnumber", "protocol", "service"
    return unless in_tag("portlist")
    return unless in_tag("portlist-host")
    return unless in_tag("portinfo")
    collect_service_data(name)
  when "report"
    collect_product
  end
  @state[:current_tag].delete(name)
end
record_host() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 118
def record_host
  @host = {}
end
record_hosts() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 106
def record_hosts
  @report_data[:hosts] = []
end
record_service() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 122
def record_service
  @service = {}
end
record_services() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 110
def record_services
  @report_data[:services] = []
end
record_text() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 131
def record_text
  @state[:has_text] = true
end
record_vuln() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 126
def record_vuln
  @vuln = {}
  @refs = []
end
record_vulns() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 114
def record_vulns
  @report_data[:vulns] = []
end
report_hosts() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 213
def report_hosts
  block = @block
  @report_data[:hosts].each do |h|
    db.emit(:address, h[:host], &block) if block
    db_report(:host, h)
  end
end
report_services() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 221
def report_services
  block = @block
  @report_data[:services].each do |s|
    db.emit(:service, "#{s[:host]}:#{s[:port]}/#{s[:proto]}", &block) if block
    db_report(:service, s)
  end
end
report_vulns() click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 229
def report_vulns
  block = @block
  @report_data[:vulns].each do |v|
    db.emit(:vuln, ["#{v[:name]} (#{v[:host]})", 1], &block) if block
    db_report(:vuln, v)
  end
end
start_element(name, attrs) click to toggle source
# File lib/rex/parser/outpost24_nokogiri.rb, line 10
def start_element(name, attrs)
  @state[:current_tag][name] = true
  case name
  when "description", "information"
    return unless in_tag("detaillist")
    return unless in_tag("detail")
    record_text
  when "detail"
    return unless in_tag("detaillist")
    record_vuln
  when "detaillist"
    record_vulns
  when "host"
    return unless in_tag("hostlist")
    record_host
  when "hostlist"
    record_hosts
  when "id"
    return unless in_tag("detaillist")
    return unless in_tag("detail")
    return unless in_tag("cve")
    record_text
  when "name"
    return unless in_tag("hostlist") || in_tag("detaillist")
    return unless in_tag("host") || in_tag("detail")
    record_text
  when "platform"
    return unless in_tag("hostlist")
    return unless in_tag("host")
    record_text
  when "portinfo"
    return unless in_tag("portlist")
    return unless in_tag("portlist-host")
    record_service
  when "portlist"
    record_services
  when "portnumber", "protocol", "service"
    return unless in_tag("portlist")
    return unless in_tag("portlist-host")
    return unless in_tag("portinfo")
    record_text
  when "report", "ip"
    record_text
  end
end