公司负责维护的一位同事发现的,我们的页面很多地方都被注入了JS代码,这段代码展开了如下
(function (sogouExplorer) {
sogouExplorer.extension.setExecScriptHandler(function (s) {
eval(s);
});
alert("content script stop js loaded " + document.location);
if (typeof comSogouWwwStop == "undefined") {
var SERVER = "http://ht.www.sogou.com/websearch/features/yun1.jsp?pid=sogou-brse-596dedf4498e258e&";
window.comSogouWwwStop = true;
setTimeout(function () {
if (!document.location || document.location.toString().indexOf(SERVER) != 0) {
return;
}
function bind(elem, evt, func) {
if (elem) {
return elem.addEventListener ? elem.addEventListener(evt, func, false) : elem.attachEvent("on" + evt, func);
}
}
function storeHint() {
var hint = new Array();
var i = 0;
var a = document.getElementById("hint_" + i);
var b = document.getElementById("hint_text_" + i);
var storeClick = function () {
sogouExplorer.extension.sendRequest({
cmd: "click"
});
}
while (a && b) {
bind(a, "click", storeClick);
hint.push({
"text": b.innerHTML,
"url": a.href
});
i++;
a = document.getElementById("hint_" + i);
b = document.getElementById("hint_text_" + i);
}
return hint;
}
if (document.getElementById("windowcloseit")) {
document.getElementById("windowcloseit").onclick = function () {
sogouExplorer.extension.sendRequest({
cmd: "closeit"
});
}
var flag = false;
document.getElementById("bbconfig").onclick = function () {
flag = true;
sogouExplorer.extension.sendRequest({
cmd: "config"
});
return false;
}
document.body.onclick = function () {
if (flag) {
flag = false;
} else {
sogouExplorer.extension.sendRequest({
cmd: "closeconfig"
});
}
};
document.getElementById("bbhidden").onclick = function(){
sogouExplorer.extension.sendRequest({cmd: "hide"});
return false;
}
var sogoutip = document.getElementById("sogoutip");
var tip = {};
tip.word = sogoutip.innerHTML;
tip.config = sogoutip.title.split(",");
var hint = storeHint();
sogouExplorer.extension.sendRequest({
cmd: "show",
data: {
hint: hint,
tip: tip
}
});
} else {
if (document.getElementById("windowcloseitnow")) {
sogouExplorer.extension.sendRequest({
cmd: "closeit",
data: true
});
}
}
}, 1);
}
})(window.external.sogouExplorer(window, 8));
好像使用了FCKEditor这种编辑器和搜狗浏览器的时候会发生这种事情?这算流氓行为吗?搜狗在统计什么?
流氓行为,这是没有疑问的。对HTTP等协议透明,没有用户明示就不污染传输内容,这是浏览器行为绝对的底线。
浏览器如果连这种事情都做得出,只能说明这三件事,其一或一部分:
不过以我的猜测,搜狗浏览器的开发者不会这么笨(尤其是不会笨到把
alert
这种东西写进在后台静默运行的程序中!),所以还是建议LZ仔细检查原因到底出在哪里。不过就算如此,我也求求大家:在搜狗大战360这场狗咬狗的战争中,大家两害相权取其轻,至少千万别站在支持360的一边。
非常重要的补充:
Google搜索
http://ht.www.sogou.com/websearch/features/yun1.jsp
,发现了非常多(10页以上)的结果,并且都是LZ你这段代码。参考别人的经验,这表明这个污染的网址,很可能就是出现在后端,而不是浏览器捣的鬼。
这样,这个代码的意图、添加者可真的就难以说清了。搜狗干的有可能,别人抹黑搜狗也有可能,真的不可说。还是先排查服务器的安全问题吧。