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/wapiti_document.rb
Views: 11780
# -*- coding: binary -*-1require "rex/parser/nokogiri_doc_mixin"23module Rex4module Parser56load_nokogiri && class WapitiDocument < Nokogiri::XML::SAX::Document78include NokogiriDocMixin910def start_element(name=nil,attrs=[])11attrs = normalize_attrs(attrs)12block = @block13@state[:current_tag][name] = true1415case name16when "timestamp"17@state[:has_text] = true18when "url"19@state[:has_text] = true20when "addr"21@state[:has_text] = true22when "port"23@state[:has_text] = true24when "parameter"25@state[:has_text] = true26when "info"27@state[:has_text] = true28when "description"29@state[:has_text] = true30when "solution"31@state[:has_text] = true32when "title"33@state[:has_text] = true34end35end3637def end_element(name=nil)38block = @block39case name40when "timestamp"41@state[:timestamp] = @text.strip42@text = nil43when "url"44@state[:url] = @text.strip45@text = nil46when "addr"47@state[:host] = @text.strip48@text = nil49when "port"50@state[:port] = @text.strip51@text = nil52when "parameter"53@state[:parameter] = @text.strip54@text = nil55when "info"56@state[:info] = @text.strip57@text = nil58when "bug"59report_vuln60end61end6263def report_vuln(&block)64proto = @state[:url].split(":")[0]65path = '/' + (@state[:url].split("/")[3..(@state[:url].split("/").length - 1)].join('/'))6667web_vuln_info = {}68web_vuln_info[:web_site] = proto + "://" + @state[:host] + ":" + @state[:port]69web_vuln_info[:path] = path70web_vuln_info[:query] = @state[:url].split("?")[1]7172#if the URL contains the parameter found to be vulnerable, it is probably a GET73#if it does not contains the parameter, it is probably a POST74if @state[:url].index(@state[:parameter])75web_vuln_info[:method] = "GET"76else77web_vuln_info[:method] = "POST"78end7980@state[:parameter].split("&").each do |param|81if param.index("%27") #apostrophe82web_vuln_info[:pname] = param.split('=')[0] #sql injection83break84elsif param.index("alert")85web_vuln_info[:pname] = param.split('=')[0] #xss86end87end8889web_vuln_info[:host] = @state[:host]90web_vuln_info[:port] = @state[:port]91web_vuln_info[:ssl] = (proto =~ /https/)92web_vuln_info[:proof] = ""93web_vuln_info[:risk] = ""94web_vuln_info[:params] = @state[:parameter]95web_vuln_info[:category] = "imported"96web_vuln_info[:confidence] = 9097web_vuln_info[:name] = @state[:info]9899db.emit(:web_vuln, web_vuln_info[:name], &block) if block100vuln = db_report(:web_vuln, web_vuln_info)101end102end103end104end105106107