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/netsparker_xml.rb
Views: 11780
# -*- coding: binary -*-1module Rex2module Parser345class NetSparkerXMLStreamParser67attr_accessor :on_found_vuln89def initialize(on_found_vuln = nil)10self.on_found_vuln = on_found_vuln if on_found_vuln11reset_state12end1314def reset_state15@state = :generic_state16@vuln = {'info' => []}17@attr = {}18end1920def tag_start(name, attributes)21@state = "in_#{name.downcase}".intern22@attr = attributes2324case name25when "vulnerability"26@vuln = { 'info' => [] }27@vuln['confirmed'] = attributes['confirmed']28end29end3031def text(str)32case @state33when :in_url34@vuln['url'] ||= ""35@vuln['url'] += str36when :in_type37@vuln['type'] ||= ""38@vuln['type'] += str39when :in_severity40@vuln['severity'] ||= ""41@vuln['severity'] += str42when :in_vulnerableparametertype43@vuln["vparam_type"] ||= ""44@vuln["vparam_type"] += str45when :in_vulnerableparameter46@vuln["vparam_name"] ||= ""47@vuln["vparam_name"] += str48when :in_vulnerableparametervalue49@vuln["vparam_value"] ||= ""50@vuln["vparam_value"] += str51when :in_rawrequest52@vuln["request"] ||= ""53@vuln["request"] += str54when :in_rawresponse55@vuln["response"] ||= ""56@vuln["response"] += str57when :in_info58# <info name="Identified Internal Path(s)">C:\AppServ\www\test-apps\dokeos\main\inc\banner.inc.php</info>59if not str.to_s.strip.empty?60@vuln['info'] << [@attr['name'] || "Information", str]61end62when :in_netsparker63when :in_target64when :in_scantime65when :generic_state66when :in_vulnerability67when :in_extrainformation68else69# $stderr.puts "unknown state: #{@state}"70end71end7273def tag_end(name)74case name75when "vulnerability"76@vuln.keys.each do |k|77@vuln[k] = @vuln[k].strip if @vuln[k].kind_of?(::String)78end79on_found_vuln.call(@vuln) if on_found_vuln80reset_state81end82end8384# We don't need these methods, but they're necessary to keep REXML happy85def xmldecl(version, encoding, standalone); end86def cdata(data)87puts "cdata for #{@state} (#{data.length})"88case @state89when :in_rawresponse90@vuln["response"] = data91when :in_rawrequest92@vuln["request"] = data93when :in_info94if not data.to_s.strip.empty?95@vuln['info'] << [@attr['name'] || "Information", data]96end97end98end99100def comment(str); end101def instruction(name, instruction); end102def attlist; end103end104end105end106107__END__108109110111