学习笔记而已 ~~~~~~~~~~~~~~~~~~~~~~~~~~
点击劫持
是一种视觉上的欺骗手段,攻击者使用一个透明的,不可见的iframe 覆盖在一个网页上,然后诱使用户在该页面点击透明的iframe 网页,通过调整iframe页面的位置,可以诱使用户恰好点击在iframe页面的一些功能性按钮上
例子:
<!DOCTYPE html>
<html>
<head>
<title>Click</title>
<style>
iframe{
width: 2000px;//不可见网页的宽高
height: 6000px;
position: absolute;
top: -5px;
left: -440px;
z-index: 2;//最顶层但是透明的
-moz-opacity: 0;
opacity: 0;
filter:alpha(opacity=0);
}
button{
position: absolute;
top: 200px; //这是看见的网页的button
left: 200px;
z-index: 1;
width: 500px;
}
</style>
</head>
<body>
<iframe src="http://www.qidian.com/Default.aspx" scrolling="no"></iframe>
<button οnclick="alert(1)">you can you up!</button>
</body>
</html>
flash 点击劫持,图片覆盖攻击 XSIO
<a href="http://xxx.com.cn">
<img src="xxx.jpg" style=postion:absolute;right:320px;top:90px/>
</a>
还有可以在 手机应用上得到实习价值,
tagjacking~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
防御:
1)禁止跨域的iframe 来防范, frame busting
if(top.location != location){top.location = self.location;}
缺陷 js 代码写的 控制能力并不是特别强
攻陷方法为 嵌套多个 iframe 绕过
<iframe src="xxx1.html">
<iframe src="xxx2.html">
2) X-Frame-Options
DENY 浏览器拒绝当前页面加载任何frame 页面
SAMEORIGN 同域下的页面
ALLOW-FORM origin 允许
HTML5
简要介绍
W3C 制定的新一代 HTML语言的标准。
一些新的标签 会存在XSS攻击的可能<video> <audio>
https://github.com/cure53/H5SC 中有HTML5安全知识一个html工程
新增功能
html5 中为 iframe 定义了一个 sandbox 单独的源,其中的脚本被禁止执行,表单被禁止提交,插件被禁止限制 其功能
<a> <area> 标签定义了一个新的link type noreferrer
<a href = "xxx" rel="noreferrer">test<a> 不再发送referer 保护敏感信息和隐私的考虑
canvas HTML5的最大创新之一。 标签让JS 直接操作图片对象,也可以直接操作像素
开发者甚至可以写小游戏
HTML5 也制定了新的同源标准
www.a.com/test.html ->origin-> www.b.com/test.php
www.a.com/test.html <- access-control-allow-origin<- www.b.com/test.php
跨窗口传递消息:
window.name 来跨窗口,跨域传递消息。
window这个对象几乎不受同源策略的限制的,
HTML5 为了丰富WEB开发者的能力, 新API: postMessage (firefox3 ie8,opera 9)
允许每一个window 包括当前窗口,弹出窗口,iframe等 对象往其他窗口发送文本消息,从而实现跨窗口的消息传递。这个功能也不受同源策略的限制
send:
<!DOCTYPE html>
<html>
<iframe src="http://1.hipanda.sinaapp.com/postMessage/receive.html" id="iframe"></iframe>
<form id="form">
<input type="text" id="msg" value="Message To send"/>
<input type="submit"/>
</form>
<script>
window.onload = function(){
var win = document.getElementById("iframe").contentWindow;
document.getElementById("form").onsubmit = function(e){
win.postMessage(document.getElementById("msg").value);
e.preventDefault();
};
};
</script>
</html>
receive:
<html>
<b>receive msg!</b>
<div id="test">Send me a message!</div>
<script>
document.addEventListener("message",function(e){
document.getElementById("test").textContent = e.domain + " said: " + e.data;
},false);
</script>
</html>
但是不知道为什么 win.postMessage 执行不成功 是版本问题??
安全问题: 1)验证URL , 2)接受消息写入的地方 要进行检查
Web Storage 非关系型 数据库,Key-Value 对组成
设置一个值: window.sessionStorage.setItem(key,value);
读取一个值: window.sessionStorage.getItem(key);
firefox 好单独实现了一个globalStorage 基于SQLite
1)session storage 关闭浏览器就失效
2)local storage 会一直存在
可以将 XSS PAYLOAD 存储在 WEB STORAGE 中,实现跨域页面攻击