> 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/websockets/websocket-handshake-manipulation.md).

# التلاعب بالمصافحة في WebSocket

### التلاعب بمصافحة WebSocket لاستغلال الثغرات

يحتوي هذا المتجر الإلكتروني على وظيفة دردشة في الوقت الفعلي تعتمد على **WebSockets**. / يوجد عامل تصفية XSS: إنه صارم لكنه يحتوي على عيوب قابلة للاستغلال.

يتيح لك حقل الدردشة إرسال رسائل تُعرض في الوقت الفعلي لدى موظف الدعم.

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

#### اختبار أولي لعامل تصفية XSS

عند إرسال الحمولة التالية إلى الدردشة:

```javascript
<img src=0 onerror=alert(0)>
```

يرد الخادم بالرسالة:

* **تم اكتشاف هجوم: معالج الحدث**
* اتصال WebSocket يُغلق فورًا **مغلق**.

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

بعد إعادة تحميل الصفحة ببساطة، تظهر الرسالة التالية:

* **هذا العنوان مدرج في القائمة السوداء**

لذلك يتم حظر عنوان IP مؤقتًا.

<figure><img src="/files/5d4f48d09e2286c11ba953a648d3a82d4f2ad0d4" alt=""><figcaption></figcaption></figure>

#### التحايل على القائمة السوداء

تتم إضافة ترويسة HTTP التالية عند إنشاء مصافحة WebSocket:

```http
X-Forwarded-For: 0.0.0.0
```

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

يقبل الخادم الاتصال مرة أخرى. / ولتجنب الاضطرار إلى إضافتها يدويًا في كل مرة، تم تكوين هذه الترويسة **بشكل دائم في الوكيل**.

<figure><img src="/files/42db9779fb40cbcfae4430224c866861ca7f70ce" alt=""><figcaption></figcaption></figure>

#### التحايل على عامل تصفية XSS

بمجرد استعادة الاتصال، يتم تعديل الحمولة قليلًا لتجاوز عامل التصفية:

```javascript
<img src=0 OnErrOR=alert`0`>
```

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

هذا التغيير في الكسر والبنية النحوية يسمح بتجاوز الاكتشاف.

<figure><img src="/files/0a6141a0be4bfffc5aa76f59fcbfe3061fd13b94" 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/websockets/websocket-handshake-manipulation.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.
