A high-performance toolkit for testing, analyzing and attacking JSON Web Tokens.
Installation
Cargo
Homebrew
Snapcraft (Ubuntu)
From source
Docker images
GHCR
Docker Hub
Features
| Mode | Description | Support |
|---|---|---|
| Encode | JWT/JWE Encoder | Secret based / Key based / Algorithm / Custom Header / DEFLATE Compression / JWE |
| Decode | JWT/JWE Decoder | Algorithm, Issued At Check, DEFLATE Compression, JWE Structure |
| Verify | JWT Verifier | Secret based / Key based (for asymmetric algorithms) |
| Crack | Secret Cracker | Dictionary Attack / Brute Force / DEFLATE Compression |
| Payload | JWT Attack Payload Generator | none / jku&x5u / alg_confusion / kid_sql / x5c / cty |
| MCP | Model Context Protocol Server | AI model integration via standardized protocol |
Basic Usage
Decode a JWT
You can decode both regular and DEFLATE-compressed JWTs. The tool will automatically detect and decompress compressed tokens.
Decode a JWE
Decode JWE (JSON Web Encryption) tokens to analyze their structure. The tool automatically detects JWE format (5 parts) and displays the encryption details.
# Decode JWE token structure
# Shows JWE header, encrypted key, IV, ciphertext, and authentication tag
Encode a JWT
Encode a JWT with DEFLATE Compression
You can use the --compress option to apply DEFLATE compression to the JWT payload.
With Private Key
ssh-keygen -t rsa -b 4096 -E SHA256 -m PEM -P "" -f RS256.key jwt-hack encode '{"a":"z"}' --private-key RS256.key --algorithm=RS256
### Encode a JWE
Create JWE (JSON Web Encryption) tokens for testing encrypted JWT scenarios.
```bash
# Basic JWE encoding
jwt-hack encode '{"sub":"1234", "data":"encrypted"}' --jwe --secret=your-secret
# JWE tokens are encrypted and can only be decrypted with the proper key
jwt-hack encode '{"sensitive":"data"}' --jwe
Verify a JWT
Checks if a JWT's signature is valid using the provided secret or key.
# With Secret (HMAC algorithms like HS256, HS384, HS512)
# With Private Key (for asymmetric algorithms like RS256, ES256, EdDSA)
Crack a JWT
Dictionary and brute force attacks also support JWTs compressed with DEFLATE.
# Dictionary attack
# Bruteforce attack
Generate payloads
MCP (Model Context Protocol) Server Mode
jwt-hack can run as an MCP server, allowing AI models to interact with JWT functionality through a standardized protocol.
# Start MCP server (communicates via stdio)
The MCP server exposes the following tools:
| Tool | Description | Parameters |
|---|---|---|
decode |
Decode JWT tokens | token (string) |
encode |
Encode JSON to JWT | json (string), secret (optional), algorithm (default: HS256), no_signature (boolean) |
verify |
Verify JWT signatures | token (string), secret (optional), validate_exp (boolean) |
crack |
Crack JWT tokens | token (string), mode (dict/brute), chars (string), max (number) |
payload |
Generate attack payloads | token (string), target (string), jwk_attack (optional), jwk_protocol (default: https) |
Example MCP Usage
The MCP server is designed to be used by AI models and MCP clients. Each tool accepts JSON parameters and returns structured responses.
Decode Tool:
Encode Tool:
MCP Client Integration Examples
You can connect jwt-hack’s MCP server to popular MCP-enabled clients. Make sure the jwt-hack binary is on your system and accessible by the client.
VSCode
Claude Desktop
DEFLATE Compression Support
DEFLATE Compression Support The
jwt-hacktoolkit supports DEFLATE compression for JWTs.
- Use the
--compressoption withencodeto generate compressed JWTs.- The
decodeandcrackmodes automatically detect and handle compressed JWTs.
Contribute
Urx is open-source project and made it with ❤️ if you want contribute this project, please see CONTRIBUTING.md and Pull-Request with cool your contents.