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

# Relato do HackTheBox Underpass

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

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

* Enumeração UDP
* Credenciais padrão (DaloRADIUS)
* Quebra de senhas
* Escalonamento de privilégios via SUDO (mosh-server)
  {% 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/a74834b7045408769838cf19edae495e9463e983" 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/2a856de8f9e338502485706b14eab175ba0b44b6" alt="" width="563"><figcaption></figcaption></figure>

### TCP

**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 -vvv --min-rate 5000 10.10.11.48 -oG allPorts
```

<figure><img src="/files/1fedfaf2cb60089a325077160bd0b183ffece6f1" alt=""><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,80 10.10.11.48 -oN targeted
```

<figure><img src="/files/23d12bd8efce35195d7d8bee02a07077a016ab13" alt=""><figcaption></figcaption></figure>

### UDP

**Varredura das portas UDP mais usadas:**

Realizamos uma varredura das 100 portas UDP mais comuns:

```bash
nmap -sU --top-ports 100 --open -vvv -n 10.10.11.48 -oG allPortsUDP
```

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

* Portas identificadas: **161, 1812, 1813**.

<figure><img src="/files/71b2343cbc2a532b13610790826eb92fa6428920" alt=""><figcaption></figcaption></figure>

**Varredura de versão dos serviços UDP:**/ Miramos as portas identificadas para obter informações adicionais:

```bash
nmap -sUCV -p161,1812,1813 10.10.11.48 -oN targetedUDP
```

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

**Observação inicial:**

* O domínio **underpass.htb** é descoberto.
* Um CMS chamado **DaloRADIUS** é identificado.

## CMS - **DaloRADIUS**

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

**Escaneie os diretórios com o Gobuster:**/ Exploramos os diretórios do site:

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

Resultado: um diretório chamado **`/app`** é descoberto.

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

**Listagem dos subdiretórios:**<br>

Ao explorar **`/app`**, encontramos:

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

<figure><img src="/files/75246fe6789675b1cdfce463796eb1e43902f2e0" alt=""><figcaption></figcaption></figure>

* Um **página de login para usuários**.

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

* Um **página de login para operadores**.

<figure><img src="/files/793b1b19276fb4ed90443f1308e75adbd9a5ed89" alt=""><figcaption></figcaption></figure>

**Acesso com as credenciais padrão do DaloRADIUS:**/ Ao testar as credenciais padrão do RADIUS:

* **Nome de usuário:** `administrador`
* **Senha:** `radius`/ Essas credenciais funcionam no painel do operador.

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

### **Extração de informações sensíveis:**

No **Gerenciamento** na seção encontramos um **nome de usuário** e um **hash de senha**:

* **Usuário:** `svcMosh`
* **Hash :** `412DD4759978ACFCC81DEAB01B382403`

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

### **Quebra de hash:**<br>

Usamos **CrackStation** para descriptografar o hash:

{% embed url="<https://crackstation.net/>" %}

**Senha descriptografada:** `underwaterfriends`

<figure><img src="/files/975e71fdc9582de3600b2c586f0a6a6ba5bba600" alt=""><figcaption></figcaption></figure>

**Conexão SSH:**/ Com essas credenciais, acessamos a máquina via SSH:

```bash
ssh svcMosh@underpass.htb

underwaterfriends
```

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

## Escalada de privilégios

### SUDO - Mosh-Server

Ao verificar as permissões com o `sudo -l` comando, descobrimos que o usuário **svcMosh** pode executar o **mosh-server** binário com privilégios de administrador sem fornecer uma senha

```bash
sudo -l
```

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

> Como você tem a opção de executar **mosh-server** como root, você pode aproveitar isso para estabelecer uma conexão com **mosh** usando **sudo** para executar o servidor como administrador.

O comando a seguir executará **mosh-server** com privilégios de root e, em seguida, estabelecerá uma conexão com o **mosh** cliente:

```bash
mosh --server="sudo /usr/bin/mosh-server" localhost
```

Isso permitirá **mosh** se conectar ao servidor **mosh-server** que está sendo executado como root em **localhost**. Usando esse método, você terá acesso privilegiado à máquina com direitos de administrador.

<figure><img src="/files/12eb1a327e08a62ac00596b9911a9c3831e2a45d" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="/files/0372d963fd54d77e20affd2550d486e96e84d2f6" alt="" width="547"><figcaption></figcaption></figure>

<figure><img src="/files/3262f9540bd04f2339fd43d4c71addc94a8f8bff" alt="" width="522"><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/underpass-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.
