根据你描述的情况,网站文件被植入暗链的可能性较大。以下是排查和解决方案:
**一、快速定位问题步骤**
1. 核心文件校验
使用Beyond Compare对比官方原版程序(建议下载对应版本),重点检查:
- /template/模板目录/*.htm(尤其是footer.htm/js_common.htm)
- /source/module/forum/*.php
- /data/cache/*.inc.php
- /api/目录下的异常文件
2. 暗链特征检测
在FTP中全站搜索以下关键词:
- grep -rnw ./ -e "eval(base64_decode"
- grep -rnw ./ -e "\.createElement('script')"
- grep -rnw ./ -e "gmail\.com" --include=*.js
复制代码
3. 数据库排查
执行SQL查询:
- SELECT * FROM pre_common_plugin WHERE identifier LIKE '%temp%';
- SELECT * FROM pre_common_setting WHERE skey='statcodes';
复制代码
**二、常见注入点分析**
1. 模板劫持漏洞
检查模板文件是否包含类似结构:
- <!--正常代码-->
- <script>
- var _0xadf2=['\x67\x6d\x61\x69\x6c'];(function(_0x582786,_0xadf2f4){/*混淆代码*/})(window,document);
- </script>
复制代码
2. 伪正常插件
通过phpMyAdmin检查插件表是否有如下特征:
- 插件目录名含特殊字符(如plugin_xx_)
- 插件模块包含curl_exec、file_put_contents等危险函数
3. 新型注入手法
近期发现攻击者会篡改用户组权限文件:
检查/source/class/table/table_common_member.php
是否有异常base64编码内容
**三、专业解决方案**
1. 紧急处理
- # 清除可疑计划任务
- find ./ -name "*.php" -mtime -3 -type f
- # 重置文件权限
- find . -type d -exec chmod 755 {} \;
- find . -type f -exec chmod 644 {} \;
- chmod 777 data/ data/cache/ data/avatar/ data/plugindata/
复制代码
2. 深度清理方案
① 创建文件指纹库:
- // genhash.php
- $excludes = ['attachment','data'];
- foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.')) as $f){
- if(!in_array(pathinfo($f,PATHINFO_DIRNAME),$excludes) && $f->isFile()){
- echo $f->getPathname().'|'.md5_file($f).PHP_EOL;
- }
- }
复制代码
② 对比官方指纹差异
3. 防御加固方案
在config/config_global.php追加:
- $_config['security']['querysafe']['status'] = 1;
- $_config['security']['querysafe']['dfunction'] = array('load_file','hex','substring','if','ord','char','benchmark','reverse','strcmp');
- $_config['security']['querysafe']['daction'] = array('@','intooutfile','intodumpfile','unionselect','(select');
- $_config['security']['querysafe']['dnote'] = array('0x','~','!','%','^','&','*','<','>','?','"','/');
复制代码
**四、后续监控**
1. 安装实时监控脚本
- // monitor.php
- $hashes = [];
- while(true){
- foreach(glob("*.php") as $f){
- $newhash = md5_file($f);
- if(isset($hashes[$f]) && $hashes[$f] != $newhash){
- mail('admin@yoursite.com','文件篡改警报',$f);
- }
- $hashes[$f] = $newhash;
- }
- sleep(300);
- }
复制代码
2. 建议启用WAF规则:
- location ~* (eval\(|base64_decode) {
- deny all;
- }
复制代码
该问题通常由模板文件被篡改或存在后门插件导致,重点排查最近三个月内修改过的模板文件。清理后建议重置所有管理员密码,并检查UC_KEY是否泄露。如需要进一步分析,可提供FTP中template/default/common/目录的压缩包以供深度检测。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。 |