- 浏览: 13554 次
最新评论
关于联通(网通)DNS劫持广告的屏蔽办法.
- 博客分类:
- 技术杂绘
关于联通(网通)DNS劫持广告的屏蔽办法.
2010年07月27日
最近接到投诉,说我的网站老弹出广告,而且是死对头家的广告. 经过仔细研究,终于发现了猫腻.
关于dns劫持我说明一下,过程是这样的, 首先用户发送请求到你的网站服务器,网站服务器响应请求,响应结果需要返回给用户,
在这个时候,dns服务器就开始搞鬼了,不定期植入一些你网页代码中包含的关键字的广告,这就是为什么我页面中会弹出对家的广告的原因了.
因为我们做的都是相同的服务产品.
下面是联通植入到我网站页面内的js代码: /* $Rev: 145 $ $Date: 2010-04-29 14:20:48 -0700 (Thu, 29 Apr 2010) $ */ (function() { try { var d = document, h = window, x, z = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion), p = ((d.all) && (!z)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]), A = (!p ? 1024: (d.documentMode ? d.documentMode: (d.compatMode && d.compatMode === "CSS1Compat" ? p: (d.compatMode && d.compatMode !== "CSS1Compat" ? 5: p)))), t = 300, k = 2147483647, g = "", l = '', s = "html{color:#000;}body,div,h1,h2,h3,h4 ,h5,h6,p{margin:0;padding:0;}img{border:0;}em,stron g,var{font-style:normal;font-weight:normal;}h1,h2,h 3,h4,h5,h6{font-size:100%;font-weight:normal;}sup{v ertical-align:text-top;}sub{vertical-align:text-bot tom;}body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small; *font:x-small;}"; if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(D, C) { C = C || 0; var e = this.length, B; if (C document.domain) { D.src = E.protocol + "//" + E.host } function B() { if (B.gone) { return } B.gone = true; clearInterval(e); D.onload = null; D.onreadystatechange = null; C(D.contentWindow) } for (H in I) { if (I.hasOwnProperty(H)) { D.setAttribute(H, I[H]) } } if (A === 7 && I.height === "100%") { F.attachEvent("onresize", function() { D.style.height = F.offsetHeight + "px" }) } if (C) { D.onload = B; D.onreadystatechange = function() { if (D.readyState === "complete") { B() } }; if (!p) { e = setInterval(function() { if (D.contentWindow) { B() } }, 200) } } F.appendChild(D); return D } function r() { if (r.settings) { return r.settings } var D = "/floating-frame.", e = d.getElementsByTagName("script"), C, B; for (C = 0; C B.fp.stopTime || !B.fp.sendAccounting) { return null } for (e = 0; e 6) { L = B.style; L.position = "relative"; L.zIndex = k - 1; while (L.zIndex != k - 1 && G > 0) { k = Math.pow(2, --G) - 1; L.zIndex = k - 1 } L.position = "static" } H = ["nw", "sw", "se", "ne"]; for (G = 0; G 6) { O.push("padding-" + D.close_align + ":" + N + "px") } else { if (D.top_align === "left") { O.push("left:" + (N + D.top_offset_left) + "px") } } } if (A = 6 ? d.documentElement: d.body, O, H, B, K, G, I = this; this.place = function() { E.style.top = J + (e ? L.clientHeight: 0) + L.scrollTop; if (P) { E.style.left = L.clientWidth / 2 + D } else { E.style.left = D + (N ? L.clientWidth: 0) + L.scrollLeft } if (F) { E.style.height = L.clientHeight + "px" } }; this.addListeners = function() { attachEvent("onscroll", this.place); attachEvent("onresize", O) }; this.removeListeners = function() { detachEvent("onscroll", this.place); detachEvent("onresize", O) }; this.init = function() { E.style.position = "absolute"; if (C.outer_width === -100) { M = M.charAt(0) + "w"; B = []; B.push(E); B.push(0); B.push(E.firstChild.contentWindow.document.getElem entsByTagName("iframe")[0]); B.push(C.border_left_width + C.border_right_width); K = E.firstChild.contentWindow.document.getElementsByT agName("div"); for (G = 0; G K ? 1: (O - B) / F, N; for (H = 0; H K) { clearInterval(C); D() } }, 13); return C } function n() { var e = r(); if (!e || !e.sprite_img) { return } n.ran = true; n.loaded = false; n.onload = null; if (!n.sprite) { n.sprite = new Image(); n.sprite.onload = function() { n.loaded = true; if (typeof n.onload === "function") { n.onload() } }; n.sprite.src = e.sprite_img } if (!e.delay_duration || e.delay_duration 6) { M.position = "fixed"; if (G.outer_height === -100) { M.top = M.bottom = G.vertical_offset + "px" } else { if (N.charAt(0) === "c") { M.top = "50%"; M.marginTop = ( - 1 * Math.floor(G.outer_height / 2)) + "px" } else { M[N.charAt(0) === "n" ? "top": "bottom"] = G.vertical_offset + "px" } } if (G.outer_width === -100) { M.right = M.left = G.horizontal_offset + "px" } else { if (N.charAt(1) === "c") { M.left = "50%"; M.marginLeft = ( - 1 * Math.floor(G.outer_width / 2)) + "px" } else { M[N.charAt(1) === "e" ? "right": "left"] = G.horizontal_offset + "px" } } } else { G.fixIE = L = new o(I, G); L.init(); L.addListeners() } for (B in M) { if (M.hasOwnProperty(B)) { I.style[B] = M[B] } } if (L) { L.place() } if (G.visible_duration > 0) { E = function() { setTimeout(function() { u(I, G) }, G.visible_duration * 1000) } } if (G.animate_in_duration || G.animate_out_duration) { D = I.firstChild; D.style.position = "relative"; for (K = 0; K F.fp.stopTime) { return } clearTimeout(e); if (!F.content_url && F.message_html) { H.document.write(g + l + F.message_html); H.document.close() } F.fp.accounting = F.fp.sendAccounting(1); q(B, F) } function E(K) { if (c() > F.fp.stopTime) { return } var J, N, I, M, H; try { M = K.document } catch(L) { return } M.write(g + "" + l + s + "html,body{margin:0;padding:0}"); M.close(); if (parseInt(p, 10) === 6) { try { M.execCommand("BackgroundImageCache", false, true) } catch(L) {} } N = m("div", M.body, null, { id: "fpid" }, M); H = m("div", N, null, { id: "iwrap" }, M); I = y(F, N, function() { u(B, F) }, M); j(I.join(""), M); C = { frameBorder: "0", scrolling: (F.allow_content_scroll ? "auto": "no") }; if (p && F.allow_content_transparency) { C.allowTransparency = !!F.allow_content_transparency } if (F.content_url) { C.src = F.content_url } C.height = "100%"; J = a(H, C, G, M); if (!F.allow_content_transparency) { J.style.backgroundColor = "#fff" } e = setTimeout(function() { try { J.src = "about:blank" } catch(O) {} try { H.removeChild(J) } catch(O) {} }, F.fp.stopTime - c()) } if (!n.ran) { n() } if (F === null || c() > F.fp.stopTime) { return } B = m("div", d.body, null, { style: "display:none" }); B.style.display = "none"; C = { scrolling: "no", width: F.outer_width === -100 ? "100%": F.outer_width, height: F.outer_height === -100 ? "100%": F.outer_height, frameBorder: 0, id: f() }; if (p) { C.allowTransparency = !F.opaque_outer_frame } j("@media print{#" + C.id + "{display:none}}"); D = a(B, C, E, d) }) } catch(w) {} })(); 内容是以上这些,得到的原始代码是压缩代码.现在大家看到的是解压以后的可以直观展现出来的代码.
其实上面这段代码不是直接植入网站页面的.
而是在你网页的head标签中植入一条js引用: .js?fp681 这个就是广告了, 根据后面的fp数字不同 得到的似乎是不同的广告.
反正我这里几次截取的.js?后面的内容都不一样.
下面说一下问题的解决过程:
一开始 想着 干掉js生成的iframe 但是后来考虑,要从根源抓起.
于是 动手解决head标签中植入的js引用.
发现一个重复点: 广告的域名根为 clicklifter.com
于是写了下面的方法, 放到了页面body标签的最后. -1) { sub = sub.substring(index + text.length, sub.length - 1); count++; index = sub.indexOf(text); } } catch (e) { } if (count > 1) window.location.reload(); // --> 经过测试 ok 轻松解决. 但是唯一的遗憾就是 偶尔访问页面的时候被植入广告了 页面会重新刷新一遍.
虽然能解决广告弹出 但是还是不够"优雅"
js代码的前2行是为了跳出iframe(防止别人使用iframe把你的页面嵌入进去)
剩下的就是判断页面中clicklifter.com的数量, 除了自己原始代码中有一个以外,如果dns服务器植入js的话就会超过1个.
所以在下面判断 如果统计超过了1个 就刷新本页面.
好了,说完了. 希望大家遇到同样问题了可以借鉴一下此方法. 还是比较有效的.
如果哪位大侠能有更好办法, 请分享一下.
发表评论
-
javascript知识汇总
2012-01-20 10:12 773javascript知识汇总 2010年 ... -
javascript全面总结(可能别人看的有点乱,不过多看几遍就习惯了,每个*是一个知识点集合)
2012-01-20 10:12 758javascript全面总结(可能别人看的有点乱,不过多看几遍 ... -
JavaScript方法和技巧大全[集合]
2012-01-20 10:12 635JavaScript方法和技巧大全 ... -
JS方法与技巧
2012-01-20 10:12 556JS方法与技巧 2010年08月 ... -
一名优秀的Flex开发者需要知道的10样东西
2012-01-19 15:13 576一名优秀的Flex开发者需要知道的10样东西 2011年05 ... -
Flex 86道题(好好学习一下)
2012-01-19 15:13 600Flex 86道题(好好学习一 ... -
Flex开发者需要知道的10件事
2012-01-19 15:13 683Flex开发者需要知道的10 ... -
Flex面试题及答案
2012-01-19 15:13 607Flex面试题及答案 2011年 ... -
2011-8-4
2012-01-19 15:13 10472011-8-4 2011年08月04日 ... -
J2ME编程之Nokia 7210配置篇
2012-01-17 05:00 681J2ME编程之Nokia 7210配置篇 2011年02月0 ... -
总体上说,是c++ builder胜于VC++,DELPHI是最好
2012-01-17 05:00 741总体上说,是c++ builder胜 ... -
FPS游戏透视源码!
2012-01-17 05:00 1537FPS游戏透视源码! 2011年10月03日 需要的自己 ... -
...
2012-01-16 03:51 659... 2010年12月04日 Flex、FB、FC学习 ... -
实例资源
2012-01-16 03:51 661实例资源 2009年08月29日 ... -
ActionScript3.0视频系列教程
2012-01-16 03:51 695ActionScript3.0视频系列教程 2010年05月 ... -
想开始整整SmartRcP Flex + Java 开发GUI程序
2012-01-16 03:51 617想开始整整SmartRcP Flex + Java 开发GUI ... -
Flash Builder 4 / Flash Catalyst 发布(转www.airia.cn)
2012-01-16 03:51 788Flash Builder 4 / Flash Catalys ...
相关推荐
全国各地电信、网通DNS查询包括港澳台.pdf
广东省江门市(中国电信) 首选DNS:202.96.128.86 备份DNS:202.96.128.166 广东省佛山市南海区(中国网通) 首选DNS:221.5.88.88 备份DNS:210.21.196.6 广西: 广西壮族自治区(中国电信) 首选DNS:202.103.224...
广东省江门市(中国电信) 首选DNS:202.96.128.86 备份DNS:202.96.128.166 广东省佛山市南海区(中国网通) 首选DNS:221.5.88.88 备份DNS:210.21.196.6 广西: 广西壮族自治区(中国电信) 首选DNS:202.103.224...
内网通 nwt_setup_3.4.3055.exe
全国电信网通铁通DNS服务器IP地址分享.doc
网通dns服务器地址列举.docx
河北省沧州市(中国网通) 首选DNS:202.99.160.68 备份DNS:202.99.176.30或202.99.166.4
这是我收集的全国dns地址 山东 首选:202.102.152.3 dns-jn.sd.cninfo.net 济南 202.102.154.3 dns-qd.sd.cninfo.net 青岛 备用:202.102.128.68 ns.sdjnptt.net.cn 济南 202.102.134.68 ns1.sdqdptt.net....
内网通免广告插件
联通网通宽带用户手册.pdf
全国各地dns服务器ip地址大全,dns服务器就是域名解析服务器,相当于互联网的路标
网通IP检测Delphi源代码..rar
网通3G支撑系统技术规范.rarv网通3G支撑系统技术规范.rar网通3G支撑系统技术规范.rar
铁通,电信,网通,ADSL错误代码大全.pdf铁通,电信,网通,ADSL错误代码大全.pdf铁通,电信,网通,ADSL错误代码大全.pdf铁通,电信,网通,ADSL错误代码大全.pdf铁通,电信,网通,ADSL错误代码大全.pdf铁通,电信,网通,ADSL错误...
XXX大学一网通办平台运行管理暂行办法.pdf
中国各地_电信、网通、铁通_DNS_地址服务器.txt
内网通3.4.3045最新版本 免广告码 积分码 算法工具,每次生成100万积分
升学E网通试卷答案导入-导出.user.js
2,该软件最大的优点是首创DNS双线智能解析功能,是目前解决网通、电信、铁通及其他网络的互通问题的最有效方法,同一个域名可以让网通、电信及其他线路的客户ping出来的完全不同IP,就近访问站点。 3,支持中文域名...