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

# Linux 権限昇格

sudo の悪用、SUID バイナリ、cron ジョブ、Linux capabilities、PATH ハイジャック、カーネルエクスプロイト、Docker エスケープ、共有ライブラリ、ファイル権限、NFS 共有、サービスなどを扱う Linux 権限昇格メモ。

Linuxの権限昇格は、低権限のシェルからrootへ移行することに焦点を当てたポストエクスプロイテーション段階です。目的は、ローカルシステムを列挙し、設定ミスを特定し、信頼された実行経路を悪用し、弱い権限を確実なrootシェルへと変えることです。

このセクションでは、ペネトレーションテスト、CTFマシン、ラボ環境、ローカルのポストエクスプロイテーション確認で使用される実践的なLinux権限昇格手法を扱います。

## 権限昇格ワークフロー

1. シェルを安定化し、現在のユーザー、グループ、ホスト名、カーネル、ディストリビューションを特定します。
2. sudo権限、SUIDバイナリ、capability、書き込み可能ファイル、cronジョブ、NFSエクスポート、ローカルサービスを列挙します。
3. docker、lxd、adm、proxyなどのグループ所属を確認し、直接悪用できる経路を探します。
4. PATHの使用、共有ライブラリの読み込み、Pythonのimport、書き込み可能な実行コンテキストを確認します。
5. カーネルおよびパッケージのバージョンを、既知のローカル権限昇格CVEと照合します。
6. 最も安全で確認済みの経路を悪用し、報告用にコマンドの手順を保持します。

## 手動列挙チェックリスト

Linuxホストに入ったとき、権限昇格の経路を選ぶ前に素早くローカルの全体像を把握するために使用します。

### 基本システム情報

```bash
uname -a
cat /proc/version
cat /etc/issue
cat /etc/*-release
lsb_release -a 2>/dev/null
lscpu
uptime
```

ハードウェアとファイルシステムの情報:

```bash
cat /proc/cpuinfo
free -h
df -h
```

### 環境変数

```bash
env
set
echo $PATH
echo $HOME
echo $USER
```

### ユーザー列挙

```bash
whoami
id
groups
cat /etc/passwd
cut -d: -f1 /etc/passwd
grep -v '/nologin\|/false' /etc/passwd
cat /etc/shadow 2>/dev/null
cat /etc/group
```

ユーザーの活動と履歴:

```bash
last
lastlog
history
cat ~/.bash_history 2>/dev/null
```

sudoアクセス:

```bash
sudo -l
cat /etc/sudoers 2>/dev/null
```

### ネットワーク列挙

インターフェースとルート:

```bash
ifconfig -a 2>/dev/null
ip a
route 2>/dev/null
ip route
netstat -r 2>/dev/null
arp -a 2>/dev/null
ip neigh
```

ポートと接続:

```bash
netstat -tuln 2>/dev/null
ss -tuln
netstat -tunap 2>/dev/null
ss -tunap
```

DNS、hosts、ファイアウォール:

```bash
cat /etc/resolv.conf
cat /etc/hosts
iptables -L 2>/dev/null
```

### 実行中のサービス

```bash
service --status-all 2>/dev/null
ps aux
ps -ef
pstree 2>/dev/null
systemctl list-units --type=service 2>/dev/null
service service_name status 2>/dev/null
```

起動スクリプト:

```bash
ls -la /etc/init.d/ 2>/dev/null
ls -la /etc/rc*.d/ 2>/dev/null
```

### ファイルシステム列挙

機密設定と隠しファイル:

```bash
find / -name "*.conf" -o -name "*.config" 2>/dev/null
find /home -name ".*" -type f 2>/dev/null
```

パスワードと機密アーティファクト:

```bash
grep -r "password" /etc/ 2>/dev/null
find /etc \( -name "*.conf" -o -name "*.config" \) -exec grep -l "password" {} \; 2>/dev/null
cat /var/apache2/config.inc 2>/dev/null
cat /var/lib/mysql/mysql/user.MYD 2>/dev/null
cat /root/anaconda-ks.cfg 2>/dev/null
cat ~/.bash_history 2>/dev/null
cat ~/.mysql_history 2>/dev/null
cat ~/.ssh/id_rsa 2>/dev/null
cat ~/.ssh/id_rsa.pub 2>/dev/null
```

興味深いファイルの探索:

```bash
find / -name "*.txt" 2>/dev/null
find / -name "*flag*" 2>/dev/null
find / -name "*.txt" 2>/dev/null | grep -i flag
grep -r "password" /home 2>/dev/null
grep -r "flag" /home 2>/dev/null
```

権限:

```bash
find / -type f -perm -o+w -not -path "/proc/*" 2>/dev/null
find / -type f -perm -o+w -not -path "/proc/*" -not -path "/sys/*" 2>/dev/null
find / -type d -perm -o+w -not -path "/proc/*" 2>/dev/null
find / -type f -perm -u=s 2>/dev/null
find / -type f -perm -g=s 2>/dev/null
find / -perm -o+x -type f 2>/dev/null
find / -type f -mtime -1 2>/dev/null
```

### スケジュール済みタスク

```bash
cat /etc/crontab
ls -la /etc/cron.d/
ls -la /etc/cron.daily/
ls -la /etc/cron.hourly/
ls -la /etc/cron.monthly/
ls -la /etc/cron.weekly/
crontab -l
```

### インストール済みソフトウェア

```bash
dpkg -l 2>/dev/null
rpm -qa 2>/dev/null
which command_name 2>/dev/null
```

Webサーバーパス:

```bash
cat /etc/apache2/apache2.conf 2>/dev/null
cat /etc/httpd/conf/httpd.conf 2>/dev/null
ls -la /var/www/ 2>/dev/null
ls -la /srv/www/ 2>/dev/null
```

### 高速権限チェック

```bash
find / -perm -4000 -type f -exec ls -la {} \; 2>/dev/null
ls -la /etc/passwd
sudo -l
echo $PATH | tr ':' '\n' | xargs -I {} ls -ld {} 2>/dev/null
find /etc/cron* -type f -perm -o+w 2>/dev/null
getcap -r / 2>/dev/null
```

### 自動列挙ツール

自動化ツールは補助として使い、証拠としては扱わないでください。出力は保持し、悪用前に見つかった項目をすべて手動で検証してください。

```bash
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh
chmod +x LinEnum.sh
./LinEnum.sh
wget https://raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.sh
chmod +x lse.sh
./lse.sh -l1
wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh
chmod +x linux-exploit-suggester.sh
./linux-exploit-suggester.sh
```

### 段階的トリアージ

1. OS、カーネル、ディストリビューション、CPU、ストレージ、稼働時間を収集します。
2. 現在のユーザー、グループ、シェル、sudoアクセス、読み取り可能なアカウントファイルを確認します。
3. SUID/SGIDバイナリ、sudoルール、capability、cronジョブ、PATH、NFS、サービスを列挙します。
4. 書き込み可能ファイル、書き込み可能ディレクトリ、資格情報、鍵、履歴、最近の変更を探します。
5. 許可されている場合は自動列挙を実行し、その後に興味深い発見を手動で検証します。
6. より安全な設定ミス経路が排除された後の最後の手段として、カーネルエクスプロイトを扱います。

## Linux権限昇格手法

<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-terminal" style="color:$primary;">:terminal:</i></h3></td><td><h4>sudoers</h4></td><td>Linux sudoers 権限昇格手法、sudo -l の悪用、許可されたバイナリ、シンボリックリンクの悪用、およびsudoのバージョン脆弱性。</td><td><a href="/ja/privesc/sudoers.md">Sudoers</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>脆弱なバイナリ、GTFOBinsの手順、PwnKit、Nmap、PHP、screen、カスタムSUIDバイナリ向けのLinux SUID権限昇格メモ。</td><td><a href="/ja/privesc/suid.md">SUID</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>Cronジョブ</h4></td><td>書き込み可能なスクリプト、定期的なrootタスク、pspy64、Logstashジョブ、ImageMagickの悪用に関するCronジョブ権限昇格メモ。</td><td><a href="/ja/privesc/cron-jobs.md">cron ジョブ</a></td></tr><tr><td><h3><i class="fa-linux" style="color:$primary;">:linux:</i></h3></td><td><h4>Dirty Pipe</h4></td><td>実践的な列挙、悪用例、検証を含むLinux権限昇格手法メモ。</td><td><a href="/ja/privesc/dirty-pipe-linux-privilege-escalation.md">Dirty Pipe</a></td></tr><tr><td><h3><i class="fa-shield-halved" style="color:$primary;">:shield-halved:</i></h3></td><td><h4>権限</h4></td><td>書き込み可能ファイル、/etc/passwd の悪用、Smart Enumeration、最小権限の確認に関するLinuxの権限設定ミスメモ。</td><td><a href="/ja/privesc/permissions.md">権限</a></td></tr><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>Capabilities</h4></td><td>cap_setuid、cap_dac_read_search、GTFOBins、Python、Perl、Vim、tac、tar の悪用に関するLinux capability権限昇格メモ。</td><td><a href="/ja/privesc/capabilities.md">Capabilities</a></td></tr><tr><td><h3><i class="fa-route" style="color:$primary;">:route:</i></h3></td><td><h4>PATHハイジャック</h4></td><td>相対的なバイナリ呼び出し、書き込み可能なPATH優先順位、悪意あるコマンド置換に関するPATHハイジャック権限昇格メモ。</td><td><a href="/ja/privesc/path-hijacking.md">PATH ハイジャック</a></td></tr><tr><td><h3><i class="fa-microchip" style="color:$primary;">:microchip:</i></h3></td><td><h4>カーネル悪用</h4></td><td>ローカル権限昇格、Linux Exploit Suggester、Dirty COW、OverlayFS、UbuntuカーネルCVEに関するLinuxカーネルエクスプロイトメモ。</td><td><a href="/ja/privesc/kernel-exploitation.md">カーネルの悪用</a></td></tr><tr><td><h3><i class="fa-network-wired" style="color:$primary;">:network-wired:</i></h3></td><td><h4>NFS共有</h4></td><td>no_root_squash、書き込み可能なエクスポート、攻撃者がマウントした共有、SUIDペイロードの検証に関するNFS共有権限昇格メモ。</td><td><a href="/ja/privesc/nfs-shares.md">NFS 共有</a></td></tr><tr><td><h3><i class="fa-server" style="color:$primary;">:server:</i></h3></td><td><h4>サービスとSystemd</h4></td><td>書き込み可能なサービスファイル、サービスバイナリ、systemdユニット、安全でないデーモン設定に関するLinuxサービス権限昇格メモ。</td><td><a href="/ja/privesc/services.md">サービスと systemd</a></td></tr><tr><td><h3><i class="fa-python" style="color:$primary;">:python:</i></h3></td><td><h4>Pythonライブラリハイジャック</h4></td><td>import解決順序の悪用と、sudo実行されるPythonスクリプト中の書き込み可能な作業ディレクトリに関するPythonライブラリハイジャックメモ。</td><td><a href="/ja/privesc/python-library-hijacking.md">Python ライブラリハイジャック</a></td></tr><tr><td><h3><i class="fa-users" style="color:$primary;">:users:</i></h3></td><td><h4>ユーザーグループ</h4></td><td>docker、lxd、adm、proxy、logs、ホストルール、コンテナの悪用に関するLinuxローカルグループ権限昇格メモ。</td><td><a href="/ja/privesc/user-groups.md">ユーザーグループ</a></td></tr><tr><td><h3><i class="fa-docker" style="color:$primary;">:docker:</i></h3></td><td><h4>Dockerエスケープ</h4></td><td>デフォルトのDocker Toolbox認証情報、SUID操作、パスワード再利用、SSH鍵のピボットに関するDockerエスケープ権限昇格メモ。</td><td><a href="/ja/privesc/docker-escape.md">Docker エスケープ</a></td></tr><tr><td><h3><i class="fa-link" style="color:$primary;">:link:</i></h3></td><td><h4>共有ライブラリハイジャック</h4></td><td>特権付きLinuxバイナリによって読み込まれる、欠落しているまたは書き込み可能な共有オブジェクトを悪用するための共有ライブラリハイジャックメモ。</td><td><a href="/ja/privesc/shared-library-hijacking.md">共有ライブラリハイジャック</a></td></tr></tbody></table>

## 推奨ツール

* [LinPEAS](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS) 自動Linux権限昇格列挙のための。
* [pspy64](/ja/privesc/cron-jobs/pspy64-cron-enumeration-linux-privilege-escalation.md) root権限なしでcronジョブとプロセスを検出するための。
* [Linux Exploit Suggester](/ja/privesc/kernel-exploitation/linux-exploit-suggester-linux-privilege-escalation.md) カーネルエクスプロイト候補のための。
* [GTFOBins](https://gtfobins.github.io/) sudo、SUID、capability、シェルエスケープのペイロードのための。
* [スマート列挙](/ja/privesc/permissions/smart-enumeration-linux-privilege-escalation.md) 構造化されたローカル設定ミスの確認のための。


---

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