0x01 前言
0x02 GET型
利用十分简单,构造一个IMG标签,加载的时候即可发送一个恶意
get请求(可以和xss联合使用,也可以是有钓鱼,诱骗的方式让其
点击get请求链接)<img src=https://xxx.cn/csrf?xx=11 />
0x03 POST型
@GetMapping("/"
public String index( {
return "form";
}
@PostMapping("/post"
@ResponseBody
public String post( {
return "CSRF passed.";
}
前端提交数据页面(spring框架中调用_csrf.parameterName方法可以有效防止csrf)
<div>
<!-- th:action with Spring 3.2+ and Thymeleaf 2.1+ can automatically force Thymeleaf to include the CSRF token as a hidden field -->
<!-- <form name="f" th:action="@{/csrf/post}" method="post"> -->
<form name="f" action="/csrf/post" method="post">
<input type="text" name="input" />
<input type="submit" value="Submit" />
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
</form>
</div>
正常提交携带token值则能够通过请求
0x04 审计方法
审计前端html、jsp等前端页面,在提交表单时是否有token(隐藏属性)