
This is a JSON Web Token Challenge.
- The username and password are given in the source code for
index.php
- username: admin
- password: admin
- We are given an application where after logging in, we need to send cookie called
magic_word that contains the correct ‘magic word.’
- The cookie must be a JSON web token signed correctly using the secret key.
Let’s take a look at the JWT we have initially using https://jwt.io


Let’s do the following:
- Insert the secret key
- Change the word to a word on the provided wordlist. (I’ll use images)
- Copy the generated JWT to serve as point of reference to ensure our automation script works correctly.

I’ll copy my reference JWT into a file called reference.txt
- Again, we are just using this to ensure our program produces a correct JWT for the word ‘images’ because we can be reasonably sure that JWT.io will create a valid JWT given the correct information.
We’ll use php this time. Install firebase/php-jwt using Composer first
composer require firebase/php-jwt
Here’s a program that will generate a JWT for the word images.
gen.php
<?php
require 'vendor/autoload.php';
use Firebase\JWT\JWT;
$secret_key = '1c0b76fce779f78f51be339c49445c49';
// Define the single word to encode
$word = 'images';
// Payload for JWT
$payload = [
"magic_word" => $word
];
// Generate JWT token
$jwt = JWT::encode($payload, $secret_key, 'HS256');
// Print JWT token
echo "Magic Word: $word\n JWT Token:\n";
echo "$jwt";
?>
Run it with: