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

# Manipulation des WebSocket-Handshakes

### Manipulation des WebSocket-Handshakes, um Schwachstellen auszunutzen

Dieser Online-Shop verfügt über eine Echtzeit-Chat-Funktion auf Basis von **WebSockets**. / Ein XSS-Filter ist vorhanden: Er ist aggressiv, hat jedoch ausnutzbare Fehler.

Ein Chat-Feld ermöglicht es Ihnen, Nachrichten zu senden, die auf der Seite des Support-Agenten in Echtzeit angezeigt werden.

<figure><img src="/files/21de7320f2593c54784610a373bb944668b47d41" alt=""><figcaption></figcaption></figure>

#### Erster XSS-Filter-Test

Beim Senden des folgenden Payloads in den Chat:

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

Der Server antwortet mit der Nachricht:

* **Angriff erkannt: Event-Handler**
* WebSocket-Verbindung wird sofort **geschlossen**.

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

Nach einfachem Neuladen der Seite erscheint die folgende Meldung:

* **Diese Adresse steht auf der Blacklist**

Die IP-Adresse wird daher vorübergehend blockiert.

<figure><img src="/files/7b75a238b9b8ca1ec53f3db7afc930df373555af" alt=""><figcaption></figcaption></figure>

#### Umgehung der Blacklist

Hinzufügen des folgenden HTTP-Headers beim Aufbau des WebSocket-Handshakes:

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

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

Der Server akzeptiert die Verbindung erneut. / Um zu vermeiden, dass dieser jedes Mal manuell hinzugefügt werden muss, wird dieser Header **dauerhaft im Proxy konfiguriert**.

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

#### Umgehung des XSS-Filters

Sobald die Verbindung wiederhergestellt ist, wird das Payload leicht modifiziert, um den Filter zu umgehen:

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

<figure><img src="/files/31e674c5c025886634b1b98a0a4c87d72ec6e9a7" alt=""><figcaption></figcaption></figure>

Diese Änderung von Groß-/Kleinschreibung und Syntax ermöglicht es, die Erkennung zu umgehen.

<figure><img src="/files/bfa672b08b3f971c1e0ce1a484b4289c92195ba3" 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/de/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.
