XFS攻击一例

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攻击。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值