Dedecms预认证远程代码执行漏洞
This_is_Y Lv6

0x1

参考:https://www.ddosi.org/dedecms-poc/#ShowMsg_%E6%A8%A1%E6%9D%BF%E6%B3%A8%E5%85%A5%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E

这个漏洞只影响5.8.1 预发布版本
下载链接:https://github.com/dedecms/DedeCMS/archive/refs/tags/v5.8.1.zip

验证版本:http://127.0.0.1/DedeCMS-5.8.1/data/admin/ver.txt
image-20211012155400476

先看一下它的poc跟着走一下代码
POC:

1
2
3
GET /plus/flink.php?dopost=save&c=id HTTP/1.1
Host: target
Referer: <?php "system"($c);die;/*

bp抓包,修改一下,传给phpstorm
image-20211012162516995

跳到ShowMsg函数里面

image-20211012162614100

gourl传入的是-1image-20211012162722990
所以这里会从HTTP_REFERER里获取gourl,POC这里是<?php “system”($c);die;/*

然后gourl会嵌入到$func变量里,$func变量又会拼接到$msg遍历里面,最后,由DedeTemplate()类里的LoadString()方法和Display()来处理$msg变量,接下来看LoadSting()和Display()

image-20211012163457451
image-20211012163517491

DedeTemplate()类在include/dedetemplate.class.php文件里,372行处是LoadString()函数,
函数把$this->sourceString设置为了传入的msg,然后cachedir值为/data/tplcache,然后在本地目录找到了这个文件,打开它,发现location这个地方还是<?php “system”($c);die;/*

image-20211012165040497

image-20211012164840863

继续看代码,走完$this->ParseTemplate();这一步,this->sourceString里的location还是
Referer: <?php “system”($c);die;/*。
image-20211012165749148

然后走display,display里有一步WriteCach(),跟进

image-20211012165918492

进入到WriteCache()后,我这里的走向和参考博客里不一样,我这里if判断为false,直接跳出来了,但是不走if里面的代码,最后也能出来结果,有点迷惑,

image-20211012183403469

 Comments