phpcms v9 部分漏洞修复

发表时间
评论 没有

/phpcms/modules/member/index.php phpcms注入漏洞修复

定位到/phpcms/modules/member/index.php 610 行
源码:

$password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('password_empty'), HTTP_REFERER);

修改为:

$password = isset($_POST['password']) && trim($_POST['password']) ? addslashes(urldecode(trim($_POST['password']))) : showmessage(L('password_empty'), HTTP_REFERER);

/api/phpsso.php phpcms注入漏洞修复

定位到/api/phpsso.php 118行
源码:

$arr['uid'] = intval($arr['uid']);
$phpssouid = $arr['uid'];

合并为:

$phpssouid = intval($arr['uid']);

/phpcms/modules/content/down.php前台注入导致任意文件读取漏洞修复

定位到/phpcms/modules/content/down.php 17行
源码:

parse_str($a_k);

修改为:

$a_k = safe_replace($a_k); 
parse_str($a_k);

定位到/phpcms/modules/content/down.php 89行
源码:

parse_str($a_k);

修改为:

$a_k = safe_replace($a_k); 
parse_str($a_k);

定位到/phpcms/modules/content/down.php 120行
源码:

file_down($fileurl, $filename);

修改为:

$fileurl = str_replace(array('<','>'), '', $fileurl); 
file_down($fileurl, $filename);

/phpcms/modules/pay/respond.php phpcmsv9宽字节注入

定位到/phpcms/modules/pay/respond.php 16行
源码:

$payment = $this->get_by_code($_GET['code']);

修改为:

$payment = $this->get_by_code(mysql_real_escape_string($_GET['code']));

phpsso_server/phpcms/modules/phpsso/index.php phpcms注入漏洞

定位到phpsso_server/phpcms/modules/phpsso/index.php 424行
源码:

$applist = getcache('applist', 'admin');

再其下面添加代码:

foreach ($applist as $key => $value) {
    unset($applist[$key]['authkey']);
}

api/get_menu.php phpcms authkey泄漏漏洞

定位到api/get_menu.php 28行
源码:

$cachefile = str_replace(array('/', '//'), '', $cachefile);

修改为

$cachefile = str_replace(array('/', '//', '\\'), '', $cachefile);

phpcms/modules/poster/poster.php 文件中,未对输入参数$_GET[‘group’]进行严格过滤,导致注入漏洞

定位到/phpcms/modules/poster/poster.php 219行
源码:

if ($_GET['group']) {
    $group = " `".$_GET['group']."`";
    $fields = "*, COUNT(".$_GET['group'].") AS num";
    $order = " `num` DESC";
}

改为:

$_GET['group'] = addslashes(urldecode(trim($_GET['group'])));
if ($_GET['group']) {
    $_GET['group'] = preg_replace('#`#', '', $_GET['group']);
    $group = " `".$_GET['group']."`";
    $fields = "*, COUNT(".$_GET['group'].") AS num";
    $order = " `num` DESC";
}

phpcms/libs/classes/attachment.class.php某处逻辑问题导致getshell修复方案

定位到phpcms/libs/classes/attachment.class.php 144行
源码:

function download($field, $value,$watermark = '0',$ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
	{
        global $image_d;
		$this->att_db = pc_base::load_model('attachment_model');
		$upload_url = pc_base::load_config('system','upload_url');
		$this->field = $field;

修改(一):

function download($field, $value,$watermark = '0',$ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
	{

// 此处增加类型的判断
        if($ext !== 'gif|jpg|jpeg|bmp|png'){
            if(!in_array(strtoupper($ext),array('JPG','GIF','BMP','PNG','JPEG'))) exit('附加扩展名必须为gif、jpg、jpeg、bmp、png');
        }

        global $image_d;
		$this->att_db = pc_base::load_model('attachment_model');
		$upload_url = pc_base::load_config('system','upload_url');
		$this->field = $field;

修改(二):

function download($field, $value,$watermark = '0',$ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = ''){

之后加上

$extArray=explode('|',$ext); 
     if(!empty($extArray) && is_array($extArray)){ 
         foreach($extArray as $k => $v){ 
           if(!in_array(strtolower($v), array('gif','jpg','jpeg','bmp','png'))); exit('0');//循环判断如果有一个不符合,直接返回 0 
         } 
      }

PHPCMS V9.6.2 SQL注入漏洞

  1. phpcms/libs/classes/param.class.php 位置约109行

原来代码

$value = isset($_COOKIE[$var]) ? sys_auth($_COOKIE[$var], 'DECODE') : $default;

替换为

$value = isset($_COOKIE[$var])?addslashes(sys_auth($_COOKIE[$var],'DECODE')):$default;

(2)/phpsso_server/phpcms/libs/classes/param.class.php 位置约108行

原来代码

return isset($_COOKIE[$var]) ? sys_auth($_COOKIE[$var], 'DECODE') : $default;

替换为

return isset($_COOKIE[$var]) ? addslashes(sys_auth($_COOKIE[$var],'DECODE')) : $default;

phpcms authkey生成算法问题导致authkey泄露

在/caches/configs/system.php,增加第一个参数: 'alivulfix' => 'yes',
caches/configs/system.php 找到并修改auth_key,20位字符串;具体写什么,自定义即可;找到并修改phpsso_auth_key,32位字符串,具体写什么,自定义即可;
phpsso/caches/configs/system.php找到并修改phpsso_auth_key,32位字符串;具体写什么与以上auth_key相同。

PHPCMS v9.6.3存在文件包含漏洞的修复方法

phpcms\libs\classes\param.class.php
phpsso_server\phpcms\libs\classes\param.class.php

源代码:

public static function get_cookie($var, $default = '') {
    $var = pc_base::load_config('system','cookie_pre').$var;
    $value = isset($_COOKIE[$var]) ? sys_auth($_COOKIE[$var], 'DECODE', md5(PC_PATH.'cookie'.$var).pc_base::load_config('system','auth_key')) : $default;
    if(in_array($var,array('_userid','userid','siteid','_groupid','_roleid'))) {
        $value = intval($value);
    } elseif(in_array($var,array('_username','username','_nickname','admin_username','sys_lang'))) { // site_model auth
        $value = safe_replace($value);
    }
    return $value;
}

修改后的代码:

public static function get_cookie($var, $default = '') {
    $var_base = $var;
    $var = pc_base::load_config('system','cookie_pre').$var;
    $value = isset($_COOKIE[$var]) ? sys_auth($_COOKIE[$var], 'DECODE', md5(PC_PATH.'cookie'.$var).pc_base::load_config('system','auth_key')) : $default;
    if(in_array($var_base,array('_userid','userid','siteid','_groupid','_roleid'))) {
        $value = intval($value);
    } elseif(in_array($var_base,array('_username','username','_nickname','admin_username','sys_lang'))) { // site_model auth
       $value = safe_replace($value);
    }
    return $value;
}

GET SHELL block

phpcms/modules/block/block_admin.php

$template = isset($_POST['template']) && trim($_POST['template']) ? trim($_POST['template']) : '';

改为

$template = isset($_POST['template']) && trim($_POST['template']) ? trim(safe_replace($_POST['template'])) : '';

两处

GET SHELL 2

phpcms/libs/functions/global.func.php 283行

@eval("\$array = $data;");

改为:

$data=safe_replace($data);
@eval("\$array = \"$data\";");

GET SHELL member

phpcms/modules/member/member_model.php,约47行

$model_import = @file_get_contents($_FILES['model_import']['tmp_name']);

改为

$model_import = safe_replace(@file_get_contents($_FILES[‘model_import’][‘tmp_name’]));

作者
分类 网站建设

评论

本文评论功能已关闭。

← 较早的 较新的 →

相关文章