JWT Tool : A Toolkit For Testing, Tweaking & Cracking JSON Web Tokens

JWT Tool(jwt_tool.py) is a toolkit for validating, forging and cracking JWTs (JSON Web Tokens). Its functionality includes:

  • Checking the validity of a token
  • Testing for the RS/HS256 public key mismatch vulnerability
  • Testing for the alg=None signature-bypass vulnerability
  • Testing the validity of a secret/key/key file
  • Identifying weak keys via a High-speed Dictionary Attack
  • Forging new token header and payload values and creating a new signature with the key or via another attack method

Audience

This tool is written for pentesters, who need to check the strength of the tokens in use, and their susceptibility to known attacks.

It may also be useful for developers who are using JWTs in projects, but would like to test for stability and for known vulnerabilities, when using forged tokens.

Also Read – Ph0neutria : Malware Zoo Builder That Sources Samples Straight From The Wild

Requirements

This tool is written natively in Python 2.x using the common libraries. Customised wordlists are recommended for the Dictionary Attack option.

As a speed reference, an Intel i5 laptop can test ~1,000,000 passwords per second on HMAC-SHA256 signing. YMMV.

Installation

Installation is just a case of downloading the jwt_tool.py file (or git cloneing the repo). (chmod the file too if you want to add it to your $PATH and call it from anywhere.)

Usage

$ python jwt_tool.py (filename)

The first argument should be the JWT itself, followed by a filename/filepath (for cracking the token, or for use as a key file).

For example:

$ python jwt_tool.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpbiI6InRpY2FycGkifQ.aqNCvShlNT9jBFTPBpHDbt2gBB1MyHiisSDdp8SQvgw /usr/share/wordlists/rockyou.txt

The toolkit will validate the token and list the header and payload values.
It will then provide a menu of your available options.

Note: signing the token is currently supported using HS256, HS384, HS512 algorithms

Input is in either standard or url-safe JWT format, and the resulting tokens are output in both formats for your ease of use.

Further Reading

Tips

Regex for finding JWTs in Burp Search
(make sure ‘Case sensitive’ and ‘Regex’ options are ticked)

  • [= ]ey[A-Za-z0-9_-]*\.[A-Za-z0-9._-]* – url-safe JWT version
  • [= ]ey[A-Za-z0-9_\/+-]*\.[A-Za-z0-9._\/+-]* – all JWT versions (higher possibility of false positives)
R K

Recent Posts

Kali Linux 2024.4 Released, What’s New?

Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…

2 days ago

Lifetime-Amsi-EtwPatch : Disabling PowerShell’s AMSI And ETW Protections

This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…

2 days ago

GPOHunter – Active Directory Group Policy Security Analyzer

GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…

4 days ago

2024 MITRE ATT&CK Evaluation Results – Cynet Became a Leader With 100% Detection & Protection

Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…

7 days ago

SecHub : Streamlining Security Across Software Development Lifecycles

The free and open-source security platform SecHub, provides a central API to test software with…

1 week ago

Hawker : The Comprehensive OSINT Toolkit For Cybersecurity Professionals

Don't worry if there are any bugs in the tool, we will try to fix…

1 week ago