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

# Fuerza bruta de una cookie de sesión persistente

Notas sobre Fuerza bruta de una cookie de sesión persistente para los laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payload, validación en Burp Suite y contexto de mitigación.

### Fuerza bruta de una cookie de permanecer conectado

Este laboratorio permite a los usuarios seguir conectados incluso después de haber cerrado el navegador. La cookie utilizada para esta función es vulnerable a fuerza bruta. / Para resolver el laboratorio, necesitas hacer fuerza bruta a la cookie de Carlos para acceder a su página Mi cuenta.

**Credenciales proporcionadas:** `wiener:peter`/ \*\* Nombre de la víctima:\*\* `carlos`

### \*\*Análisis del mecanismo

Cuando marcas la opción de reconexión automática, se envía la siguiente solicitud:

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0403a19dab402f3e97c579c9825f7331603d1b8d%2F%7B8D6D842C-F790-48A4-AC29-DCAC18AD2362%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

El servidor entonces devuelve una cookie llamada **stay-logged-in**, cuyo contenido está codificado en Base64:

```bash
d2llbmVyOjUxZGMzMGRkYzQ3M2Q0M2E2MDExZTllYmJhNmNhNzcw
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-359b0e421ac5ddfffd4149ee6cc04759e30e10ad%2F%7B469300F7-6C16-42BF-BFBF-D1F5254966AE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Después de decodificar, obtenemos:

```bash
wiener:51dc30ddc473d43a6011e9ebba6ca770
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9c73b15c956ca8704047869bd559bc5eb7e73112%2F%7BA01AF79D-B838-4252-9A86-46AF6B0F52A7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

La estructura de la cookie es, por tanto:

Al comprobar el hash mediante CrackStation, descubrimos que corresponde al valor **peter** en MD5.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-439858b58f7b42121bd2e78a123370b0944bef21%2F%7BD57F01BA-3A29-45F7-941E-1FB71CEC1E8A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Configuración de fuerza bruta**

1. Envía la solicitud de la cookie a **Burp Intruder** y selecciona el valor de la cookie como el área de inyección.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-14892da393a82e18479182560f435303c07dc8dd%2F%7B76698D2C-E70F-4B1E-9243-AD759C812CBE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

En Procesamiento de carga útil:

* añade una transformación que genere un hash **MD5**;

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2f47e72581f4ed1e9c8c8d88dfb2c4e920c7831d%2F%7B37EC0F27-0B9F-452D-A041-F54DCC9686B5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* añade un prefijo: `carlos:`

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-67bfb16b499114e6751f7ac5167d18f3b56eb047%2F%7B31EB1BB3-3F24-4857-8A42-9EB6DD7560B6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* codifica todo en **Base64**.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a3c5a693dee97c0392a326eb20651ba038f7c394%2F%7B66EDA515-67B1-4141-9D92-0F5468F7B5AB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. Carga la lista de contraseñas en Configuración de carga útil.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-78de49eecd6ccd85f007c51cc67279ef03f78470%2F%7B384D96E6-8DA0-471A-B2E9-6322A26999EB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Durante el ataque, una respuesta **200** indica la cookie correcta para Carlos.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef712dc2dd92f224f0787cee97ac036e501c22f3%2F%7B2EF935E2-69B3-4161-9DAA-A69B9D416457%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

La cookie obtenida es:

```bash
Y2FybG9zOjdkOGJjNWYxYThkMzc4N2QwNmVmMTFjOTdkNDY1NWRm
```

Decodificación

{% code overflow="wrap" %}

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

{% endcode %}

* carlos:7d8bc5f1a8d3787d06ef11c97d4655df

Al comprobar este hash en CrackStation, encontramos que la contraseña asociada es **taylor**.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1ede348078088576176ffdbc5377f5a7933561f8%2F%7BC16A22DF-86A3-40CA-8F61-B58E8B3F5D69%7D.png?alt=media" 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 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/es/web/authentication/brute-forcing-a-stay-logged-in-cookie.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.
