> 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/authentication/brute-forcing-a-stay-logged-in-cookie.md).

# Força Bruta em um Cookie de Sessão Persistente

### Força bruta em um cookie de manter-se logado

Este laboratório permite que os usuários permaneçam conectados mesmo depois de fecharem seus navegadores. O cookie usado para esse recurso é vulnerável a força bruta. / Para resolver o laboratório, você precisa fazer força bruta no cookie do Carlos para acessar sua página Minha conta.

**Credenciais fornecidas:** `wiener:peter`/ \*\* Nome da vítima:\*\* `carlos`

### \*\*Análise do mecanismo

Quando você marca a opção de reconexão automática, a seguinte requisição é enviada:

```bash
username=wiener&password=peter&stay-logged-in=on
```

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

O servidor então retorna um cookie chamado **stay-logged-in**, cujo conteúdo é codificado em Base64:

```bash
d2llbmVyOjUxZGMzMGRkYzQ3M2Q0M2E2MDExZTllYmJhNmNhNzcw
```

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

Após a decodificação, obtemos:

```bash
wiener:51dc30ddc473d43a6011e9ebba6ca770
```

<figure><img src="/files/3d8509232496462f596bcf05d02dce3b1dc461a2" alt=""><figcaption></figcaption></figure>

A estrutura do cookie é, portanto:

Ao verificar o hash via CrackStation, descobrimos que ele corresponde ao valor **peter** em MD5.

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

### **Configuração da força bruta**

1. Envie a consulta do cookie para **Burp Intruder** e selecione o valor do cookie como a área de injeção.

<figure><img src="/files/99d8b97b6c0d4078db282fa7be1277425a0000d3" alt=""><figcaption></figcaption></figure>

Em Processamento de payload:

* adicione uma transformação que gere um hash **MD5**;

<figure><img src="/files/78d1aaf016b540e9806f97a4eae7d41d466ffd00" alt=""><figcaption></figcaption></figure>

* adicione um prefixo: `carlos:`

<figure><img src="/files/260ba3f851272964259cfdd45d7b2462e283e9b3" alt=""><figcaption></figcaption></figure>

* codifique tudo em **Base64**.

<figure><img src="/files/85b89e81019baee4c0e1c118058c065909586526" alt=""><figcaption></figcaption></figure>

1. Carregue a lista de senhas nas Configurações de payload.

<figure><img src="/files/1d403fe67a61fa7e28cb1c195b53a71e902f192a" alt=""><figcaption></figcaption></figure>

Durante o ataque, uma resposta **200** indica o cookie correto para Carlos.

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

O cookie obtido é:

```bash
Y2FybG9zOjdkOGJjNWYxYThkMzc4N2QwNmVmMTFjOTdkNDY1NWRm
```

Decodificação

{% code overflow="wrap" %}

```bash
echo -n "Y2FybG9zOjdkOGJjNWYxYThkMzc4N2QwNmVmMTFjOTdkNDY1NWRm" | base64 -d ;echo
```

{% endcode %}

* carlos:7d8bc5f1a8d3787d06ef11c97d4655df

Ao verificar esse hash no CrackStation, descobrimos que a senha associada é **taylor**.

<figure><img src="/files/925cd19b80ca46871aef3665f47e6dc3bb90ba20" 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/authentication/brute-forcing-a-stay-logged-in-cookie.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.
