Zurück zum Ranking

hahwul/jwt-hack

Rustjwt-hack.hahwul.com

JSON Web Token Hack Toolkit

jwthackingbugbountysecuritytooltesting-toolscrackingpayload-generatorhacktoberfest
Sterne-Wachstum
Sterne
1k
Forks
121
Wochenwachstum
Issues
0
1k1k1k
18. Juli19. Juli20. Juli20. Juli
Artefaktecrates.iocargo add jwt-hack
README
jwt-hack

JSON Web Token Hack Toolkit


A high-performance toolkit for testing, analyzing and attacking JSON Web Tokens.

Installation

Cargo

cargo install jwt-hack

Homebrew

brew install jwt-hack

Snapcraft (Ubuntu)

sudo snap install jwt-hack

From source

git clone https://github.com/hahwul/jwt-hack
cd jwt-hack
cargo install --path .

Docker images

GHCR

docker pull ghcr.io/hahwul/jwt-hack:latest

Docker Hub

docker pull hahwul/jwt-hack:v2.6.0

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
Scan Vulnerability Scanner Automated security checks for common JWT vulnerabilities
Server API Server Run API Server Mode (http://localhost:3000)
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.

jwt-hack decode eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0In0.CHANGED
jwt-hack decode COMPRESSED_JWT_TOKEN

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
jwt-hack decode eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..ZHVtbXlfaXZfMTIzNDU2.eyJ0ZXN0IjoiandlIn0.ZHVtbXlfdGFn

# Shows JWE header, encrypted key, IV, ciphertext, and authentication tag

Encode a JWT

jwt-hack encode '{"sub":"1234"}' --secret=your-secret

Encode a JWT with DEFLATE Compression

You can use the --compress option to apply DEFLATE compression to the JWT payload.

jwt-hack encode '{"sub":"1234"}' --secret=your-secret --compress

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)
jwt-hack verify YOUR_JWT_TOKEN_HERE --secret=your-256-bit-secret

# With Private Key (for asymmetric algorithms like RS256, ES256, EdDSA)
jwt-hack verify YOUR_JWT_TOKEN_HERE --private-key path/to/your/RS256_private.key

Crack a JWT

Dictionary and brute force attacks also support JWTs compressed with DEFLATE.

# Dictionary attack
jwt-hack crack -w wordlist.txt JWT_TOKEN
jwt-hack crack -w wordlist.txt COMPRESSED_JWT_TOKEN

# Bruteforce attack
jwt-hack crack -m brute JWT_TOKEN --max=4
jwt-hack crack -m brute COMPRESSED_JWT_TOKEN --max=4

Generate payloads

jwt-hack payload JWT_TOKEN --jwk-attack evil.com --jwk-trust trusted.com

Scan for vulnerabilities

Automatically scan JWT tokens for common security issues and vulnerabilities.

# Full scan including weak secret detection and payload generation
jwt-hack scan JWT_TOKEN

# Skip secret cracking for faster results
jwt-hack scan JWT_TOKEN --skip-crack

# Skip payload generation
jwt-hack scan JWT_TOKEN --skip-payloads

# Use custom wordlist for weak secret detection
jwt-hack scan JWT_TOKEN -w custom_wordlist.txt

# Limit secret testing attempts
jwt-hack scan JWT_TOKEN --max-crack-attempts 50

The scan command checks for:

  • None algorithm vulnerability: Detects if the token accepts unsigned tokens
  • Weak secrets: Tests against common passwords (customizable with wordlist)
  • Algorithm confusion: Identifies tokens vulnerable to RS256->HS256 attacks
  • Token expiration issues: Checks for missing or improper expiration claims
  • Missing security claims: Verifies presence of recommended JWT claims
  • Kid header injection: Detects potential SQL/path injection vulnerabilities
  • JKU/X5U header attacks: Identifies URL spoofing attack vectors

Server (REST API)

Start a local REST API for automation and integrations. To require authentication, use --api-key and include X-API-KEY in requests.

# Start on localhost:3000 with API key protection
jwt-hack server --api-key your-api-key

# Example request (must include X-API-KEY when --api-key is set)
curl -s http://127.0.0.1:3000/health -H 'X-API-KEY: your-api-key'

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)
jwt-hack mcp

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:

{
  "name": "decode",
  "arguments": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Encode Tool:

{
  "name": "encode",
  "arguments": {
    "json": "{\"sub\":\"1234\",\"name\":\"test\"}",
    "secret": "mysecret",
    "algorithm": "HS256"
  }
}

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

{
  "servers": {
    "jwt-hack": {
      "type": "stdio",
      "command": "jwt-hack",
      "args": [
        "mcp"
      ]
    }
  },
  "inputs": []
}

Claude Desktop

{
  "mcpServers": {
    "jwt-hack": {
      "command": "jwt-hack",
      "args": ["mcp"],
      "env": {}
    }
  }
}

Supported Algorithms

Signature Algorithms (JWS)

Algorithm Description Type
HS256 HMAC using SHA-256 Symmetric
HS384 HMAC using SHA-384 Symmetric
HS512 HMAC using SHA-512 Symmetric
RS256 RSASSA-PKCS1-v1_5 using SHA-256 Asymmetric
RS384 RSASSA-PKCS1-v1_5 using SHA-384 Asymmetric
RS512 RSASSA-PKCS1-v1_5 using SHA-512 Asymmetric
ES256 ECDSA using P-256 and SHA-256 Asymmetric
ES384 ECDSA using P-384 and SHA-384 Asymmetric
PS256 RSASSA-PSS using SHA-256 Asymmetric
PS384 RSASSA-PSS using SHA-384 Asymmetric
PS512 RSASSA-PSS using SHA-512 Asymmetric
EdDSA Edwards-curve Digital Signature Algorithm Asymmetric
none No digital signature -

Encryption Algorithms (JWE)

Algorithm Description
A128GCM AES-GCM using 128-bit key
A256GCM AES-GCM using 256-bit key

Key Management Algorithms (JWE)

Algorithm Description
dir Direct use of shared symmetric key

DEFLATE Compression Support

DEFLATE Compression Support The jwt-hack toolkit supports DEFLATE compression for JWTs.

  • Use the --compress option with encode to generate compressed JWTs.
  • The decode and crack modes 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.

Ähnliche Repositories
fastapi/full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.

TypeScriptnpmMIT Licensepythonjson
44.4k8.8k
nextauthjs/next-auth

Authentication for the Web.

TypeScriptnpmISC Licensenodejsnextjs
authjs.dev
28.3k4k
flipped-aurora/gin-vue-admin

🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,企业级业务AI+开发解决方案,内置mcp辅助服务,内置skills管理,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。

GoGo ModulesOthergin-vue-admingin
demo.gin-vue-admin.com
24.9k7.1k
shieldfy/API-Security-Checklist

Checklist of the most important security countermeasures when designing, testing, and releasing your API

MIT Licenseapisecurity
23.3k2.7k
elunez/eladmin

eladmin jpa 版本:项目基于 Spring Boot 2.7.18、 Jpa、 Spring Security、Redis、Vue的前后端分离的后台管理系统,项目采用分模块开发方式, 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前后端代码,支持动态路由

JavaMavenApache License 2.0spring-bootspring-security
eladmin.vip/demo
21.9k7.4k
logto-io/logto

🧑‍🚀 Authentication and authorization infrastructure for SaaS and AI apps, built on OIDC and OAuth 2.1 with multi-tenancy, SSO, and RBAC.

TypeScriptnpmMozilla Public License 2.0authenticationauthorization
logto.io
14.2k1k
go-admin-team/go-admin

基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd PRO:https://antd.go-admin.pro

GoGo ModulesMIT Licensegincasbin
go-admin.pro
12.7k2.6k
tymondesigns/jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen

PHPPackagistMIT Licensejwtlaravel
jwt-auth.com
11.5k1.5k
jwtk/jjwt

Java JWT: JSON Web Token for Java and Android

JavaMavenApache License 2.0jwtjava
11.1k1.4k
golang-jwt/jwt

Go implementation of JSON Web Tokens (JWT).

GoGo ModulesMIT Licensegogolang
golang-jwt.github.io/jwt/
9.2k440
teamhanko/hanko

Modern authentication, on your terms. Open source alternative to Auth0, Clerk, WorkOS, Stytch.

GoGo ModulesOtherpasskeyswebauthn
hanko.io
9k1k
panva/jose

JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes

TypeScriptnpmMIT Licensejosejwa
7.7k375