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

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

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

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

* Identificando um dispositivo IoT
* Recuperação forense de arquivos
  {% 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/2437fab0b853f1d7236d977990d7f79ed603cb9f" 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/94f449284d33cf252d74e8dd76ef69491c383d7f" 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.48 -oG allPorts
```

<figure><img src="/files/d71f02ff69d15a983e5d040837c8dac9897d2f29" 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,53,80,1178,32400,32469)

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

Varredura de versões 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 -p22,53,80,1178,32400,32469 10.10.10.48 -oN targeted
```

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

## Porta 80 - Pi-hole

Ao escanear a porta 80, a ferramenta Wappalyzer não revela nenhuma informação significativa.

<figure><img src="/files/276e8ef5b4d6b9c17a66aeb77e85e96b64b094cd" alt=""><figcaption></figcaption></figure>

No entanto, após fazermos um pouco de fuzzing, descobrimos um diretório "`admin`" associado ao Pi-hole, contendo um painel de login.

<figure><img src="/files/260bbe378dec6a0747f2be756a8b64608ed3b13b" alt=""><figcaption></figcaption></figure>

Em seguida, buscamos na Internet por credenciais padrão e encontramos as seguintes informações:

* **Usuário:** pi
* **Senha:** raspberry

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

Estamos tentando nos conectar via SSH porque a porta 22 está aberta:

```bash
ssh pi@10.10.10.48
```

A conexão é bem-sucedida.

<figure><img src="/files/84db445a099e05646a705209d3da0dfe57153553" alt=""><figcaption></figcaption></figure>

### Flag user.txt

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

## **Elevação de privilégios :**

**Grupo sudo:** Ao verificar os grupos do usuário, vemos que o usuário "pi" pertence ao grupo sudo. Como já conhecemos sua senha, podemos obter privilégios de root.

```bash
id
```

<figure><img src="/files/923d4d580097b4345c265f87f74d55dcf1973101" alt=""><figcaption></figcaption></figure>

Em seguida, executamos `sudo su` e inserimos a senha do usuário "pi":

```bash
sudo su
```

### Bandeira root.txt

**Recuperação do arquivo root.txt:** O atacante nos informa que perdeu o `root.txt` arquivo e que devemos procurá-lo em um backup em um pendrive.

<figure><img src="/files/653fcd4517742a1e08d2aaa98e95ca8e44bb0521" alt=""><figcaption></figcaption></figure>

Procuramos dispositivos USB conectados e encontramos um `/dev/sdb` disco

```bash
df -h 
```

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

Ao tentar ler este disco diretamente, os dados ficam ilegíveis. No entanto, após usar o `strings` comando, conseguimos recuperar informações legíveis do dispositivo:

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

```bash
strings /dev/sdb
```

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

<figure><img src="/files/831b2daba69bf4d0cff2c1c4ae9eccfdd958b67d" alt="" width="530"><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/mirai-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.
