阿里云ECS phpcms v9 各种注入漏洞补丁

最新福利:领取阿里云1000通用代金券

用阿里云ECS服务器,上传了用phpcms v9做的项目,没想到还能帮我查漏洞,于是各种百度,下面记录下百度到的答案。

 

1、宽字节注入漏洞

/phpcms/modules/pay/respond.php 位置约16行

原来代码

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

 

替换为

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

 

 

2、phpcms注入漏洞

/phpcms/modules/poster/poster.php 位置约221行

if ($_GET['group']) {

 

 

之后加上

 

 

$_GET['group'] = preg_replace('#`#', '', $_GET['group']);

 

3、phpcms前台注入导致任意文件读取漏洞补丁

/phpcms/modules/content/down.php

(1)位置约17行

parse_str($a_k);

 

替换为

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

 

(2)位置约89行

parse_str($a_k);

 

替换为

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

 

(3)位置约120行

$filename = date('Ymd_his').random(3).'.'.$ext;

 

之后加上

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

 

 

4、phpcms注入漏洞 

/phpcms/modules/member/index.php 位置约615行

原来代码:

 

 

$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);

 

5、phpcms某处逻辑问题导致getshell

1.根据漏洞描述,找到对应文件attachment.class.php的对应位置(第144行附近),并添加补丁代码。

//补丁代码如下
if($ext !== 'gif|jpg|jpeg|bmp|png'){
    if(!in_array(strtoupper($ext),array('JPG','GIF','BMP','PNG','JPEG'))) exit('附加扩展名必须为gif、jpg、jpeg、bmp、png');
}

添加后的代码,截图如下:

 

这样,加入一个判断,如果允许的文件格式是'gif','jpg','jpeg','bmp','png'这些,就继续,不然就跳出,当然这里的格式可以根据需要增多几个。

6、phpcms注入漏洞

/api/phpsso.php 位置约128行

原来代码

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

替换为,二合一代码

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

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

/caches/configs/system.php,增加第一个参数:

'alivulfix' => 'yes',

照着下面的函数重新生成一下key值,然后找caches/configs/system.php 里面把两个参数替换一下就ok了

<?php 
     function random($length, $chars = '0123456789') { 
       
        $hash = ''; 
        $max = strlen($chars) - 1; 
        for($i = 0; $i < $length; $i++) { 
            $hash .= $chars[mt_rand(0, $max)]; 
        } 
        return $hash; 
    }
    
    echo random(20, 'authkey').'<br/>';    
    echo random(32, 'phpssoauthkey');exit; 

?>

猜你喜欢

转载自blog.csdn.net/shanzhihang/article/details/81870023