MVC模型开发框架

控制器Controller:负责响应用户请求、准备数据,及决定如何展示数据
模块Model:管理业务逻辑和数据库逻辑,提供链接和操作数据库的抽象层
视图View:负责前端模板渲染数据,通过html呈现给用户
MVC模型对代码审计的影响:
1、文件代码定位问题
2、代码过滤分析问题
3、前端安全发现问题
示例cms:http://www.lmxcms.com/file/d/down/xitong/20210628/202106281714266126.zip
入口文件:
define('LMXCMS',TRUE):定义常量LMXCMS并赋值为TRUE
inc/run.inc.php文件就是路由文件
可以看见requireClassName函数接收值,转化路径
梦想cmsV1.4.1 RCE 命令执行
源码下载:http://www.lmxcms.com/file/d/down/xitong/20210628/202106281714266126.zip
搜索eval敏感关键词

可以看见,这个文件内的eval中间有变量
$temdata['data']
而 t e m d a t a = temdata= temdata=this->model->caijiDataOne($_GET['cid']);

其中又调用了cj_data_tab()和oneModel()方法


其中oneModel又调用了oneDB方法

先构造url访问改代码处
http://127.0.0.1:8086/admin.php?m=Acquisi\&a=showCjData

加入调试代码寻找问题
class/db.class.php

c/admin/AcquisiAction.class.php

构造url:http://127.0.0.1:8086/admin.php?m=Acquisi\&a=showCjData\&lid=1\&id=1\&uid=1\&cid=1
访问

发现$temdata变量为空数组,只要使得该变量的data键的值为恶意代码即可
所以直接在数据库添加phpinfo在data字段
insert into lmx_cj_data (lid,data,uid,url,time,is_in) values ('1','phpinfo()','1','1','1','1');

再访问url:http://127.0.0.1:8086/admin.php?m=Acquisi\&a=showCjData\&lid=1\&id=1\&uid=1\&cid=1

rce执行成功
百家cms V4.1.4 RCE 代码执行
搜索system(

发现只有最后一个可能存在代码执行漏洞

来到首页,登录后进入备份与还原
http://127.0.0.1:8087/index.php?mod=site\&act=manager\&do=database\&beid=1

直接搜索manager

查看第一个文件system/manager/web.php 在该文件中找到do_database()方法,database也在url当中
那么猜测它就是对应url代码文件
添加测试代码

果然,猜测成功

那么url构造不必担心了
继续看代码执行的地方代码
php
system('convert'.$quality_command.' '.$file_full_path.' '.$file_full_path);
其中 q u a l i t y c o m m a n d = ′ − q u a l i t y ′ . i n t v a l ( quality_command=' -quality '.intval( qualitycommand=′−quality′.intval(scal); 由于intval的存在,所以这个变量放弃
$file_full_path来自于实参
找到url路径,发现这个文件路径存在于includes文件夹内,无法直接访问
includes/baijiacms/setting.inc.php
寻找包含了这个文件的文件

发现只有baijiacms.php调用过
includes/baijiacms.php
可是也是include文件夹内的文件,那么寻找调用了baijiacms.php的文件

寻找调用了file_save的地方

system/weixin/class/web/setting.php 文件存在调用
构造url
http://127.0.0.1:8087/index.php?mod=site\&act=weixin\&do=setting
访问看看

代码添加调试代码,其中WEB_ROOT."/".$file['name']是关乎system函数内的可控变量

成功

查看想要执行到system的条件

要使得$settings['image_compress_openscale'])存在即可,
$settings=globaSystemSetting();

echo一下$settings 发现根本没有image_compress_openscale这个键

搜索image_compress_openscale找到设置settings['image_compress_openscale']的地方

在system/manager/template/web/netattach.php文件

构造url访问
http://127.0.0.1:8087/index.php?mod=site\&act=manager\&do=netattach


更改为开启
再发送刚刚的包

发现终于满足了存在的条件
添加echo调试代码

再次发包

将filename参数更改为xxx&dir&.txt或xxx;dir;.txt
&是可以执行多条命令的联合符号(可以使用与linux和windows)
;也是可以执行多条命令的联合符号(只可以使用与linux)
