一种很常见的写法:

document.write('<scr'+'ipt src="http://a.com/b.js" type="text/javascript"></scr'+'ipt>');

直到被杀毒软件提示有恶意代码才发现这也是不安全的,汗……

那就只好改成这样了:

(function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = 'http://a.com.cn/b.js';
    document.getElementsByTagName('head')[0].appendChild(s);
})();

搜了一下,原来还有“邪恶”的eval,具体可以看这里:网马解密大讲堂——网马解密中级篇(Document.write篇)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.