> 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/linux-permissions-calculator.md).

# Linux 权限计算器

适用于八进制和符号表示法、SUID、SGID、粘滞位、常见模式以及权限提升分诊的 Linux 权限计算器。

搜索诸如以下的八进制模式 `755`, `644`, `600`, `4755`，或诸如以下的符号模式 `rwxr-xr-x` 以转换权限并理解其影响。

## 权限查找器

<table data-view="cards" data-full-width="true" data-search="true"><thead><tr><th>八进制</th><th>符号</th><th>含义</th><th>典型用途</th><th>提权风险</th></tr></thead><tbody><tr><td><code>000</code></td><td><code>---------</code></td><td>无权限</td><td>锁定文件</td><td>低</td></tr><tr><td><code>400</code></td><td><code>r--------</code></td><td>所有者仅可读</td><td>私钥材料</td><td>如果被错误所有者可读，则风险很高</td></tr><tr><td><code>600</code></td><td><code>rw-------</code></td><td>所有者可读/可写</td><td>SSH 密钥、配置和机密</td><td>如果所有者是服务账户，则为中等风险</td></tr><tr><td><code>640</code></td><td><code>rw-r-----</code></td><td>所有者可读/可写，组可读</td><td>共享服务配置</td><td>如果组可暴露机密，则风险很高</td></tr><tr><td><code>644</code></td><td><code>rw-r--r--</code></td><td>所有者可写，所有人可读</td><td>公开 Web 文件</td><td>对机密文件风险很高</td></tr><tr><td><code>660</code></td><td><code>rw-rw----</code></td><td>所有者/组可读写</td><td>团队管理的文件</td><td>如果组能编辑特权脚本，则风险很高</td></tr><tr><td><code>664</code></td><td><code>rw-rw-r--</code></td><td>所有者/组可写，所有人可读</td><td>协作文件</td><td>中到高</td></tr><tr><td><code>666</code></td><td><code>rw-rw-rw-</code></td><td>所有人可读写</td><td>很少合适</td><td>对于配置、脚本或认证文件至关重要</td></tr><tr><td><code>700</code></td><td><code>rwx------</code></td><td>仅所有者完全访问</td><td>私有脚本和目录</td><td>如果所有者正确，则风险低</td></tr><tr><td><code>710</code></td><td><code>rwx--x---</code></td><td>所有者完全权限，组可执行</td><td>用于组的目录遍历</td><td>中等</td></tr><tr><td><code>750</code></td><td><code>rwxr-x---</code></td><td>所有者完全权限，组可读/可执行</td><td>服务目录</td><td>如果组范围较大，则为中等风险</td></tr><tr><td><code>755</code></td><td><code>rwxr-xr-x</code></td><td>所有者可写，所有人可读/可执行</td><td>常见二进制文件和 Web 目录</td><td>如果可写所有者被攻陷，则风险很高</td></tr><tr><td><code>770</code></td><td><code>rwxrwx---</code></td><td>所有者/组完全访问</td><td>共享管理员目录</td><td>如果组可被滥用，则风险很高</td></tr><tr><td><code>775</code></td><td><code>rwxrwxr-x</code></td><td>所有者/组可写，所有人可读/可执行</td><td>共享 Web 目录</td><td>对代码路径风险很高</td></tr><tr><td><code>777</code></td><td><code>rwxrwxrwx</code></td><td>所有人完全访问</td><td>仅限临时实验文件</td><td>对脚本、目录、服务和 Web 根目录至关重要</td></tr><tr><td><code>1733</code></td><td><code>rwx-wx-wt</code></td><td>带粘滞位的世界可写目录</td><td>上传/投放目录</td><td>中等</td></tr><tr><td><code>1777</code></td><td><code>rwxrwxrwt</code></td><td>世界可写且带粘滞位的目录</td><td><code>/tmp</code></td><td>中等；检查符号链接/竞争条件问题</td></tr><tr><td><code>2755</code></td><td><code>rwxr-sr-x</code></td><td>SGID 可执行文件</td><td>以文件组运行</td><td>如果二进制文件/脚本可被滥用，则风险很高</td></tr><tr><td><code>2775</code></td><td><code>rwxrwsr-x</code></td><td>SGID 且组可写的目录</td><td>共享项目目录</td><td>如果组控制了被执行的文件，则风险很高</td></tr><tr><td><code>4755</code></td><td><code>rwsr-xr-x</code></td><td>SUID 可执行文件</td><td>以文件所有者身份运行</td><td>如果由 root 拥有且可被利用，则极其严重</td></tr><tr><td><code>4777</code></td><td><code>rwsrwxrwx</code></td><td>SUID 且世界可写</td><td>严重配置错误</td><td>严重</td></tr><tr><td><code>6755</code></td><td><code>rwsr-sr-x</code></td><td>SUID 和 SGID 可执行文件</td><td>特权辅助程序</td><td>如果存在用户可控行为，则极其严重</td></tr></tbody></table>

## 位计算器

| 值 | 权限 | 符号  |
| - | -- | --- |
| 4 | 读取 | `r` |
| 2 | 写入 | `w` |
| 1 | 执行 | `x` |
| 0 | 无  | `-` |

将每一类的值相加：

| 八进制数字 | 符号    | 含义       |
| ----- | ----- | -------- |
| `0`   | `---` | 无访问权限    |
| `1`   | `--x` | 仅执行      |
| `2`   | `-w-` | 仅写入      |
| `3`   | `-wx` | 写入并执行    |
| `4`   | `r--` | 仅读取      |
| `5`   | `r-x` | 读取并执行    |
| `6`   | `rw-` | 读取和写入    |
| `7`   | `rwx` | 读取、写入、执行 |

## 特殊位

| 八进制前缀 | 位    | 文件含义       | 目录含义                    |
| ----- | ---- | ---------- | ----------------------- |
| `1`   | 粘滞位  | 在文件上很少见    | 用户只能删除自己的文件             |
| `2`   | SGID | 以文件组执行     | 新文件继承目录组                |
| `4`   | SUID | 以文件所有者身份执行 | 在大多数 Linux 系统上对目录没有实际意义 |

## 快速命令

```bash
stat -c '%A %a %U %G %n' /path/to/file
find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null
find / -writable -type d 2>/dev/null
find / -writable -type f 2>/dev/null
```

## 分级规则

| 发现项                         | 优先级 |
| --------------------------- | --- |
| 名称或路径异常的 root 所有 SUID 二进制文件 | 严重  |
| 世界可写且由 root 执行的脚本           | 严重  |
| 可写的服务文件或 systemd 单元         | 严重  |
| 可写的 cron 目标                 | 严重  |
| 世界可写的 Web 根目录               | 高   |
| 由特权组拥有的可写组文件                | 高   |
| 可读的机密、备份、密钥或数据库配置           | 高   |


---

# 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/linux-permissions-calculator.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.
