`
cuishen
  • 浏览: 293690 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

XFS攻击一例

    博客分类:
  • j2ee
阅读更多
XFS: Cross Frame Script (跨框架脚本) 攻击。

什么是XFS攻击,下面举一个例子:

Tom在QQ上发消息诱骗Jerry点击了下面的连接:
http://thief.com

上面的连接返回了下面的html:
<html>
<head>
<title>IE Cross Frame Scripting Restriction Bypass Example</title>
<script>
function alertKey(e) {
	alert("key press = '" + e.which + "'");
}
</script>
</head>
<frameset onload="this.focus();" onblur="this.focus();" cols="100%" onkeypress="alertKey(event);">
 <frame src="http://cuishen.iteye.com/" scrolling="auto">
</frameset>
</html>

对于Jerry来说,他以为自己在访问熟悉的网站,殊不知将输入的敏感信息暴露给了Tom (只要将上面alert 改成ajax call)。

魔高一尺,道高一丈,对于XFS攻击也有防御的办法。
主要算法是:

A. 对于确定你的网站没有使用frame的页面要打破frame (frame busting)
        <style>
                html { visibility:hidden; }
        </style>
        <script>
                if( self == top){
                        document.documentElement.style.visibility='visible';
                }else{
                        top.location = self.location;
                }
        </script>

B. 对于有使用iframe 和frame的页面当心anti-busting,换做下面的脚本:
if top <> self then
    if top.location.hostname <> self.location.hostname then
        top.location = "http://cuishen.iteye.com/"
    end if
end if


你的网站可能会毫不知情的被外面包裹一层frame,而变成了一个钓鱼网站,so... 请尽量避免在你的网站使用frame/iframe,并且应用frame busting脚本。

对于user来说,请升级到IE7以上浏览器,并设置:
Navigate sub-frames across different domains
set to "Prompt" or "Disable", 这个将在浏览器层面防御XFS攻击。
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics