> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/pt-br/writeups-ctf/hackthebox/linux-easy/blocky-hackthebox-writeup.md).

# Resolução da máquina Blocky do HackTheBox

{% embed url="<https://app.hackthebox.com/machines/48>" %}

{% hint style="warning" %}
**Habilidades:**

* Enumeração do WordPress
* Vazamento de Informações
* Analisando um arquivo jar - JD-Gui + Acesso SSH
* Abusando do Privilégio Sudoers (Escalada de Privilégio)
  {% endhint %}

## Reconhecimento

**Configuração do ambiente de trabalho:**

Configure o ambiente de trabalho criando três pastas para armazenar conteúdo importante, exploits e resultados de reconhecimento do Nmap.

<figure><img src="/files/8a97317aede178e698d11ee6c433faf1f702454a" alt=""><figcaption></figcaption></figure>

**Verificação de conectividade da VPN**

Verifique a conectividade da VPN para garantir comunicação estável com a máquina-alvo.

<figure><img src="/files/496a96720b6f10e0c5d00822b14e863e1479a614" alt=""><figcaption></figcaption></figure>

**Descoberta de portas abertas com Nmap:** Enumere as portas abertas e exporte os resultados para o arquivo "allPorts" no diretório do Nmap:

```bash
nmap -p- --open -sS -n -Pn --min-rate 5000 10.10.10.37 -oG allPorts
```

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

**Análise das portas abertas com extractport:** Usando a função extractport para exibir sinteticamente as portas abertas e copiá-las para a área de transferência. (21.22.80,25565)

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

**Escaneando a versão da porta com o Nmap:** Usando o Nmap para escanear a versão da porta e extraindo as informações para o arquivo "targeted":

```bash
nmap -sCV -p21,22,80,25565 10.10.10.37 -oN targeted
```

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

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

### Porta 80

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

**Enumeração de diretórios com Gobuster:**

Usamos **Gobuster** para enumerar diretórios no servidor web da máquina alvo.

```bash
gobuster dir -u http://blocky.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

<figure><img src="/files/118d1d1692d227632018444710d64477939867dd" alt=""><figcaption></figcaption></figure>

Descobrimos um diretório chamado **plugins**.

<figure><img src="/files/9736105b0df3f698e34ede7319889125dbff37a1" alt=""><figcaption></figcaption></figure>

**Baixando e extraindo o arquivo BlockyCore.jar:**

Baixamos o arquivo **BlockyCore.jar** , que parece ser um plugin personalizado. Em seguida, extraímos seu conteúdo.

```java
jar xf BlockyCore.jar
```

#### Descompilando o arquivo BlockyCore.class

No arquivo extraído encontramos um arquivo **BlockyCore.class** . Descompilamos ele usando **javap** para examinar seu conteúdo

```bash
javap -c BlockyCore.class
```

Encontramos um conjunto de credenciais para o banco de dados:

* **localhost**
* **root**
* **8YsqfCTnvxAUeduzjNSXe22**

<figure><img src="/files/8e28c9a191d9b86bee0b9fdab01fc28eabdcaca3" alt=""><figcaption></figcaption></figure>

#### Acesso ao banco de dados via PhpMyAdmin

Usando as credenciais extraídas, fazemos login no **PhpMyAdmin** e descobrimos uma tabela no banco de dados contendo um usuário chamado **notch**.

<figure><img src="/files/704afcda8c618e32c01db2a60b3c15596b863c75" alt=""><figcaption></figcaption></figure>

**Conexão via SSH:**

Usamos a senha **`8YsqfCTnvxAUeduzjNSXe22`** para o usuário **notch** e fazemos login com sucesso.

<figure><img src="/files/04a4878e82eb8d5ca7814f25374856bf6cb56137" alt=""><figcaption></figcaption></figure>

### Flag User.txt

<figure><img src="/files/705133dab46d36820d59e214ef6b1fed8b8b4838" alt=""><figcaption></figcaption></figure>

## Escalada de privilégios

Percebemos que o usuário pertence ao **sudo** grupo, o que nos permite usar **sudo** para elevar nossos privilégios

<figure><img src="/files/31c384c22b2fba497e2eea5a7a2d76e27fffdb19" alt=""><figcaption></figcaption></figure>

**Executando o comando sudo su:**/ Executamos o seguinte comando para obter um shell root:

```bash
sudo su
8YsqfCTnvxAUeduzjNSXe22
```

### Flag root.txt : )

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

<figure><img src="/files/01b31abe6fb5ddc8a687323e8796145b0be15ef1" alt="" width="516"><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://hacking-notes.jord4n.pro/pt-br/writeups-ctf/hackthebox/linux-easy/blocky-hackthebox-writeup.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.
