Saltar al contenido
HackIndex logo

HackIndex

Herramientas

Laravel Cookie Forge & Decodificador

Decodifica cookies cifradas AES de Laravel o forja firmadas — para retos CTF y pruebas autorizadas.

Laravel cifra todas las cookies con AES-256-CBC (o AES-256-GCM en Laravel 10+) usando la APP_KEY de tu archivo .env. El valor cifrado es JSON codificado en base64 que contiene un IV, el texto cifrado y una firma HMAC-SHA256. Esta herramienta descifra la cookie para revelar el payload de sesión — ID de usuario, rol, token CSRF — verifica la firma HMAC y te permite forjar una nueva cookie firmada válida. Todo el procesamiento ocurre del lado del servidor en PHP. Nada se almacena ni se registra.

Decodificar Cookie

Descifrar y verificar una cookie existente

Acepta: base64:xxx (estándar), cadena hex o base64 en crudo. Se encuentra en el .env objetivo como APP_KEY.

Forjar Cookie

Generar una cookie de Laravel firmada válida

AES-256-CBC es el predeterminado para Laravel 9 e inferior. AES-256-GCM para Laravel 10+.

Consejo: decodifica primero una cookie real para ver el formato serializado exacto, luego modifica y forja.

Cómo funciona

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.

¿Qué son las cookies cifradas de 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+).

Preguntas frecuentes

¿Envía mi cookie o APP_KEY a algún lugar?

No. El descifrado y cifrado ocurren del lado del servidor en PHP usando openssl_decrypt / openssl_encrypt. No se almacena, registra ni transmite ningún dato a terceros.

¿Qué es el driver de sesión 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.

¿Cómo funciona la firma 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.

¿Qué cifrado debo elegir al forjar?

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).

El descifrado falla incluso con la APP_KEY correcta — ¿por qué?

Verifica que estás pegando el valor en crudo y no una versión codificada en URL. Algunos frameworks codifican las cookies dos veces. También verifica el formato de la clave: Laravel lo almacena como base64:xxx en .env — pégalo exactamente como aparece allí.