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

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

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

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

* Abusando do Request Tracker
* Vazamento de Informações
* Obtendo a senha do KeePass por meio de um dump de memória (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/b02ba4b346de3362101c0d60bebed8212d02142d" alt="" width="563"><figcaption></figcaption></figure>

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

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

**Procurando portas abertas com o Nmap: 22.80**

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

<figure><img src="/files/7d77237f4f4368f7ce36b41703eed02861cf4126" 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 -p22,80 10.10.11.227 -oN targeted
```

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

### Porta 80

Descobrimos o domínio **keeper.htb** e um subdomínio **tickets.keeper.htb**.

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

Nós os adicionamos ao `/etc/hosts` arquivo:

<figure><img src="/files/9e13be711675ce5fa1e9687469ad609e6f4f33e0" alt=""><figcaption></figcaption></figure>

## CMS do Request Tracker

Ao visitar **tickets.keeper.htb** encontramos um painel de administração.

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

Testamos as credenciais padrão do **Request Tracker**:

```plaintext
Usuário: root  
Senha: password  
```

<figure><img src="/files/144444ecf4c792d456381e207b74f2332dc35265" alt=""><figcaption></figcaption></figure>

Conexão bem-sucedida!

<figure><img src="/files/3700aa695f6f73f229b4ecca5cdb45e3a6fb36a1" alt=""><figcaption></figcaption></figure>

No **Admin → Users** na seção encontramos uma conta de usuário:

* Usuário: <Inorgaard@keeper.htb>
* Senha: Welcome2023!

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

#### Conexão SSH

Usamos as credenciais encontradas para conectar via SSH:

```bash
ssh Inorgaard@keeper.htb
```

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

### Flag user.txt :)

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

## Escalada de privilégios

### **Dump do banco de dados do KeePass**

Encontramos um arquivo ZIP `RT30000.zip` que baixamos para nossa máquina:

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

```bash
wget http://10.10.11.227:8080/RT30000.zip
```

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

Após a extração, obtemos:

* **KeePassDumpFull.dmp**
* **passcodes.kdbx**

<figure><img src="/files/139b0716dcc069eed4d48c48d3b8360cc0acb697" alt=""><figcaption></figcaption></figure>

Estamos tentando abrir `passcodes.kdbx` com o KeePassXC:

```bash
keepassxc passcodes.kdbx
```

Ele pede uma senha. Tentamos um brute force com **John The Ripper**, sem sucesso.

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

### **KeePass - análise do dump de memória**

{% embed url="<https://github.com/matro7sh/keepass-dump-masterkey>" %}

Exploramos o `.dmp` arquivo com um script Python:

```bash
python3 poc.py KeePassDumpFull.dmp
```

Isso revela caracteres ilegíveis. Uma busca online nos leva a uma provável senha:

<figure><img src="/files/18618c62c3f247a2c43d2ce7c4584c74f9b2906b" alt=""><figcaption></figcaption></figure>

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

**Resultado**: mingau vermelho com creme

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

Usamos essa senha para desbloquear o KeePass, nos fornecendo uma **chave criptografada do PuTTY e senha de root**.

<figure><img src="/files/55f5a1401f798033037b978e7a41a47fab2ce1f3" alt=""><figcaption></figcaption></figure>

### Converter chave PuTTY para o formato OpenSSH

Precisamos converter a chave PuTTY para o formato OpenSSH:

```bash
puttygen key.ppk -O private-openssh -o id_rsa
```

Em seguida, certifique-se de que sua chave privada tenha as permissões corretas:

```bash
chmod 600 id_rsa
```

#### **Conectar ao servidor SSH**

```bash
ssh -i id_rsa root@10.10.11.227
```

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

### Flag root.txt :)

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

<figure><img src="/files/8248f10ab2305cfb4501d2458a7e73c6ef8ae073" alt="" width="417"><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/keeper-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.
