Rework parse_xml
We try to avoid using Nokogiri in modules due to the sometimes uncomfortable dependencies it creates with particular compiled libxml versions. Also, the previous parse_xml doesn't seem to be correctly skipping item entries with blank names. I will paste the test XML in the PR proper, but do check against a live target to make sure I'm not screwing it up.unstable
parent
902cd7ec85
commit
7579b574cb
|
@ -23,6 +23,7 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
require 'msf/core'
|
require 'msf/core'
|
||||||
|
require 'rexml/document'
|
||||||
|
|
||||||
class Metasploit4 < Msf::Auxiliary
|
class Metasploit4 < Msf::Auxiliary
|
||||||
include Msf::Exploit::Remote::HttpClient
|
include Msf::Exploit::Remote::HttpClient
|
||||||
|
@ -60,14 +61,18 @@ class Metasploit4 < Msf::Auxiliary
|
||||||
|
|
||||||
def parse_xml(xml_data)
|
def parse_xml(xml_data)
|
||||||
files = []
|
files = []
|
||||||
xml_doc = Nokogiri::XML(xml_data)
|
xml_doc = REXML::Document.new(xml_data)
|
||||||
xml_doc.css('item').each {|item|
|
xml_doc.root.each_element('//item') do |item|
|
||||||
name = item.css('NAME')
|
name = size = nil
|
||||||
size = item.css('SIZE')
|
item.each_element do |elem|
|
||||||
if not name.empty? and not size.empty?
|
name = elem.text if elem.name == "NAME"
|
||||||
files << { "name" => name.text, "size" => size.text }
|
size = elem.text if elem.name == "SIZE"
|
||||||
|
break if name and size
|
||||||
|
end
|
||||||
|
if (name and size) and not (name.empty? or size.empty?)
|
||||||
|
files << { "name" => name, "size" => size }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
|
||||||
return files
|
return files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue