LMXCMS代码审计
下载地址:
大家自己找,,,,,,,,,,,,,ahhhhhhhh

审计版本:
注意看图V1.2
安装步骤:
- 放在环境的www目录下,修改数据库配置文件用户名密码
- 按照提示下一步下一步即ok

插曲
如果在xdebug的过程中,还没有完成过程就返回500的报错,需要设置修改一下配置文件

选择xdebug的站点的配置文件添加
这里的配置应该是设置的超时时间是600s,单位为S(秒)

重启服务器即ok
审源码
废话不多说,直接审源码该cms就是MVC架构,但是比较奇怪的是这个MVC写的有点不太规范,,,,,尤其这命名,对不是搞开发的同志们来说比较难受😫,,,,前端来讲功能太简单了,查询以及留言,直接看后台,后台的功能比较多,结合管理员的控制层看源码,,,,
源码结构如下:

如果说想要直接了当的去分析,去找漏洞,怎么找?命令执行漏洞?得分析路由,传参以及执行函数,文件上传,那么直接找上传点,文件包含直接找文件包含的函数,注入漏洞呢,还是找sql语句,那么逻辑漏洞呢,没什么好的方式,估计黑盒的效果都要比白盒方便,未授权也差不多个意思了,,,,
顺便“水”一下
怎么设置debug呢,,,,差不多过程就是下面的了,反正是我一直是这么审的,除此之外,我发现一个问题,很多小伙伴都比较喜欢代码审计工具,工具只是起到辅助效果,个人觉得审计的魅力不就是在debug么,,,,,,

php环境配置
路径
File->Settings-> Languages&Frameworks->PHP

安装xdebug扩展
根据php版本选择扩展文件
php-5.6-xdebug
放在对应的php文件夹执行程序的ext文件夹内

接着修改php.ini配置文件,添加xdebug配置内容
[XDebug]
xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug"
xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug"
;zend_extension="D:\phpStudy\php\php-5.6.27-nts\ext\php_xdebug.dll"
;zend_extension="C:\phpStudy20161103\php\php-5.6.27-nts\ext\php_xdebug.dll"
zend_extension="D:\phpStudy\php\php-5.6.27-nts\ext\php_xdebug-2.5.5-5.6-vc11-nts-x86_64.dll" ;指定Xdebug扩展文件的绝对路径
xdebug.auto_trace=on ;启用代码自动跟踪
xdebug.collect_params=on ;允许收集传递给函数的参数变量
xdebug.collect_return=on ;允许收集函数调用的返回值
xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug" ;指定堆栈跟踪文件的存放目录
xdebug.profiler_enable=on ;是否启用Xdebug的性能分析,并创建性能信息文件
xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug" ;指定性能分析信息文件的输出目录
xdebug.remote_enable = on ;是否开启远程调试
xdebug.remote_handler = dbgp ;指定远程调试的处理协议
xdebug.remote_host= localhost ;指定远程调试的主机名
xdebug.remote_port = 9000 ;指定远程调试的端口号
xdebug.idekey = PHPSTORM ;指定传递给DBGp调试器处理程序的IDE Key
在这里尽量根据访问该xdebug网址去识别对应的xdebug,否则无法启动debug,或者选用路径为对应php版本下的xdebug

验证xdebug安装成功

phpstrom配置debug环境

配置server

运行时选择配置的servers

浏览器安装插件方便使用进行debug测试

审源码继续
根据源码结构继续进行,前端功能比较简单,能测试的点比较少,注入,XSS,其它的也没啥了,直接看后台吧(并不是说前台没有问题),前端真的是有漏洞的,,,,主要后台功能点比较多,值得分析一下。
直接瞅一瞅看一看比较容易出现问题的地方
至于为什么看这里,看截图应该不用解释,sql注入常见的问题点

基本上关于数据库的类文件也都在这个位置,那么不考虑sql语句在查询过程中的路由,直接看这里的sql语句的话那么问题已经来了,如果能直接实现闭合的话是就可以实现注入了,增删改查的所有语句也都在这里,
那么直接寻找查询的位置进行测试,纵观后台功能,查询点开始测试,追踪路由,后台功能页

c/admin/BookAction.class.php
因为直接调试函数跟进调用的就是上面的函数语句了,下断点调试

猜测没有问题,并且测试的时候发现,有报错

那么构造构造报错语句payload即可
id=11 and updatexml(1,concat(1,user()),1) #
或者
id=11 and (extractvalue(1, concat(0x5c,user()))) #
报错语句的两种语法,,,,
okk,注入存在

接下来,大家自己发挥,送0day的时候到了,ahhhh
简单翻一翻功能,其实最直接了当的就是上传点了,就比较离谱

webshell不必多说了,就比较奇怪的就是这个上传的点的按钮点击没啥反应,可能版本的问题吧,自个花卉
源码的上传以及文件类型的检测是这样的

在upload.class.php中对上传单个文件多个文件进行了控制,上传成功命名做了设定,

在check方法中也只是对文件类型做了简单的校验,所以文件上传这块儿也是比较好利用拿shell的,,,,
后端多个地方明显存在XSS漏洞,简单测试一下,顺便追踪一下路由

效果

存储型XSS一枚,,,,追踪分析如下

确定漏洞位置,定位控制层
修改广告时,传入的参数为13个。POST传入的数据,在修改的时候调了function update方法, 同时调用了check方法对传入的数据进行过滤检测

验证文字数据的时候正则太过简单,对于remarks值来说,也就是备注没有对数据做任何的处理,所以也就造成了XSS漏洞的形成,类似的位置很多,,,,可做扩展。
结语
审计还是得靠分析和验证或者思路吧,大佬请绕路,不当之处还请各位师傅指正。