# WebSockets

## Lab: Manipulating WebSocket messages to exploit vulnerabilities

### Enunciado

Esta tienda en línea tiene una función de chat en vivo implementada con WebSockets. Los mensajes de chat que envíes son vistos en tiempo real por un agente de soporte.

Envía un mensaje a través de WebSocket que provoque un popup de `alert()` en el navegador del agente de soporte.

### Resolución

Como vemos los mensajes que enviamos no salen en el **HTTP history** sino en **WebSockets** ya que es lo que usa.

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

Interceptamos y vemos que nos cambia los símbolos pero antes de mandarlo los cambiamos nosotros.

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

Vemos que se ha enviado por lo que enviamos un payload.

```
<img src=error onerror='alert(document.domain)'>
```

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

<figure><img src="/files/1HODeTp2Jqk6OECjQMg8" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://beafn28.gitbook.io/beafn28/web-security/laboratorios-portswigger/websockets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
