来源:phpeval's BLOG
作者:phpeval
include/inc_request_vars.php
//注册请求字符串并加转义
function FilterNotSafeString(&$str)
{
global $cfg_notallowstr,$cfg_replacestr;
if(strlen($str)>10)
{
//禁止字串
if(!empty($cfg_notallowstr) && eregi($cfg_notallowstr,$str)) { //当$str包含一个空字符时。这句就过了
echo "Messege Error! <a href='javascript:history.go(-1)'>[Go Back]</a>";
exit();
}
//替换字串
if(!empty($cfg_replacestr)) {
$str = eregi_replace($cfg_replacestr,'***',$str); //但是如果$cfg_replacestr这个东西有了的时候。$str空字符后的东西就会被截断了。 (一个两难的地方。by: phpeval)
}
}
}
function RunMagicQuotes(&$str)
{
global $needFilter,$cfg_notallowstr,$cfg_replacestr;
if(!get_magic_quotes_gpc())
{
if( is_array($str) ) {
foreach($str as $key => $val) $str[$key] = RunMagicQuotes($val);
}else{
if($needFilter) FilterNotSafeString($str);
$str = addslashes($str);
}
}
else
{
if($needFilter) {
$str = stripslashes($str); //先解码
FilterNotSafeString($str);
addslashes($str); //这里失误,没有赋值,上面又解码了,所以导致很严重的问题,当然也可以直接GetWebshell
}
}
return $str;
}
//传递变量
foreach(Array('_GET','_POST','_COOKIE') as $_request)
{
foreach($$_request as $_k => $_v){
if($_k{0} != '_') ${$_k} = RunMagicQuotes($_v);
}
}
原创文章如转载,请注明:转载自心动吧黑客BLOG [ http://www.abcxd.com/abcxd/ ]
本文链接地址:http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/DedeCms-V51GBK_SP1_B88-deyigeloudong.html