看到一个后台代码执行便来了兴趣,来复现一下。
利用方法:
1.登陆后台
修改缓存文件内容。
后台 —> 静态缓存 —> 缓存列表 —> 后台缓存 —> 修改 f6f373570fe983d7f5ea813871d99f6d
2.访问http://xxxxx/adminxxx/?usergrouplist
利用成功
代码审计:
1.后台的代码 admin793/index.php
<?php
require '../inc/zzz_admin.php';
$getModule=getModule();
$type=getform('type','get');
$folder=getform('folder','get');
$module=!empty($getModule) ? $getModule : 'index';
$GLOBALS['type']=$type;
geturl();
switch ($module) {
............................
//echop (parse_admin_tlp($module));die;
include parse_admin_tlp($module);
可以看到又两个文件包含 require '../inc/zzz_admin.php';(检测网站安装状态) 与 include parse_admin_tlp($module);
2.定位 parse_admin_tlp() 函数
function parse_admin_tlp( $module ) {
$tpltype = G( 'ID' ) ? 'edit' : 'add'; //全局变量匹配ID,如果匹配到则将edit赋值给$tpltype,反之则将add赋值给$tpltype,
$tplfile = SITE_DIR . conf( 'adminpath' ) . 'template/' . $module . '.tpl';
//拼接$tplfile
$cachefile = RUN_DIR . 'cache/' . conf( 'adminpath' ) . md5( $module . $tpltype ) . '.tpl';
//拼接$cachefile
//echop ($tplfile);echop ($cachefile);
//echop( template_parse(load_file($tplfile)));
if ( !is_file( $cachefile ) || time_file( $tplfile ) > time_file( $cachefile ) || size_file( $tplfile ) == 0 ) {
create_file( $cachefile, template_parse( load_file( $tplfile ) ) );
}//如果不存在$cachefile或者$tplfile文件大小=1或者time_file( $tplfile ) > time_file( $cachefile )就创建$cachefile
return $cachefile;
//返回 $cachefile
}
3.而 cachefile 文件内容可以在后台修改,如果其内容修改为任意 php 代码,则会造成任意 php 代码执行。cachefile就是 /2/zzzphp_a5/runtime/cache/admin793/f6f373570fe983d7f5ea813871d99f6d.tpl ,可以修改
4.现在来研究一下 $module 传的是什么参数形成了f6f373570fe983d7f5ea813871d99f6d.tpl 这个文件
usergrouplistadd md5 加密之后是f6f373570fe983d7f5ea813871d99f6d
根据代码
$tpltype = G( 'ID' ) ? 'edit' : 'add';
$tplfile = SITE_DIR . conf( 'adminpath' ) . 'template/' . $module . '.tpl';
$cachefile = RUN_DIR . 'cache/' . conf( 'adminpath' ) . md5( $module . $tpltype ) . '.tpl';
得知$module=usergrouplist
5.所以访问 http://127.0.0.1/2/zzzphp_a5/admin793/?module=usergrouplist 就可以实现任意代码执行。
现在重头开始分析一下
先发现后台缓存列表可以修改任意代码,那么开始寻找是否又文件包含漏洞
然后在后台发现两个可以文件包含的地方,第一个是关于网站安装状态的,第二个开始分析,通过定位函数发现创建了一个文件,通过分析文件路径找到这个文件,然后结合前面的可以修改文件内容构成了任意代码执行
原文链接:https://www.jianshu.com/p/9626e6720fd4
打赏我,让我更有动力~
zzzphp_a5.zip File Size:10.685M (Download Count:0)
© 2016 - 2022 掌控者 All Rights Reserved.