Fdream's Blog
专注于WEB前端开发
Powered by Google

不安全的js写法

11 晴天 2009-9
Fdream 发表于 Ajax Web, 已被阅读 1093 次, 评论 0 条
关键词:javascript ajax
[ 阅读字体大小: ]

一种很常见的写法:

参考代码: [复制代码] [保存代码]

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篇)

Related articles 您可能对这些文章也感兴趣:
Related comments 与该文相关的评论:(我也想说几句)
Add a comment 我来说两句: 
禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
表  情
arrow
用户名:   密码:  (匿名可不写) 同时注册?
验证码:   看不清?换个图片  看不清楚?换个图片

 
Copyright © 2005-2008,Fdream All Rights Reserved
Processed in 0.0625008 second(s) , unknow queries
Powered by OWord V0.1, Even Not Alpha
(此博客程序为半成品,请勿索取,以免给您的心灵造成创伤^_^)
鄂ICP备05026031号