> For the complete documentation index, see [llms.txt](https://itskode.gitbook.io/pentesting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itskode.gitbook.io/pentesting/dockerlabs/facil/candy.md).

# Candy

## Reconocimiento

Se comienza con un escaneo de puertos utilizando `nmap`:

```bash
nmap -sV -p- 172.17.0.2
```

![nmap](/files/FY0eQguGQfSFXaUVOs3V)

**Resultados:**

* Puerto 80 abierto
* Servicio: Apache httpd 2.4.58 (Ubuntu)

***

## Enumeración Web

Accedemos al sitio web:

* Página principal: **Cassiopeia**
* Se observa un formulario de login

![gobuster](/files/tQB0wkXNe2OPwKl9oeGB)

Se realiza fuzzing de directorios con `gobuster`:

```bash
gobuster dir -u http://172.17.0.2 \
-w /usr/share/seclists/Discovery/Web-Content/common.txt \
-x html,txt,php
```

**Hallazgos importantes:**

* `/administrator/`
* `/robots.txt`
* `/README.txt`
* `/api/`, `/components/`, etc.

![login](/files/ApPnfmygmrXyR8WE9phH)

***

## Análisis de robots.txt

Se accede a:

```
http://172.17.0.2/robots.txt
```

Se identifican rutas sensibles y un posible leak:

```
admin:c2FubHVpczEyMzQ1
```

![joomla](/files/KBNqGRN0Db8TSSeqYi4g)

***

## Decodificación de credenciales

El string parece estar en base64:

```bash
echo "c2FubHVpczEyMzQ1" | base64 -d
```

Resultado:

```
sanluis12345
```

Credenciales:

* Usuario: admin
* Password: sanluis12345

![template](/files/wjLjqFDSSbvDmhZXTn8O)

***

## Acceso al panel Joomla

Se accede al panel de administración:

```
/administrator
```

![shell](/files/RchZBxqDAXgpiUYRbqQr)

***

## RCE mediante edición de templates

Se edita el template:

```
/templates/cassiopeia/index.php
```

Se inserta una reverse shell en PHP.

![find](/files/B3Vm2YOrNsrWpsqHz6bK)

***

## Reverse Shell

Configuración:

* IP atacante: 172.17.0.1
* Puerto: 9001

Listener:

```bash
nc -lvnp 9001
```

Se obtiene acceso:

![file](/files/CMJjF08eirn9VH7Pz3YR)

***

## Tratamiento de TTY

```bash
script -c bash /dev/null
stty raw -echo; fg
export TERM=xterm
export SHELL=bash
```

***

## Búsqueda de archivos interesantes

```bash
find / -type f -name "*.txt" 2>/dev/null
```

Archivo interesante:

```
/var/backups/hidden/otro_caramelo.txt
```

![sudo](/files/pJTMRLQiF9nlEQuB0e8k)

***

## Archivo sensible

Contenido:

* Credenciales de base de datos
* Usuario del sistema: `luisillo`

![dd](/files/hDiMXm9EIIJ6362e9EiT)

***

## Escalada de privilegios

Cambio de usuario:

```bash
su luisillo
```

Luego:

```bash
sudo -l
```

Resultado:

```
(ALL) NOPASSWD: /bin/dd
```

![extra](/files/Q9QhKWkIdH3JPPrjeNkP)

***

## Explotación con dd

![tty](/files/Q1wyvygte0lfKgKO5EUG)

Se puede escribir archivos como root:

```bash
echo "DATA" | dd of=/ruta/archivo
```

Esto permite escalada a root.

![resultado](/files/ODdr2tPcwYP47tzCZRnt)

![final](/files/rqDrZBCBq4IgUc03zGbw)

***

## Conclusión

* Enumeración básica → acceso Joomla
* Credenciales expuestas en `robots.txt`
* RCE vía template
* Reverse shell
* Escalada mediante `dd` con permisos sudo

***

## Lecciones aprendidas

* Nunca exponer credenciales en archivos públicos
* Revisar permisos sudo cuidadosamente
* CMS como Joomla pueden ser vectores de ataque si no están securizados


---

# 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://itskode.gitbook.io/pentesting/dockerlabs/facil/candy.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.
