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/fusionvm_document.rb
Views: 11780
# -*- coding: binary -*-1require "rex/parser/nokogiri_doc_mixin"23module Rex4module Parser56# If Nokogiri is available, define document class.7load_nokogiri && class FusionVMDocument < Nokogiri::XML::SAX::Document8910include NokogiriDocMixin1112def start_element(name=nil,attrs=[])13return nil if in_tag("JobOrder")14attrs = normalize_attrs(attrs)15attrs = attr_hash(attrs)16@state[:current_tag][name] = true17case name18when "IPAddress"19thost={}20return nil unless attrs["IPAddress"] and attrs["HostName"]21thost = {22:host => attrs["IPAddress"],23:name => attrs["HostName"],24:workspace => @args[:workspace]25}26thost[:host] = attrs["IPAddress"]27thost[:name] = attrs["HostName"]28@host = db_report(:host, thost)29when "OS"30@state[:has_text] = true31when "Port"32@service = {33:host => @host,34:port => attrs["Number"],35:state => "open"36}37when "Service"38@state[:has_text] = true39when "Protocol"40@state[:has_text] = true41when "Exposure"42@vuln = {43:host => @host,44:refs => []45}46when "Title"47@state[:has_text] = true48when "Description"49@state[:has_text] = true50when "CVE"51@state[:has_text] = true52when "References"53@state[:has_text] = true54end55end5657def end_element(name=nil)58unless in_tag("JobOrder")59case name60when "OS"61unless @host.nil? or @text.to_s.strip.empty?62tnote = {63:type => "host.os.fusionvm_fingerprint",64:data => { :os => @text.strip },65:host => @host,66:workspace => @args[:workspace]67}68db_report(:note, tnote)69@host.normalize_os70end71when "IPAdress"72@host = nil73when "Service"74@service[:name] = @text.strip75when "Protocol"76@service[:proto] = @text.strip.downcase77when "Port"78db_report(:service, @service)79when "Exposure"80db_report(:vuln, @vuln)81when "Title"82@vuln[:name] = @text.strip83when "Description"84@vuln[:info] = @text.strip85when "CVE"86@vuln[:refs] << "CVE-#{@text.strip}"87when "References"88unless @text.to_s.strip.empty?89@text.split(' ').each do |ref|90next unless ref.start_with? "http"91if ref =~ /MS\d{2}-\d{3}/92@vuln[:refs] << "MSB-#{$&}"93else94@vuln[:refs] << "URL-#{ref.strip}"95end96end97end98end99end100@text = nil101@state[:current_tag].delete name102end103104105106end107end108end109110111