GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java-Interview-Advanced/docs/03/96.md at master · leelovejava/Java-Interview-Advanced

Expand file tree

/

96.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
32 lines (10 loc) · 1.74 KB
/

96.md

Copy path

File metadata and controls

32 lines (10 loc) · 1.74 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

96、听说过CSRF攻击吗?你知道他背后的原理是什么吗

Cross Site Request Forgery,垮站点请求伪造

这个就是黑客想办法去伪造成你这个用户去发送请求到某个系统上去,然后查询你的数据,转账交易之类的,伪装成你,也有很多办法,比如利用XSS搞一个恶意脚本让你执行,然后盗取你的浏览器里的cookie

利用你的cookie伪装成你登录的状态,然后去执行一些请求

利用XSS跨站点脚本攻击,获取cookie,然后再利用postman发送垮站点伪造请求

防御CSRF的方法主要是以下几种:

(1)防止cookie被窃取:最最根本的,其实还是说防止cookie被窃取,可以给你的网站的cookie设置HttpOnly属性,禁止被别人的script脚本窃取,那么别人就无法伪造用户登录请求了

(2)随机token:每次返回一个页面给你的时候,都生成一个随机token附加在页面的隐藏元素里,同时在你的redis里可以存以下,然后页面发送请求的时候附加随机token,验证通过才能执行请求,你要是自己用postman构造请求就不知道随机token是什么了

(3)验证码:页面提交必须搞一个验证码,那种图形的,现在比较流行的还有拖动一个拼图什么的,必须验证码通过了才能执行你的请求,避免黑客直接伪造请求发送过来,这个其实是比较常见的,最好是在用户进行支付交易的时候,要求必须在页面上拖拽一个拼图验证码

(4)Referer请求头:这个是http请求里有一个referer请求头,带有这个请求的来源,你可以验证一下这个请求是不是从自己的页面里来的,如果是的话才执行,否则就不要执行了

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.