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

# Перебор постоянного сессионного cookie

### Подбор cookie «Оставаться в системе»

Это лабораторное задание позволяет пользователям оставаться подключёнными даже после закрытия браузера. Cookie, используемая для этой функции, уязвима к перебору. / Чтобы решить лабораторную работу, вам нужно подобрать cookie Карлоса, чтобы получить доступ к его странице «Мой аккаунт».

**Предоставленные учетные данные:** `wiener:peter`/ \*\* Имя жертвы:\*\* `carlos`

### \*\*Анализ механизма

При выборе опции автоматического повторного входа отправляется следующий запрос:

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

<figure><img src="/files/39241cf4bfd42975c03567958d0ffc2c6e318cea" alt=""><figcaption></figcaption></figure>

Затем сервер возвращает cookie с именем **stay-logged-in**, содержимое которого закодировано в Base64:

```bash
d2llbmVyOjUxZGMzMGRkYzQ3M2Q0M2E2MDExZTllYmJhNmNhNzcw
```

<figure><img src="/files/6e9a9c8ffae45d9e4ad0ab51c8162be2f1a1e488" alt=""><figcaption></figcaption></figure>

После декодирования получаем:

```bash
wiener:51dc30ddc473d43a6011e9ebba6ca770
```

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

Таким образом, структура cookie такова:

Проверив хеш через CrackStation, мы обнаруживаем, что он соответствует значению **peter** в MD5.

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

### **Настройка перебора**

1. Отправьте запрос с cookie в **Burp Intruder** и выберите значение cookie в качестве области внедрения.

<figure><img src="/files/066a889f5ba1470efecc024058d69f70e273c3da" alt=""><figcaption></figcaption></figure>

В разделе обработки полезной нагрузки:

* добавьте преобразование, генерирующее хеш **MD5**;

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

* добавьте префикс: `carlos:`

<figure><img src="/files/4236c65c0938ca16a181204a9daa9c81eaaf5eac" alt=""><figcaption></figcaption></figure>

* закодируйте все в **Base64**.

<figure><img src="/files/390d4a0375360cf8d86206ddef0724822b0a5267" alt=""><figcaption></figcaption></figure>

1. Загрузите список паролей в настройках полезной нагрузки.

<figure><img src="/files/148a9ea72510b21d58605a91195fd22fffefe282" alt=""><figcaption></figcaption></figure>

Во время атаки ответ **200** указывает на правильную cookie для Карлоса.

<figure><img src="/files/8ed3c6b599f7bbf389a1f35ffa06965433ad3fd9" alt=""><figcaption></figcaption></figure>

Полученная cookie:

```bash
Y2FybG9zOjdkOGJjNWYxYThkMzc4N2QwNmVmMTFjOTdkNDY1NWRm
```

Декодирование

{% code overflow="wrap" %}

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

{% endcode %}

* carlos:7d8bc5f1a8d3787d06ef11c97d4655df

Проверив этот хеш на CrackStation, мы обнаруживаем, что связанный пароль — **taylor**.

<figure><img src="/files/214d50ac701bd5c90ec8240d24bcfc34cce72a5e" 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/ru/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.
