> 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/pt-br/web/xss/reflected-xss-in-a-javascript-string-with-html-encoded-angle-brackets.md).

# XSS Refletido em uma String JavaScript com Parênteses Angulares Codificados em HTML

### XSS refletido em uma string JavaScript com os sinais de menor e maior codificados em HTML

Este laboratório contém uma vulnerabilidade do tipo XSS refletida no mecanismo de rastreamento da consulta de pesquisa: os sinais de menor e maior (`<` e `>`) são codificados em HTML, mas o valor refletido é inserido dentro de uma \*\*string JavaScript\*\*. O objetivo é sair dessa string JS e chamar `alert()`.

**Trecho relevante ao código observado**

{% code overflow="wrap" %}

```javascript
var searchTerms = 'hello';
   document.write('<img src="/resources/images/tracker.gif?searchTerms='+encodeURIComponent(searchTerms)+'">');
```

{% endcode %}

<figure><img src="/files/5784a79785cbdc5deba7de63df2c6387db7ae0fc" alt=""><figcaption></figcaption></figure>

O valor de pesquisa (`searchTerms`) é concatenado em uma `document.write` instrução dentro de uma string HTML construída em JavaScript. Ao injetar um apóstrofo (`'`) no valor, você pode fechar a string JavaScript atual e executar código arbitrário.

```javascript
hello'
```

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

Ao enviar a seguinte string como valor de pesquisa, você fecha a string, executa `alert(0)` e então fecha:

```javascript
hello' ; alert(0);'
```

<figure><img src="/files/0795ac4acd4531532454135be35a186781f797ab" 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/pt-br/web/xss/reflected-xss-in-a-javascript-string-with-html-encoded-angle-brackets.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.
