SoFunction
Updated on 2025-04-06

dedecms v5.1 WriteBookText code injection vulnerability


\include\inc_bookfunctions.php 
--------------------------------------------------- 
…… 
Copy the codeThe code is as follows:

function WriteBookText($cid,$body)  
{<span ></span>  
global $cfg_cmspath,$cfg_basedir;  
$ipath = $cfg_cmspath."/data/textdata";  
$tpath = ceil($cid/5000);  
if(!is_dir($cfg_basedir.$ipath)) MkdirAll($cfg_basedir.$ipath,$GLOBALS['cfg_dir_purview']);  
if(!is_dir($cfg_basedir.$ipath.'/'.$tpath)) MkdirAll($cfg_basedir.$ipath.'/'.$tpath,$GLOBALS['cfg_dir_purview']);  
$bookfile = $cfg_basedir.$ipath."/{$tpath}/bk{$cid}.php";  
$body = "&lt;"."?php\r\n".$body."\r\n?"."&gt;";  
@$fp = fopen($bookfile,'w');  
@flock($fp);  
@fwrite($fp,$body);  
@fclose($fp);  
<div  class="qt" style="display: block;">}  

</div>  
…… 

—————————————————

\member\story_add_content_action.php
—————————————————

…… 
Copy the codeThe code is as follows:

WriteBookText($arcID,addslashes($body));  
…… 

—————————————————

I found a good site to test it