Перейти к содержимому
HackIndex logo

HackIndex

Инструменты

Laravel Cookie Forge и Декодер

Декодируйте зашифрованные AES cookie Laravel или подделывайте подписанные — для CTF и авторизованного тестирования.

Laravel шифрует все cookie с помощью AES-256-CBC (или AES-256-GCM в Laravel 10+), используя APP_KEY из файла .env. Зашифрованное значение — это base64-кодированный JSON, содержащий IV, зашифрованный текст и подпись HMAC-SHA256. Этот инструмент расшифровывает cookie для отображения полезной нагрузки сессии — ID пользователя, роль, CSRF-токен — проверяет подпись HMAC и позволяет создать новый корректный подписанный cookie. Вся обработка происходит на стороне сервера в PHP. Ничего не сохраняется и не записывается в журнал.

Декодировать Cookie

Расшифровать и проверить существующий cookie

Принимает: base64:xxx (стандарт), hex-строку или сырой base64. Находится в .env цели как APP_KEY.

Подделать Cookie

Сгенерировать допустимый подписанный cookie Laravel

AES-256-CBC — стандарт для Laravel 9 и ниже. AES-256-GCM для Laravel 10+.

Tip: decode a real cookie first to see the exact serialized format, then modify and forge.

Как это работает

Laravel encrypts cookies using AES-256-CBC (or AES-128-CBC / GCM variants) with the APP_KEY from your .env file. The encrypted value is base64-encoded JSON containing an IV, the ciphertext, and an HMAC-SHA256 signature. This tool decrypts and verifies the signature or forges a new valid cookie from scratch. Both operations happen server-side in PHP without storing any input.

  1. 1. Get the cookie: intercept the target request in Burp Suite or browser DevTools and copy the laravel_session cookie value.
  2. 2. Get the APP_KEY: find it in the target .env, a leaked config, or crack it from known plaintext.
  3. 3. Decode: paste both above and decode to reveal the session payload (user ID, CSRF token, flash data).
  4. 4. Modify & forge: change the payload (e.g. elevate user_id), paste the APP_KEY and forge a new valid signed cookie.
  5. 5. Inject: replace the original cookie in your request and resend.

Что такое зашифрованные cookie Laravel?

Laravel automatically encrypts and signs all cookies set via Cookie::make() or the cookie helper (unless excluded via $except in EncryptCookies middleware). The session cookie (laravel_session by default) uses the cookie session driver only when SESSION_DRIVER=cookie, otherwise it contains just an encrypted session ID pointer. In CTF challenges, apps frequently use the cookie driver to store the full session payload directly in the cookie.

iv

Initialisation Vector. Randomly generated for each encryption operation. Base64-encoded inside the JSON payload.

value

The AES-encrypted ciphertext. Base64-encoded. openssl_encrypt() with flags=0 (default) returns base64 directly.

mac

HMAC-SHA256 of base64(iv) concatenated with base64(value), keyed with the raw APP_KEY bytes. Absent for GCM ciphers.

tag

GCM authentication tag. Used instead of HMAC for AES-256-GCM and AES-128-GCM ciphers (Laravel 10+).

FAQ

Отправляет ли это мой cookie или APP_KEY куда-либо?

Нет. Расшифровка и шифрование происходят на стороне сервера в PHP с использованием openssl_decrypt / openssl_encrypt. Данные не хранятся, не записываются в журнал и не передаются третьим лицам.

Что такое драйвер сессий cookie?

When SESSION_DRIVER=cookie is set in .env, Laravel serializes the entire session array, encrypts it, and stores it directly in the browser cookie. This is common in CTF challenge setups. Most production apps use file, database, or Redis drivers where only an encrypted session ID is stored in the cookie.

Как работает подпись HMAC?

Laravel computes hash_hmac("sha256", base64(iv) . base64(ciphertext), raw_key). Both the IV and ciphertext strings used in the MAC computation are the base64-encoded versions stored in the JSON, not the raw bytes.

Какой шифр выбрать при подделке?

Match the cipher to the one used by the target app. Laravel 5-9 default is AES-256-CBC. Laravel 10+ supports AES-256-GCM. You can detect it from the presence of the tag field in the decoded cookie structure (GCM has a non-empty tag field; CBC has mac instead).

Расшифровка не удаётся даже с правильным APP_KEY — почему?

Убедитесь, что вставляете сырое значение cookie, а не URL-кодированную версию. Некоторые фреймворки двойно кодируют cookie. Также проверьте формат ключа: Laravel хранит его как base64:xxx в .env — вставляйте именно так, как он там отображается.