搜尋
首頁CMS教程ECShop修復整理ecshop漏洞

修復整理ecshop漏洞

1、ECShop存在一个盲注漏洞,问题存在于/api/client/api.php文件中,提交特制的恶意POST请求可进行SQL注入攻击,可获得敏感信息或操作数据库。
路径:/api/client/includes/lib_api.php
参照以下修改:

推荐(免费):eschop

function API_UserLogin($post)
{
    /* SQL注入过滤 */
    if (get_magic_quotes_gpc()) 
    {     
        $post['UserId'] = $post['UserId'];
    } 
    else 
    {     
        $post['UserId'] = addslashes($post['UserId']);     
    }
    /* end */
    $post['username'] = isset($post['UserId']) ? trim($post['UserId']) : '';

2、ecshop的后台编辑文件/admin/shopinfo.php中,对输入参数id未进行正确类型转义,导致整型注入的发生。
路径: /admin/shopinfo.php
参照以下修改(53-71-105-123行):

源代码:
admin_priv('shopinfo_manage');
改为:
admin_priv('shopinfo_manage');
$_REQUEST['id'] = intval($_REQUEST['id']);

3、文件/admin/affiliate_ck.php中,对输入参数auid未进行正确类型转义,导致整型注入的发生。
参照以下修改(31行和51行):

源代码:
$logdb = get_affiliate_ck();
改成:
$_GET['auid'] = intval($_GET['auid']);
$logdb = get_affiliate_ck();

注:好像按上面改了阿里云还是会提示这个漏洞,然后我在文件顶部处添加以下代码就可以了:

$_GET['auid'] = intval($_GET['auid']);

4、ecshop的/admin/comment_manage.php中,对输入参数sort_by、sort_order未进行严格过滤,导致SQL注入。
参照以下修改:

$filter['sort_by']      = empty($_REQUEST['sort_by']) ? 'add_time' : trim(htmlspecialchars($_REQUEST['sort_by']));  
$filter['sort_order']   = empty($_REQUEST['sort_order']) ? 'DESC' : trim(htmlspecialchars($_REQUEST['sort_order']));

5、ecshop没有对会员注册处的username过滤,保存重的用户信息时,可以直接写入shell。
路径:/admin/integrate.php
大概109行,参照以下修改:

$code = empty($_GET['code']) ? '' : trim(addslashes($_GET['code']));

大概601行,参照以下修改:

源代码:
@file_put_contents(ROOT_PATH . 'data/repeat_user.php', $json->encode($repeat_user));
修改成:
@file_put_contents(ROOT_PATH.'data/repeat_user.php','<?php  die();?>'.$json->encode($repeat_user));

注:好像按上面改了阿里云还是会提示这个漏洞,然后我在文件顶部处添加以下代码就可以了:

$_GET['code'] = empty($_GET['code']) ? '' : trim(addslashes($_GET['code']));

6、ecshop后台模版编译导致黑客可插入任意恶意代码。
路径:/admin/edit_languages.php
大概在第120行

$dst_items[$i] = $_POST['item_id'][$i] .' = '. '"' .$_POST['item_content'][$i]. '";';

修改为

$dst_items[$i] = $_POST['item_id'][$i] .' = '. '\'' .$_POST['item_content'][$i]. '\';';

7、ecshop过滤不严导致SQL注入漏洞。
路径:/category.php 、 /ecsapi/category.php
修改方法:https://www.cnblogs.com/LittleHann/p/4524161.html

8、ecshop的/includes/lib_insert.php文件中,对输入参数未进行正确类型转义,导致整型注入的发生。
$arr['num'] 、$arr['id']、$arr['type']这些参数的,在函数开头加上:

大概289行加上:
$arr['num'] = intval($arr['num']);
$arr['id'] = intval($arr['id']);
大概454行加上:
$arr['id'] = intval($arr['id']);
$arr['type'] = addslashes($arr['type']);
大概495行加上:
$arr['id'] = intval($arr['id']);

9、ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/modules/payment/alipay.php文件中,该文件是ECshop的支付宝插件。由于ECShop使用了str_replace函数做字符串替换,黑客可绕过单引号限制构造SQL注入语句。只要开启支付宝支付插件就能利用该漏洞获取网站数据,且不需要注册登入。

搜索代码:

$order_sn = str_replace($_GET['subject'], '', $_GET['out_trade_no']);

将下面一句改为:

$order_sn = trim(addslashes($order_sn));

Ecshop后台模版编辑漏洞
详情描述参考:https://www.cnblogs.com/LittleHann/p/4272255.html

漏洞文件:/admin/mail_template.php 和 /includes/cls_template.php
/admin/mail_template.php文件添加以下代码(过滤了部分php关键词)

/*------------------------------------------------------ */
//-- 保存模板内容
/*------------------------------------------------------ */

elseif ($_REQUEST['act'] == 'save_template')
{ 
    if (empty($_POST['subject']))
    {
       sys_msg($_LANG['subject_empty'], 1, array(), false);
    }
    else
    {
        $subject = trim($_POST['subject']);
    }

    if (empty($_POST['content']))
    {
       sys_msg($_LANG['content_empty'], 1, array(), false);
    }
    else
    {
        $content = trim($_POST['content']);
    }

    $type   = intval($_POST['is_html']);
    $tpl_id = intval($_POST['tpl']);

    /*过滤了部分php关键词*/    
    $temp_check = preg_replace("/([^a-zA-Z0-9_]{1,1})+(extract|parse_str|str_replace|unserialize|ob_start|require|include|array_map|preg_replace|copy|fputs|fopen|file_put_contents|file_get_contents|fwrite|eval|phpinfo|assert|base64_decode|create_function|call_user_func)+( |\()/is", "", $content);
    $temp_check = preg_replace("/){0,1}|){0,1}|){0,1}|<script>]+language[^>]*=[^>]*php[^>]*>[^><]*(<\/script\s*>){0,1}/iU", "", $temp_check); 
    $content = $temp_check;
    /*过滤了部分php关键词*/

    $sql = "UPDATE " .$ecs->table(&#39;mail_templates&#39;). " SET ".
                "template_subject = &#39;" .str_replace(&#39;\\\&#39;\\\&#39;&#39;, &#39;\\\&#39;&#39;, $subject). "&#39;, ".
                "template_content = &#39;" .str_replace(&#39;\\\&#39;\\\&#39;&#39;, &#39;\\\&#39;&#39;, $content).  "&#39;, ".
                "is_html = &#39;$type&#39;, ".
                "last_modify = &#39;" .gmtime(). "&#39; ".
            "WHERE template_id=&#39;$tpl_id&#39;";

    if ($db->query($sql, "SILENT"))
    {
        $link[0]=array(&#39;href&#39; => &#39;mail_template.php?act=list&#39;, &#39;text&#39; => $_LANG[&#39;update_success&#39;]);
        sys_msg($_LANG[&#39;update_success&#39;], 0, $link);
    }
    else
    {
         sys_msg($_LANG[&#39;update_failed&#39;], 1, array(), false);
    }
}</script>

/includes/cls_template.php文件替换函数(fetch_str()):

function fetch_str($source)
    { 
        if (!defined('ECS_ADMIN'))
        {
            $source = $this->smarty_prefilter_preCompile($source);
        }
        $source=preg_replace("/([^a-zA-Z0-9_]{1,1})+(copy|fputs|fopen|file_put_contents|fwrite|eval|phpinfo)+( |\()/is", "", $source);
        $source=preg_replace("/||<script>]+language[^>]*=[^>]*php[^>]*>[^><]*<\/script\s*>/iU", "", $source);
        return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select(&#39;\\1&#39;);", $source);
        //return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);//修饰符 /e 在 PHP5.5.x 中已经被弃用了
    }</script>

               

以上是修復整理ecshop漏洞的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:CSDN。如有侵權,請聯絡admin@php.cn刪除

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。