> 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/api-attack/abus-dapi-pentesting-web.md).

# إساءة استخدام واجهة API

## تثبيت خادم الويب من GitHub (إساءة استخدام API)

```bash
curl -o docker-compose.yml https://raw.githubusercontent.com/OWASP/crAPI/main/deploy/docker/docker-compose.yml
docker-compose pull
docker-compose -f docker-compose.yml --compatibility up -d

```

* نحن **سجّل** مستخدم جديد: ![](/files/513ffa9df9d60380d375a36b0a7b3c31bc7f5f93)

## استطلاع الـ API

* للعثور على ثغرات الـ API، من المهم أن نبدأ بـ **استطلاع جيد**. في قسم Network، التقط الطلب كما تفعل مع [Burp Suite](/ar/hacking-tools/web/burpsuite.md) باستخدام XHR: ![](/files/cce4a2070599b65d88ee30080aa85f12772b3ce6)
* لـ **تنظيم وتخزين** جميع طلبات الـ API بشكل صحيح، نستخدم **Postman**:

```javascript
postman & disown &>/dev/null

```

* أنشئ جديدًا **مجموعة** حيث تُجمَّع جميع طلبات الـ API. بالنسبة إلى **طلب POST** الطلبات، الصق **رابط URL** وخاصةً الخام **الجسم**: ![](/files/46a5575fb4b9addde29b391a75e1ef6e51095467) ![](/files/3ac4eb00294ad07b5b3fcd1db8480dd96bd1eff2)
* يعيد **الرمز المميز ببنية JWT** لتسجيل الدخول: ![](/files/35fa0d21f82be4bd34d020fd37459c1a3ff536aa)
* أنشئ متغيرًا باسم **accessToken** بقيمة رمز تسجيل الدخول: ![](/files/927fbd0e8f393749def3825afc81d20fbb88792f)
* في قسم **التفويض**، اربط المتغير بالنوع **رمز الحامل**: ![](/files/919ed7785e0971831672741d51c38aeb01da40a6)
* احفظ الكل **الطلبات الممكنة**:

1. لوحة التحكم: ![](/files/89bd4eee5cad3a5e0a12fb5d6195d722512386e2)
2. المنتجات: ![](/files/d8ef8f45efeaa03dd51e30640255c0630ee27fce)
3. الأمر: ![](/files/f10094258c273bf46e9e86e486f4644f1a520b96)

## الثغرات المرتبطة بإساءة استخدام الـ API:

### استعادة الرمز المميز بالقوة الغاشمة:

يوجد خيار لـ **إعادة تعيين كلمة المرور** من خلال استرجاع رمز عبر البريد الإلكتروني:

<figure><img src="/files/2ace330b5f525de12fc459d499a05813fbc2c04a" alt="" width="563"><figcaption></figcaption></figure>

على المنفذ *8025*، يوجد **SMTP** حيث نستلم الرمز المميز:

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

انقر **نسيت كلمة المرور** مع عنوان البريد الإلكتروني للحساب الذي تريد تغيير كلمة مروره:

<figure><img src="/files/63040aa862872a793dc72a9d782423cb54134116" alt="" width="563"><figcaption></figcaption></figure>

نلتقط **query** إلى الـ API:

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

نرسل الطلب على أنه **طلب POST** بالبنية الخام:

<figure><img src="/files/9003e473e78214c287dc9999a844cb0a9bd08e6d" alt="" width="563"><figcaption></figcaption></figure>

نستخدم **ffuf** لإطلاق **هجوم بالقوة الغاشمة**:

```graphql
ffuf -u http://localhost:8888/identity/api/auth/v2/check-otp -w /usr/share/SecLists/Fuzzing/4-digits-0000-9999.txt -X POST -d '{"email":"jordan@jordan.com","otp":"FUZZ","password":"Password1234*"}' -H "Content-Type: application/json" -p 1 -mc 200

```

الـ **رمز التأكيد** أعاد 0172 **رمز حالة ناجح** وقد تم تغيير كلمة المرور تلقائيًا:

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

### تعديل أسعار المنتجات وزيادة الرصيد المتاح:

نبحث باستخدام **ffuf** الطريقة الممكنة للطلب **products**:

```bash
ffuf -u http://localhost:8888/workshop/api/shop/products -w /usr/share/SecLists/Fuzzing/http-query-methods.txt -X FUZZ -p 1 -mc 200,401

```

هذه كلها **الطرق الممكنة**:

<figure><img src="/files/5ca81531e6f5c35d2948d379d7331a1ca3e3db45" alt="" width="563"><figcaption></figcaption></figure>

إذا انتقلنا من **GET** إلى **طلب POST**، فسيحدث ما يلي:

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

هذه **التعيين الجماعي** ثغرة تسمح بإنشاء منتج عبر **طلب POST** الطلبات. في هذه الحالة، ننشئ منتجًا بسعر **سالب** السعر:

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

بهذه الطريقة، يتم **تفسيره** بواسطة خادم الويب:

<figure><img src="/files/0f267e33523d4e9cffe81dc898e0e656507604da" alt="" width="563"><figcaption></figcaption></figure>

لأن السعر **سالب**، في كل مرة نضغط فيها على **شراء**، تتم إضافة 10,000 دولار إلى رصيدنا:

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

إذا كان في الطلب **الطلبات**، أدخلنا رقم المنتج مع كمية مثل 100، فسيتم ضرب رصيدنا في **100 × 10,000**:

<figure><img src="/files/462da8e92a3484aef34acc793fa84b091353f8d8" alt="" width="563"><figcaption></figcaption></figure>

### اعثر على رمز قسيمة صالح:

نرسل طلب **validate-coupon**:

<figure><img src="/files/0a65fdf8c1fb310ccde0c3114eae2ed39cfcb4f3" alt="" width="563"><figcaption></figcaption></figure>

لأن القسيمة **غير صحيحة**، لا يُرجع الخادم شيئًا:

<figure><img src="/files/31775e1f9a31a598039b833ccb3454bf070c2fda" alt="" width="524"><figcaption></figcaption></figure>

إذا حاولنا تنفيذ حقن [NoSQL ](/ar/web-vulnerabilities/nosql-attack.md)لأن قاعدة البيانات **MongoDB**، فإنه يستجيب برمز القسيمة:

<figure><img src="/files/8c21b2508dc604b065d47e62736c1390cdedb419" 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/api-attack/abus-dapi-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.
