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('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文件替换函数(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 中已经被弃用了 }
以上就是修复整理ecshop漏洞的详细内容。