怎么修復(fù)ecshop漏洞

這篇文章主要介紹了怎么修復(fù)ecshop漏洞,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創(chuàng)新互聯(lián)于2013年開(kāi)始,是專(zhuān)業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元海港做網(wǎng)站,已為上家服務(wù),為海港各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:028-86922220

1、ECShop存在一個(gè)盲注漏洞,問(wèn)題存在于/api/client/api.php文件中,提交特制的惡意POST請(qǐng)求可進(jìn)行SQL注入攻擊,可獲得敏感信息或操作數(shù)據(jù)庫(kù)。
路徑:/api/client/includes/lib_api.php
參照以下修改:

推薦(免費(fèi)):eschop

function API_UserLogin($post)
{
    /* SQL注入過(guò)濾 */
    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的后臺(tái)編輯文件/admin/shopinfo.php中,對(duì)輸入?yún)?shù)id未進(jìn)行正確類(lèi)型轉(zhuǎn)義,導(dǎo)致整型注入的發(fā)生。
路徑: /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中,對(duì)輸入?yún)?shù)auid未進(jìn)行正確類(lèi)型轉(zhuǎn)義,導(dǎo)致整型注入的發(fā)生。
參照以下修改(31行和51行):

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

注:好像按上面改了阿里云還是會(huì)提示這個(gè)漏洞,然后我在文件頂部處添加以下代碼就可以了:

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

4、ecshop的/admin/comment_manage.php中,對(duì)輸入?yún)?shù)sort_by、sort_order未進(jìn)行嚴(yán)格過(guò)濾,導(dǎo)致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沒(méi)有對(duì)會(huì)員注冊(cè)處的username過(guò)濾,保存重的用戶(hù)信息時(shí),可以直接寫(xiě)入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));

注:好像按上面改了阿里云還是會(huì)提示這個(gè)漏洞,然后我在文件頂部處添加以下代碼就可以了:

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

6、ecshop后臺(tái)模版編譯導(dǎo)致黑客可插入任意惡意代碼。
路徑:/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過(guò)濾不嚴(yán)導(dǎo)致SQL注入漏洞。
路徑:/category.php 、 /ecsapi/category.php
修改方法:https://www.cnblogs.com/LittleHann/p/4524161.html

8、ecshop的/includes/lib_insert.php文件中,對(duì)輸入?yún)?shù)未進(jìn)行正確類(lèi)型轉(zhuǎn)義,導(dǎo)致整型注入的發(fā)生。
$arr['num'] 、$arr['id']、$arr['type']這些參數(shù)的,在函數(shù)開(kāi)頭加上:

大概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函數(shù)做字符串替換,黑客可繞過(guò)單引號(hào)限制構(gòu)造SQL注入語(yǔ)句。只要開(kāi)啟支付寶支付插件就能利用該漏洞獲取網(wǎng)站數(shù)據(jù),且不需要注冊(cè)登入。

搜索代碼:

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

將下面一句改為:

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

Ecshop后臺(tái)模版編輯漏洞
詳情描述參考:https://www.cnblogs.com/LittleHann/p/4272255.html

漏洞文件:/admin/mail_template.php 和 /includes/cls_template.php
/admin/mail_template.php文件添加以下代碼(過(guò)濾了部分php關(guān)鍵詞)

/*------------------------------------------------------ */
//-- 保存模板內(nèi)容
/*------------------------------------------------------ */

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']);

    /*過(guò)濾了部分php關(guān)鍵詞*/    
    $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;
    /*過(guò)濾了部分php關(guān)鍵詞*/

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

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

/includes/cls_template.php文件替換函數(shù)(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('\\1');", $source);
        //return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);//修飾符 /e 在 PHP5.5.x 中已經(jīng)被棄用了
    }

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“怎么修復(fù)ecshop漏洞”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!

標(biāo)題名稱(chēng):怎么修復(fù)ecshop漏洞
URL網(wǎng)址:http://bm7419.com/article2/pcciic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)站排名、網(wǎng)站設(shè)計(jì)公司關(guān)鍵詞優(yōu)化、企業(yè)建站、手機(jī)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

綿陽(yáng)服務(wù)器托管