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

# Attaque par force brute sur un cookie de session persistant

Notes sur l’attaque par force brute sur un cookie de session persistant pour les laboratoires de la PortSwigger Web Security Academy, incluant le workflow d’exploitation, les tests de payloads, la validation dans Burp Suite et le contexte de remédiation.

### Attaque par force brute d’un cookie « stay-logged-in »

Ce laboratoire permet aux utilisateurs de rester connectés même après avoir fermé leur navigateur. Le cookie utilisé pour cette fonctionnalité est vulnérable à une attaque par force brute. / Pour résoudre le laboratoire, vous devez forcer par brute le cookie de Carlos afin d’accéder à sa page Mon compte.

**Identifiants fournis :** `wiener:peter`/ \*\* Nom de la victime :\*\* `carlos`

### \*\*Analyse du mécanisme

Lorsque vous cochez l’option de reconnexion automatique, la requête suivante est envoyée :

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

<figure><img src="https://3840167291-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>

Le serveur renvoie alors un cookie nommé **stay-logged-in**, dont le contenu est encodé en Base64 :

```bash
d2llbmVyOjUxZGMzMGRkYzQ3M2Q0M2E2MDExZTllYmJhNmNhNzcw
```

<figure><img src="https://3840167291-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>

Après décodage, on obtient :

```bash
wiener:51dc30ddc473d43a6011e9ebba6ca770
```

<figure><img src="https://3840167291-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 structure du cookie est donc :

En vérifiant le hachage via CrackStation, nous découvrons qu’il correspond à la valeur **peter** en MD5.

<figure><img src="https://3840167291-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>

### **Configuration de l’attaque par force brute**

1. Envoyez la requête de cookie à **Burp Intruder** et sélectionnez la valeur du cookie comme zone d’injection.

<figure><img src="https://3840167291-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>

Dans le traitement des charges utiles :

* ajoutez une transformation générant un hachage **MD5**;

<figure><img src="https://3840167291-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>

* ajoutez un préfixe : `carlos:`

<figure><img src="https://3840167291-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>

* encodez le tout en **Base64**.

<figure><img src="https://3840167291-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. Chargez la liste de mots de passe dans les paramètres des charges utiles.

<figure><img src="https://3840167291-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>

Pendant l’attaque, une réponse **200** indique le bon cookie pour Carlos.

<figure><img src="https://3840167291-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>

Le cookie obtenu est :

```bash
Y2FybG9zOjdkOGJjNWYxYThkMzc4N2QwNmVmMTFjOTdkNDY1NWRm
```

Décodage

{% code overflow="wrap" %}

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

{% endcode %}

* carlos:7d8bc5f1a8d3787d06ef11c97d4655df

En vérifiant ce hachage sur CrackStation, nous constatons que le mot de passe associé est **taylor**.

<figure><img src="https://3840167291-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/fr/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.
