> 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/greenhorn-hackthebox-writeup.md).

# Relato do HackTheBox Greenhorn

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

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

* Descobrindo senhas embutidas em repositórios Git
* Senhas SHA-512 não hashadas
* Exploração do Pluck
* Descriptografando senhas pixeladas (usando DEPIX)
  {% endhint %}

## Reconhecimento <a href="#reconnaissance" id="reconnaissance"></a>

**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/492cb8e42a76267170d13fae12d0735a470190a5" alt="" width="563"><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/02a2667faf52a12170d8ab3b0aa9fb3bbaed2b83" alt="" width="563"><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 --min-rate 5000 -vvv -n -Pn 10.10.11.25 -oG allPorts
```

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

**Análise de portas abertas com extractPorts:**

Use a função extractPorts para exibir as portas abertas em um formato conciso e copiá-las para a área de transferência (22,80,3000)

<figure><img src="/files/8498debb950eb67a63aebbd8992e09fe51c87973" alt="" width="563"><figcaption></figcaption></figure>

**Varredura de versão de portas com Nmap:**

Use o Nmap para verificar as versões dos serviços e salvar a saída no arquivo "targeted":

```bash
nmap -sCV -p80,22,3000 10.10.11.25 -oN targeted
```

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

Para resolver nomes de domínio em endereços IP via DNS, insira o nome de domínio associado ao seu endereço IP no `/etc/hosts` arquivo.

<figure><img src="/files/2da242dee0a7a943fc2a84b50b94984319240dc1" alt="" width="563"><figcaption></figcaption></figure>

### **Descoberta de senha:**

Na porta 3000 encontramos um serviço exposto semelhante ao Git, parecido com o GitHub, mas destinado ao uso corporativo interno

<figure><img src="/files/857e464b0c9c69b934b11995a0d6d03c44b172af" alt=""><figcaption></figcaption></figure>

Prosseguimos para criar uma conta

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

Entre os arquivos do projeto, encontramos um arquivo contendo uma senha em "`pass.php`":

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

```
d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163
```

<figure><img src="/files/501a5b56711b2936cd307530dde7d3998646c7a8" alt=""><figcaption></figcaption></figure>

Esse hash está em SHA512. Após a descriptografia, obtemos a senha **`iloveyou1`**.

{% embed url="<https://10015.io/tools/sha512-encrypt-decrypt>" %}

<figure><img src="/files/7bf6ed36e5f1c4c767f15a46a3c0964f71a0b901" alt=""><figcaption></figcaption></figure>

## Vulnerabilidade do Pluck CMS

Na porta 80 encontramos um serviço web Pluck.

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

O `login.php` o arquivo requer uma senha para acessar a interface do gerenciador.

<figure><img src="/files/7ca23dab7d5324056f139ff63afdbabf51e0fcb1" alt=""><figcaption></figcaption></figure>

O gerenciador de conteúdo tem uma versão `4.7.18`, vulnerável a execução remota de código (RCE).

<figure><img src="/files/75ef65970bb7d6e77caa5e7a847cedbac36ea6d5" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC>" %}

### Fase de exploração:

1. Clone o repositório contendo o script de exploit:

```bash
git clone https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC.git
cd CVE-2023-50564_Pluck-v4.7.18_PoC
```

2. Nós modificamos o `poc.py` script com o endereço IP do servidor e a senha "*iloveyou1*".

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

2. Em seguida, crie um `payload.zip` arquivo contendo o payload malicioso, com os campos `<your_ip>` e porta ajustados para corresponder ao nosso listener.

<figure><img src="/files/c855d6fee3eb18bf74a976e9fc2c9f1adc760bfe" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/3e9bdb11f0ba57b6bfe684e39338f9251f66176d" alt="" width="512"><figcaption></figcaption></figure>

5. Executamos o script de exploração:

```bash
python poc.py

/home/jordan/......./payload.zip
```

<figure><img src="/files/1bd6f6764654bf10c3b26e44b44e8598701be8cb" alt=""><figcaption></figcaption></figure>

Ao mesmo tempo, abrimos uma sessão de escuta na porta `4444` com o Netcat e obtemos acesso ao servidor como o usuário `www-data`.

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

Ao inspecionar o `/etc/passwd` arquivo, descobrimos o usuário "junior". Conseguimos nos conectar com a senha **iloveyou1**:

<figure><img src="/files/98c5a2d91ec4ad282a2fea0c1164e19f9b855744" alt=""><figcaption></figcaption></figure>

### Flag de user.txt obtida:

<figure><img src="/files/c42d89d77f852c45e2be57e6e745b4fb0f3d8503" alt="" width="563"><figcaption></figcaption></figure>

## Escalada de privilégios

1. Localizamos o arquivo PDF: `Usando OpenVAS.pdf`.
2. Transfira o arquivo usando Python 3 executando:

```bash
python3 -m http.server 1234
```

<figure><img src="/files/7843e86075e01da198710415ba3ba11f068e763e" alt="" width="563"><figcaption></figcaption></figure>

3. Baixamos o arquivo PDF com o seguinte comando:

<pre class="language-bash"><code class="lang-bash"><strong>wget http://10.10.11.25:1234/Using%20OpenVAS.pdf
</strong></code></pre>

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

Ao abrir este arquivo, descobrimos a senha pixelada da conta de administrador

<figure><img src="/files/4668811fa26827c41c1c8d1315432f8f0200de91" alt=""><figcaption></figcaption></figure>

### Descriptografia da senha:

Para quebrar a senha oculta, usamos o software Depix:

{% embed url="<https://github.com/spipm/Depix>" %}

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

```bash
git clone https://github.com/spipm/Depix
cd Depix
```

Em seguida, executamos o comando:

```bash
python3 depix.py /
    -p pixel.png /
    -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png /
    -o /home/jordan/Desktop/password.png
```

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

A senha descriptografada é:

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

`sidefromsidetheothersidesidefromsidetheotherside`

Fazemos login como usuário root com essa senha.

<figure><img src="/files/8bc0b5cde4044c8d81f9ff05aefc70869c4486b2" alt="" width="554"><figcaption></figcaption></figure>

### Flag root :)

<figure><img src="/files/239e4086b0e1888a5eeebf670e1fb26f40020827" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/75c9e73aca44ab107e25aa20635b4a4530ded5e8" alt="" width="563"><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/greenhorn-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.
