DedeCms V51GBK_SP1_B88 的一个漏洞

来源:phpeval's BLOG
作者:phpeval

include/inc_request_vars.php

  1. //注册请求字符串并加转义  
  2. function FilterNotSafeString(&$str)  
  3. {  
  4.    global $cfg_notallowstr,$cfg_replacestr;  
  5.    if(strlen($str)>10)  
  6.    {  
  7.       //禁止字串  
  8.       if(!emptyempty($cfg_notallowstr) && eregi($cfg_notallowstr,$str)) {  //当$str包含一个空字符时。这句就过了  
  9.          echo "Messege Error! <a href='javascript:history.go(-1)'>[Go Back]</a>";  
  10.          exit();  
  11.       }  
  12.       //替换字串  
  13.       if(!emptyempty($cfg_replacestr)) {  
  14.           $str = eregi_replace($cfg_replacestr,'***',$str);   //但是如果$cfg_replacestr这个东西有了的时候。$str空字符后的东西就会被截断了。 (一个两难的地方。by: phpeval)  
  15.       }  
  16.    }  
  17. }  
  18.  
  19. function RunMagicQuotes(&$str)  
  20. {  
  21.   global $needFilter,$cfg_notallowstr,$cfg_replacestr;  
  22.   if(!get_magic_quotes_gpc())  
  23.   {  
  24.      ifis_array($str) ) {  
  25.         foreach($str as $key => $val$str[$key] = RunMagicQuotes($val);  
  26.      }else{  
  27.         if($needFilter) FilterNotSafeString($str);  
  28.         $str = addslashes($str);  
  29.      }  
  30.   }  
  31.   else 
  32.   {  
  33.      if($needFilter) {  
  34.          $str = stripslashes($str);  //先解码  
  35.          FilterNotSafeString($str);  
  36.          addslashes($str);  //这里失误,没有赋值,上面又解码了,所以导致很严重的问题,当然也可以直接GetWebshell          
  37.      }  
  38.   }  
  39.   return $str;  
  40. }  
  41.  
  42. //传递变量  
  43. foreach(Array('_GET','_POST','_COOKIE'as $_request)   
  44. {  
  45.    foreach($$_request as $_k => $_v){  
  46.       if($_k{0} != '_') ${$_k} = RunMagicQuotes($_v);  
  47.    }  

 

Leave a comment

Your comment

Why not Login? Sign up now! »