今天看了下一个频道的页面,发现有 js 什么的冲突代码

最近用排除方法 是底部 <script
src=”http://discuz.gtimg.cn/cloud/scripts/discuz_tips.js?v=1″
type=”text/javascript” charset=”UTF-8″></script>

这代码引起的,既然在底部那就很好找,找到模版 footer.htm   里面是用 <!–{eval output();}–> 调用的

之前没有这代码的,打了 0339 补丁就有了,那就去 0339 补丁里搜索这代码

在 source/function/function_cloud.php 里有这么一句赤裸裸的代码,为什么我叫他赤裸裸

一 因为这 gtimg.cn 跟官方,压跟没有联系

二 这 js 代码还会影响我们 js 的效果

三 下载这个 js 还使用一个 eval(function(p,a,c,k,e,d) 加密

———————————————————————————————–

解密后得到的代码

  1. var clearTips;
  2. DiscuzCloudNameSpace = new Object();
  3. DiscuzCloudNameSpace.register = function(fullName) {
  4.     try {
  5.         var nsArray = fullName.split(“.”);
  6.         var strNS = “”;
  7.         var strEval = “”;
  8.         for (var i = 0; i < nsArray.length; i++) {
  9.             if (strNS.length > 0) strNS += “.”;
  10.             strNS += nsArray[i];
  11.             strEval += ” if (typeof(” + strNS + “) ==’undefined’) ” + strNS + ” = new Object(); “
  12.         };
  13.         if (strEval != “”) eval(strEval)
  14.     } catch(e) {
  15.         alert(e.message)
  16.     }
  17. };
  18. DiscuzCloudNameSpace.register(‘DiscuzCloud’);
  19. DiscuzCloud.JSONP = (function() {
  20.     var counter = 0,
  21.     head, query, key, window = this;
  22.     function load(url) {
  23.         script = document.createElement(‘script’),
  24.         done = false;
  25.         script.src = url;
  26.         script.charset = ‘UTF-8’;
  27.         script.async = true;
  28.         script.onload = script.onreadystatechange = function() {
  29.             if (!done && (!this.readyState || this.readyState === “loaded” || this.readyState === “complete”)) {
  30.                 done = true;
  31.                 script.onload = script.onreadystatechange = null;
  32.                 if (script && script.parentNode) {
  33.                     script.parentNode.removeChild(script)
  34.                 }
  35.             }
  36.         };
  37.         if (!head) {
  38.             head = document.getElementsByTagName(‘head’)[0]
  39.         };
  40.         head.appendChild(script)
  41.     };
  42.     function jsonp(url, params, callback) {
  43.         if (url.indexOf(‘?’) > -1) {
  44.             query = ‘&’
  45.         } else {
  46.             query = ‘?’
  47.         };
  48.         params = params || {};
  49.         for (key in params) {
  50.             if (params.hasOwnProperty(key)) {
  51.                 query += encodeURIComponent(key) + “=” + encodeURIComponent(params[key]) + “&”
  52.             }
  53.         };
  54.         var jsonp = ‘discuzTipsCallback’;
  55.         window[jsonp] = function(data) {
  56.             callback(data);
  57.             try {
  58.                 delete window[jsonp]
  59.             } catch(e) {}
  60.             window[jsonp] = null
  61.         };
  62.         load(url + query + “callback=” + jsonp);
  63.         return jsonp
  64.     };
  65.     return {
  66.         get: jsonp
  67.     }
  68. } ());
  69. DiscuzCloud.htmlspecialchars = function(string, quote_style, charset, double_encode) {
  70.     var optTemp = 0,
  71.     i = 0,
  72.     noquotes = false;
  73.     if (typeof quote_style === ‘undefined’ || quote_style === null) {
  74.         quote_style = 2
  75.     };
  76.     string = string.toString();
  77.     if (double_encode !== false) {
  78.         string = string.replace(/&/g, ‘&amp;’)
  79.     };
  80.     string = string.replace(/</g, ‘&lt;’).replace(/>/g, ‘&gt;’);
  81.     var OPTS = {
  82.         ‘ENT_NOQUOTES’: 0,
  83.         ‘ENT_HTML_QUOTE_SINGLE’: 1,
  84.         ‘ENT_HTML_QUOTE_DOUBLE’: 2,
  85.         ‘ENT_COMPAT’: 2,
  86.         ‘ENT_QUOTES’: 3,
  87.         ‘ENT_IGNORE’: 4
  88.     };
  89.     if (quote_style === 0) {
  90.         noquotes = true
  91.     };
  92.     if (typeof quote_style !== ‘number’) {
  93.         quote_style = [].concat(quote_style);
  94.         for (i = 0; i < quote_style.length; i++) {
  95.             if (OPTS[quote_style[i]] === 0) {
  96.                 noquotes = true
  97.             } else if (OPTS[quote_style[i]]) {
  98.                 optTemp = optTemp | OPTS[quote_style[i]]
  99.             }
  100.         };
  101.         quote_style = optTemp
  102.     };
  103.     if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
  104.         string = string.replace(/’/g, ”’)
  105.     };
  106.     if (!noquotes) {
  107.         string = string.replace(/”/g, ‘&quot;’)
  108.     };
  109.     return string
  110. };
  111. DiscuzCloud.setCookie = function(name, value, sec) {
  112.     if (typeof(sec) == ‘undefined’) {
  113.         sec = 86400000;
  114.     } else {
  115.         sec = sec * 1000
  116.     };
  117.     var expires = new Date();
  118.     expires.setTime(expires.getTime() + sec);
  119.     document.cookie = name + ‘=’ + escape(value) + ‘; expires=’ + expires.toGMTString()
  120. };
  121. DiscuzCloud.getCookie = function(name) {
  122.     var cookie_start = document.cookie.indexOf(name);
  123.     var cookie_end = document.cookie.indexOf(‘;’, cookie_start);
  124.     return cookie_start == -1 ? ”:
    unescape(document.cookie.substring(cookie_start + name.length + 1,
    (cookie_end > cookie_start ? cookie_end: document.cookie.length)))
  125. };
  126. DiscuzCloud.$ = function(id) {
  127.     return document.getElementById(id)
  128. };
  129. DiscuzCloud.Tips = function(sId, version, release, api, founder, fix, sUrl, sCharset, ts, sig, adminId, groupId, uid, openId) {
  130.     this.sId = sId;
  131.     this.sUrl = sUrl;
  132.     this.version = version;
  133.     this.release = release;
  134.     this.api = api;
  135.     this.founder = founder;
  136.     this.fix = fix;
  137.     this.clientWidth = document.documentElement.clientWidth;
  138.     this.clientHeight = document.documentElement.clientHeight;
  139.     this.discuzTips = DiscuzCloud.$(‘discuz_tips’);
  140.     newDate = new Date();
  141.     this.url = ‘http://cp.discuz.qq.com/tips/get?rand=’ + newDate.getDate() + newDate.getHours();
  142.     this.secret = ”;
  143.     this.tipsId = ”;
  144.     this.cacheKey = ”;
  145.     this.sendTime = ”;
  146.     this.sCharset = sCharset;
  147.     if (typeof(document.characterSet) == ‘undefined’) {
  148.         this.browserCharset = document.charset
  149.     } else {
  150.         this.browserCharset = document.characterSet
  151.     };
  152.     if (discuzTipsCVersion == ‘2’) {
  153.         this.adminId = adminId;
  154.         this.groupId = groupId;
  155.         this.uid = uid;
  156.         this.openId = openId
  157.     };
  158.     this.ts = ts;
  159.     this.sig = sig
  160. };
  161. DiscuzCloud.Tips.prototype.show = function() {
  162.     if (discuzTipsCVersion == ‘2’ && this.adminId != 1) {
  163.         return false
  164.     };
  165.     if (this.checkManyou()) {
  166.         return false
  167.     };
  168.     var callback = function(data) {
  169.         if (typeof(data.errorCode) != ‘undefined’ && data.errorCode != 0) {
  170.             return false
  171.         };
  172.         if (typeof(data.css) != ‘undefined’ && data.css) {
  173.             tips.css(data.css)
  174.         };
  175.         if (typeof(data.secret) != ‘undefined’ && data.secret) {
  176.             tips.secret = data.secret
  177.         };
  178.         if (typeof(data.tipsId) != ‘undefined’ && data.tipsId) {
  179.             tips.tipsId = data.tipsId
  180.         };
  181.         if (typeof(data.tscKey) != ‘undefined’ && data.tscKey) {
  182.             tips.tscKey = data.tscKey
  183.         };
  184.         if (typeof(data.html) != ‘undefined’) {
  185.             tips.discuzTips.innerHTML = tips.analysis(data.html)
  186.         };
  187.         if (typeof(data.beforeJS) != ‘undefined’ && data.beforeJS) {
  188.             eval(data.beforeJS)
  189.         };
  190.         if (typeof(data.afterJS) != ‘undefined’ && data.afterJS) {
  191.             eval(data.afterJS)
  192.         };
  193.         if (typeof(data.sendTime) != ‘undefined’ && data.sendTime) {
  194.             tips.sendTime = data.sendTime
  195.         };
  196.         if (typeof(data.viewPermission) != ‘undefined’ && data.viewPermission) {
  197.             tips.viewPermission = data.viewPermission
  198.         };
  199.         tips.open();
  200.         if (typeof(data.keepTime) != ‘undefined’ && data.keepTime > 0) {
  201.             clearTips = setTimeout(function() {
  202.                 tips.close(data.tipsId, data.tscKey, data.viewPermission, true)
  203.             },
  204.             data.keepTime * 1000)
  205.         }
  206.     };
  207.     var cookie = DiscuzCloud.getCookie(‘dctips’);
  208.     if (discuzTipsCVersion == ‘2’) {
  209.         var params = {
  210.             ‘s_id’: this.sId,
  211.             ‘product_version’: this.version,
  212.             ‘product_release’: this.release,
  213.             ‘fix_bug’: this.fix,
  214.             ‘is_founder’: this.founder,
  215.             ‘s_url’: this.sUrl,
  216.             ‘last_send_time’: cookie,
  217.             ‘ts’: this.ts,
  218.             ‘sig’: this.sig,
  219.             ‘admin_id’: this.adminId,
  220.             ‘group_id’: this.groupId,
  221.             ‘open_id’: this.openId,
  222.             ‘uid’: this.uid
  223.         }
  224.     } else {
  225.         var params = {
  226.             ‘s_id’: this.sId,
  227.             ‘product_version’: this.version,
  228.             ‘product_release’: this.release,
  229.             ‘fix_bug’: this.fix,
  230.             ‘is_founder’: this.founder,
  231.             ‘s_url’: this.sUrl,
  232.             ‘last_send_time’: cookie,
  233.             ‘ts’: this.ts,
  234.             ‘sig’: this.sig
  235.         }
  236.     };
  237.     DiscuzCloud.JSONP.get(this.url, params, callback)
  238. };
  239. DiscuzCloud.Tips.prototype.css = function(url) {
  240.     try {
  241.         document.createStyleSheet(url)
  242.     } catch(e) {
  243.         var cssLink = document.createElement(‘link’);
  244.         cssLink.rel = ‘stylesheet’;
  245.         cssLink.type = ‘text/css’;
  246.         cssLink.href = url;
  247.         var head = document.getElementsByTagName(‘head’)[0];
  248.         head.appendChild(cssLink)
  249.     }
  250. };
  251. DiscuzCloud.Tips.prototype.checkManyou = function() {
  252.     if (DiscuzCloud.$(‘my_notify_wrap’)) {
  253.         return true
  254.     };
  255.     return false
  256. };
  257. DiscuzCloud.Tips.prototype.markAsRead = function(taskId, cacheKey, viewPermission) {
  258.     var newDate = new Date();
  259.     var time = Math.floor(newDate.getTime() / 1000);
  260.     var sig = this.encode(taskId, this.secret);
  261.     DiscuzCloud.setCookie(‘dctips’, this.sendTime, 86400 * 30);
  262.     var url = ‘http://cp.discuz.qq.com/tips/mark?rand=’ + Math.random();
  263.     var callback = function() {};
  264.     var params = {
  265.         ‘id’: taskId,
  266.         ‘key’: cacheKey,
  267.         ‘is_founder’: this.founder,
  268.         ‘view_permission’: viewPermission,
  269.         ‘sig’: sig
  270.     };
  271.     DiscuzCloud.JSONP.get(url, params, callback)
  272. };
  273. DiscuzCloud.Tips.prototype.encode = function(id, key) {
  274.     var num = id % 8;
  275.     if (num == 0) {
  276.         num = 8
  277.     };
  278.     return key.substr(num) + key.substr(0, num)
  279. };
  280. DiscuzCloud.Tips.prototype.open = function() {
  281.     this.discuzTips.style.display = ”;
  282. };
  283. DiscuzCloud.Tips.prototype.close = function(taskId, cacheKey, viewPermission, passive) {
  284.     clearTimeout(clearTips);
  285.     this.discuzTips.style.display = ‘none’;
  286.     if (typeof(taskId) == ‘undefined’) {
  287.         taskId = 0
  288.     };
  289.     this.markAsRead(taskId, cacheKey, viewPermission);
  290.     if (typeof(passive) != ‘undefined’ && passive == true) {
  291.         this.stats(‘passiveClose’, taskId, cacheKey)
  292.     } else {
  293.         this.stats(‘close’, taskId, cacheKey)
  294.     }
  295. };
  296. DiscuzCloud.Tips.prototype.stats = function(action, taskId, cacheKey) {
  297.     var statsUrl = ‘http://cp.discuz.qq.com/tips/stats?rand=’ + Math.random();
  298.     var sig = this.encode(taskId, this.secret);
  299.     var params = {
  300.         ‘action’: action,
  301.         ‘tt_id’: taskId,
  302.         ‘sig’: sig,
  303.         ‘cache_key’: cacheKey
  304.     };
  305.     var callback = function() {};
  306.     DiscuzCloud.JSONP.get(statsUrl, params, callback)
  307. };
  308. DiscuzCloud.Tips.prototype.analysis = function(html) {
  309.     tipsId = parseInt(this.tipsId);
  310.     sId = parseInt(this.sId);
  311.     sUrl = DiscuzCloud.htmlspecialchars(this.sUrl);
  312.     sVersion = DiscuzCloud.htmlspecialchars(this.version);
  313.     sCharset = DiscuzCloud.htmlspecialchars(this.sCharset);
  314.     tempUrl = this.sUrl.split(‘//’);
  315.     tempUrl = tempUrl[1].split(‘/’);
  316.     sDomain = DiscuzCloud.htmlspecialchars(tempUrl[0]);
  317.     tempUrl = tempUrl[0].split(‘.’);
  318.     tempUrl.shift();
  319.     sMasterDomain = DiscuzCloud.htmlspecialchars(tempUrl.join(‘.’));
  320.     html = html.replace(/#TipsID#/, tipsId);
  321.     html = html.replace(/#SId#/, sId);
  322.     html = html.replace(/#SiteUrl#/, sUrl);
  323.     html = html.replace(/#SiteVersion#/, sVersion);
  324.     html = html.replace(/#SiteCharset#/, sCharset);
  325.     html = html.replace(/#SiteDomain#/, sDomain);
  326.     html = html.replace(/#SiteMasterDomain#/, sMasterDomain);
  327.     return html
  328. };
  329. window.onload = function(e) {
  330.     if (typeof(discuzTipsCVersion) == ‘undefined’) {
  331.         discuzTipsCVersion = ‘0’
  332.     };
  333.     if (discuzTipsCVersion == ‘2’) {
  334.         tips = new DiscuzCloud.Tips(discuzSId, discuzVersion,
    discuzRelease, discuzApi, discuzIsFounder, discuzFixbug, SITEURL,
    charset, ts, sig, discuzAdminId, discuzGroupId, discuzUid, discuzOpenId)
  335.     } else {
  336.         tips = new DiscuzCloud.Tips(discuzSId, discuzVersion,
    discuzRelease, discuzApi, discuzIsFounder, discuzFixbug, SITEURL,
    charset, ts, sig)
  337.     };
  338.     tips.show()
  339. }

最后提醒大家:去掉了,你就收不到 Discuz! 的安全通知了,也收不到 Discuz! 的补丁通知了,还收不到防水墙的过滤通知了。