> For the complete documentation index, see [llms.txt](https://1gnotus.gitbook.io/ignotus_pwn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://1gnotus.gitbook.io/ignotus_pwn/dockerlabs/writeup/maquina-agua-de-mayo-decode-braynfuck-+-binary-bettercap-privesc.-+-privescalation-lxd.md).

# MAQUINA AGUA DE MAYO (DECODE BRAYNFUCK + BINARY BETTERCAP PRIVESC. + PRIVescalation LXD)

Utilice mi herramienta creada en python para ver los servicios y puertos abiertos dentro de la IP y luego me realiza un escaneo de vulnerabilidades.

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

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

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

La herramienta me encontro 2 puerto, el 22 ssh de version reciente y un puerto 80 http.

Ingreso a la web y tengo una pagina por defecto de apache.

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

Revise el codigo fuente de esta plantilla.

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

Dentro del codigo fuente me encuentro con esta especie de letras, iconos, etc.. Yo utilize chatgpt para ver si me lo decifra y la verdad que si lo hizo ademas me creo un script.

```
This function simulates a Brainfuck interpreter to decode the input program
def brainfuck_interpreter(code):
    memory = [0] * 30000  # Brainfuck memory tape
    pointer = 0           # Memory pointer
    output = []
    code_pointer = 0
    loop_stack = []

    while code_pointer < len(code):
        command = code[code_pointer]

        if command == '>':
            pointer += 1
        elif command == '<':
            pointer -= 1
        elif command == '+':
            memory[pointer] = (memory[pointer] + 1) % 256
        elif command == '-':
            memory[pointer] = (memory[pointer] - 1) % 256
        elif command == '.':
            output.append(chr(memory[pointer]))
        elif command == '[':
            if memory[pointer] == 0:
                # Skip the loop
                open_brackets = 1
                while open_brackets > 0:
                    code_pointer += 1
                    if code[code_pointer] == '[':
                        open_brackets += 1
                    elif code[code_pointer] == ']':
                        open_brackets -= 1
            else:
                loop_stack.append(code_pointer)
        elif command == ']':
            if memory[pointer] != 0:
                code_pointer = loop_stack[-1]
            else:
                loop_stack.pop()

        code_pointer += 1

    return ''.join(output)


# Brainfuck code provided by the user
brainfuck_code = "++++++++++[>++++++++++>++++++++++>++++++++++>++++++++++>++++++++++>++++++++++>++++++++++++>++++++++++>+++++++++++>++++++++++++>++++++++++>++++++++++++>++++++++++>+++++++++++>+++++++++++>+>+<<<<<<<<<<<<<<<<<-]>--.>+.>--.>+.>---.>+++.>---.>---.>+++.>---.>+..>-----..>---.>.>+.>+++.>."
output = brainfuck_interpreter(brainfuck_code)
output
```

Resultado: bebeaguaqueessano

Otro es que probe una web para decifrar esto:

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

Luego de encontrar esto lo guarde en el bloc de notas y seguí enumerando la web haciendo una búsqueda de directorios ocultos, en este caso utilice gobuster.

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

Tengo una imagen llamada agua\_ssh.jpg la cual ingrese y encontré lo siguiente.

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

Reviso lo metadatos para ver si contiene algo dentro .. pero no contiene nada interesante.

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

Con crackmapexec voy a validar probando combinaciones con lo encontrado, ya que agua me indica que es de ssh.

Una vez terminado veo que me valido unas credenciales.

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

Las pruebo a través del ssh y ya estoy dentro como usuario agua.

<figure><img src="/files/9oVFyWashC2oozDTJr2L" alt=""><figcaption></figcaption></figure>

Ahora paso a realizar un reconocimiento de la maquina.

<figure><img src="/files/5nkmCZv7nwW5vaEABfai" alt=""><figcaption></figcaption></figure>

Una vez que termine veo la forma de poder escalar privilegios para ser usuario root.

Acá encontré 2 casos.. probando sudo -l tengo el binario bettercap que se puede ejecutar como root sin adquirir contraseña.

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

Luego al enumerar el id, me indica que estoy en un grupo llamado lxd, la cual tambien podemos realizar una escalada de priv. Pero la intrusion no fue por aca ya que me lanzo un error.

Dejo info aca: <https://www.hackingarticles.in/lxd-privilege-escalation/>

<figure><img src="/files/9qO8Lly1SDyGMDKhDne4" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/5IXt4O7Zeq3At37lzuaS" alt=""><figcaption></figcaption></figure>

Bueno ahora vamos a lo que nos compete, al ejecutar como root bettercap me lanza unas indicaciones si le paso el comando help.

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

Hay algo interesante, puedo ejecutar una shell usando el signo "!", lo que se me ocurrio fue darle persmiso suid a la bash para despeus ejecutar un bash -p y loguearme como root.

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