var frameBustingRegex = /^(https?:\/\/)?(www|beta)\.foo1\.com(\/.*|$)|^(https?:\/\/)?www\.foo2\.com(\/.*|$)|www\.foo3\.com/;
if (self != top) {
var httpUrlHost= ServerSide.URLHOST
var httpRefHost=ServerSide.UrlReferrer.Host
if(httpRefHost)
{
var httpReferer=ServerSide.Refer
if(httpUrlHost!=httpRefHost
&&!frameBustingRegex.test(httpReferer))
{
top.location = self.location;
}
}
}

本文介绍了一种通过正则表达式匹配特定域名并实施frame-busting技术来防止跨站脚本攻击的方法。该方法检查当前页面是否被嵌入到不受信任的父窗口中,并在检测到此类情况时采取措施重新定位到顶层窗口。
1153

被折叠的 条评论
为什么被折叠?



