Skip to content

Commit 7579b57

Browse files
author
Tod Beardsley
committed
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.
1 parent 902cd7e commit 7579b57

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_rzl_read_dir.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
##
2424

2525
require 'msf/core'
26+
require 'rexml/document'
2627

2728
class Metasploit4 < Msf::Auxiliary
2829
include Msf::Exploit::Remote::HttpClient
@@ -60,14 +61,18 @@ def initialize
6061

6162
def parse_xml(xml_data)
6263
files = []
63-
xml_doc = Nokogiri::XML(xml_data)
64-
xml_doc.css('item').each {|item|
65-
name = item.css('NAME')
66-
size = item.css('SIZE')
67-
if not name.empty? and not size.empty?
68-
files << { "name" => name.text, "size" => size.text }
64+
xml_doc = REXML::Document.new(xml_data)
65+
xml_doc.root.each_element('//item') do |item|
66+
name = size = nil
67+
item.each_element do |elem|
68+
name = elem.text if elem.name == "NAME"
69+
size = elem.text if elem.name == "SIZE"
70+
break if name and size
6971
end
70-
}
72+
if (name and size) and not (name.empty? or size.empty?)
73+
files << { "name" => name, "size" => size }
74+
end
75+
end
7176
return files
7277
end
7378

0 commit comments

Comments
 (0)