> 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/privesc/permissions/etc-passwd-write-abuse-linux-privilege-escalation.md).

# /etc/passwd 写入滥用 - Linux 权限提升

## 这是什么

基于权限的提权会滥用可写文件、薄弱的所有权设置、暴露的机密，或本应只由 root 控制的敏感路径。小小的权限错误一旦影响到认证文件或特权执行路径，就可能直接变成 root 访问。此页面具体聚焦于 **权限管理 (/etc/passwd)** 并保持利用流程切合实际：识别条件，安全验证，然后运行证明影响所需的最小载荷。

## 枚举

在运行利用路径之前，先确认本地上下文和具体的错误配置。

```bash
find / -writable 2>/dev/null
ls -la /etc/passwd /etc/shadow 2>/dev/null
```

## 示例

如果我们按系统的\*\*可写性\*\*筛选文件，那么 /etc/passwd

```bash
find / -writable 2>/dev/null
```

<figure><img src="/files/082d208111d7075debce739147a6ceebaaacdec4" alt=""><figcaption></figcaption></figure>

<div data-full-width="true"><figure><img src="/files/4722eae0a69e7d671146c1512b92d099d1c59532" alt=""><figcaption></figcaption></figure></div>

使用 **openssl**，如果我们创建一个密码，它会把它转换为 SSL 格式

```bash
openssl passwd
```

<div data-full-width="true"><figure><img src="/files/ea75b80600b537f44b1af8e7b61408f1d39b5429" alt=""><figcaption></figcaption></figure></div>

我们把这串字符串粘贴到 root 用户上，系统会先从 /etc/passwd 而不是 /etc/shadow 中读取它：

<figure><img src="/files/87ed5edc574a38ca3bd78673bdad74f81c2d9a50" 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/privesc/permissions/etc-passwd-write-abuse-linux-privilege-escalation.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.
