# OffSec Tre

<figure><img src="/files/KF0ZVM3nbeoQTAleGdud" alt=""><figcaption></figcaption></figure>

Hoy Vamos a resolver la maquina Tre de dificultad Hard segun la comunidad.

***

<figure><img src="/files/0HldWgOwwcHHHwym25xU" alt=""><figcaption></figcaption></figure>

Primero que nada observar los puertos que estan abiertos para este HOST.

***

```javascript
# Nmap 7.94SVN scan initiated Wed Feb 14 12:06:45 2024 as: nmap -sCV -p22,80,8082 -oN taregt.txt 192.168.243.84
Nmap scan report for 192.168.243.84
Host is up (0.063s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 99:1a:ea:d7:d7:b3:48:80:9f:88:82:2a:14:eb:5f:0e (RSA)
|   256 f4:f6:9c:db:cf:d4:df:6a:91:0a:81:05:de:fa:8d:f8 (ECDSA)
|_  256 ed:b9:a9:d7:2d:00:f8:1b:d3:99:d6:02:e5:ad:17:9f (ED25519)
80/tcp   open  http    Apache httpd 2.4.38 ((Debian))
|_http-title: Tre
|_http-server-header: Apache/2.4.38 (Debian)
8082/tcp open  http    nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: Tre
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed Feb 14 12:06:54 2024 -- 1 IP address (1 host up) scanned in 9.54 seconds
```

Observamos las versiones y servicios que corren para cada uno de los puertos.

***

<figure><img src="/files/P1QvkyOgbNNpiRpwNypw" alt=""><figcaption></figcaption></figure>

Si empezamos haciendo fuzzing en la pagina principal nos encontramos con un adminer.php y otros que tienen un codigo de estado 302, de un follow redirect.

***

<figure><img src="/files/kwxfoaSnaffzbbNec3Ps" alt=""><figcaption></figcaption></figure>

Si nos vamos a adminer tenemos un panel de login de la base, credenciales que no poseemos a seguir enumerando.

***

<figure><img src="/files/3OXZdAcW9fRYOuL0kQJ4" alt=""><figcaption></figcaption></figure>

El directorio mantis nos lleva a otro panel de autentificacion credenciales que igualmente no poseemos, seguimos enumerando.

***

<figure><img src="/files/KiN1zIqA5J6DzgoPcer1" alt=""><figcaption></figcaption></figure>

Segui fuzzeando a adminer pero nada, asi que empeze con mantis a hacer lo mismo y me encontre con mucho codigos de estado de  follow redirect.

***

<figure><img src="/files/yPw6QoyrActrCN2bb2ER" alt=""><figcaption></figcaption></figure>

Revise archivo a archivo, pero el que tenia las credenciales para el panel de adminer era a.txt.

***

<figure><img src="/files/HNYndhkcSpE1XdhKodwS" alt=""><figcaption></figcaption></figure>

Credenciales para adminer.

***

<figure><img src="/files/OkA5C2hunQlWc0pNVTl0" alt=""><figcaption></figcaption></figure>

Una vez iniciado session en el buscador, busque usuarios tre y me salio matis\_user\_tables, asi que tenemos aca unas nuevas credenciales, para el usuario tre.

Ahora las probamos atravez de SSH, haber si el usuario existe a nivel de sistema.

***

<figure><img src="/files/D3mSmOsfHYBwWI2ZB7vF" alt=""><figcaption></figcaption></figure>

Las credenciales funcionan y tenemos la primera bandera la de user.txt.

***

## Escalada de privilegios&#x20;

<figure><img src="/files/6NxQ62cIeSyirWKNXgz9" alt=""><figcaption></figcaption></figure>

Buscando como hacerlo busque de todo, hasta que encontre el check-system, donde podemos editarlo ya que tiene permisos de escritura,  salia un poco mas abajo de las primeras 50.

***

<figure><img src="/files/RTVV8G1rjsGPBKLgL7zI" alt=""><figcaption></figcaption></figure>

Lo abrimos y lo editamos, le decimos que nos asigne permisos SUID a la bash.

Ahora como se usa para que surja efecto, la neta check-system suena a chequeo medico. El codigo es simple en DATE hay declado algo como fechas, casi seria un estilo una tarea cron pero no lo es.

Tonces tenemos que encontrar una forma de forzar a que se haga un check, supongo que eso se hara al arrancar el sistema o yo que se.

***

<figure><img src="/files/cn0ypvUJjAcPywpzJ1Zq" alt=""><figcaption></figcaption></figure>

Bueno tre puede ejecutar shutdown, asi que vamos a reiniciar el sistema y si el script de arriba hace un check al apagar o al encender la maquina ejecutara nuestro chmod u+s la asignacion de permisos SUID a la bash.

***

<figure><img src="/files/9ajIlvIh0uBpn0uEoBb6" alt=""><figcaption></figcaption></figure>

1. Tonces reinicamos el sistema .
2. Luego nos volvemos a conectar via SSH.
3. Ahora si le hacemos un ls  a la bash observamos que se asigno el permiso SUID a la bash.

Ahora hacemos un bash -p y somos root.

***

<figure><img src="/files/YzQPgKhodZJReclkm8rQ" alt=""><figcaption></figcaption></figure>

Somos root y tenemos la ultima bandera.


---

# Agent Instructions: 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:

```
GET https://rodgar.gitbook.io/rodgar/plataformas/vulnhub/offsec-tre.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
