├── JWT.png ├── README.md ├── Script.py ├── install.sh └── requirements.txt /JWT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HIJACKED1/JWT-Token/baa52f38fcda9266e2beb015a80620ba651d9f9b/JWT.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JWT-Token : V1 2 | --- 3 |

4 | center 5 |

6 | "JWT-Token" emerges as a powerful tool designed to address this necessity, allowing you to generate JSON Web Tokens (JWT) with ease and confidence. Whether you are a developer striving to protect sensitive information during data transmission or an organization seeking to bolster your cybersecurity, JWT-Token provides a user-friendly solution that empowers you to create and manage JWTs effortlessly. In this era of data breaches and cyber threats, "JWT-Token" stands as a reliable guardian of your information, ensuring the integrity and confidentiality of your digital communications. 7 | 8 | --- 9 | 10 | ## 📌 Installation : 11 | 12 | ```sh 13 | git clone https://github.com/0xPwn1/JWT-Token 14 | cd JWT-Token 15 | # Before Run 'install.sh' You Should be upldate Python3 and Pip 16 | chmod +x install.sh && ./install.sh 17 | ``` 18 | 19 | ## 📌 Usage : 20 | 21 | #### > Encode : 22 | ```sh 23 | 0xPwn1@Arch~$ jwt-token 24 | ___ ________ ______ __ 25 | / / | / /_ __/ /_ __/___ / /_____ ____ 26 | __ / /| | /| / / / / / / / __ \/ //_/ _ \/ __ \ 27 | / /_/ / | |/ |/ / / / / / / /_/ / ,< / __/ / / / 28 | \____/ |__/|__/ /_/ /_/ \____/_/|_|\___/_/ /_/ 29 | 30 | Drink Coffe, Enjoy Generate JWT-Token By 0xPwn1 / v1.2 31 | 32 | 33 | [~] Choose (Encode \ Decode): Encode 34 | ---------- Header ----------- 35 | > Enter Value alg: HS256 36 | > Enter Value type: JWT 37 | 38 | ---------- Payload ----------- 39 | > Generating Payload / or / Default Payload: generate 40 | [!] - Wanted: Order is Very Imported !!! 41 | 42 | [~] Example Syntaxt => key:value (Enter To Stop): sub:1234567890 43 | [~] Example Syntaxt => key:value (Enter To Stop): username:0xPwn1 44 | [~] Example Syntaxt => key:value (Enter To Stop): admin:true 45 | [~] Example Syntaxt => key:value (Enter To Stop): 46 | 47 | ---------- Signature ----------- 48 | > Enter Your Secret Key (Enter To Skip): Hello World 49 | 50 | [$] Your Token is: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiIweFB3bjEiLCJhZG1pbiI6InRydWUifQ.UxCr1XdQP6UHxF_xGHNn-xoOKl1YltWigfCEHCWC6fU 51 | ``` 52 | --- 53 | #### > Decode : 54 | ```sh 55 | 0xPwn1@Arch~$ jwt-token 56 | ___ ________ ______ __ 57 | / / | / /_ __/ /_ __/___ / /_____ ____ 58 | __ / /| | /| / / / / / / / __ \/ //_/ _ \/ __ \ 59 | / /_/ / | |/ |/ / / / / / / /_/ / ,< / __/ / / / 60 | \____/ |__/|__/ /_/ /_/ \____/_/|_|\___/_/ /_/ 61 | 62 | Drink Coffe, Enjoy Generate JWT-Token By 0xPwn1 / v1.2 63 | 64 | 65 | [~] Choose (Encode \ Decode): Decode 66 | [~] Enter Your JWT Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiIweFB3bjEiLCJhZG1pbiI6InRydWUifQ.UxCr1XdQP6UHxF_xGHNn-xoOKl1YltWigfCEHCWC6fU 67 | 68 | ---------- Decode JWT Token ----------- 69 | [+] Your Header is: {"alg":"HS256","typ":"JWT"} 70 | [+] Your Payload is: {"sub":"1234567890","username":"0xPwn1","admin":"true"} 71 | [+] Your Signature is: UxCr1XdQP6UHxF_xGHNn-xoOKl1YltWigfCEHCWC6fU 72 | ``` 73 | 74 | ## 📜 Credits : 75 | 76 | [![LinkedIn Badge](https://camo.githubusercontent.com/a80d00f23720d0bc9f55481cfcd77ab79e141606829cf16ec43f8cacc7741e46/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c696e6b6564496e2d3030373742353f7374796c653d666f722d7468652d6261646765266c6f676f3d6c696e6b6564696e266c6f676f436f6c6f723d7768697465)](https://www.linkedin.com/in/elmehdi-chbani/) 77 | 78 | -------------------------------------------------------------------------------- /Script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from colorit import * 3 | init_colorit() 4 | import json 5 | import hmac 6 | import base64 7 | import hashlib 8 | from prompt_toolkit import prompt 9 | from prompt_toolkit.completion import WordCompleter 10 | 11 | PURPLE = 145,31,186 12 | DEEPPINK=255,20,147 13 | CYAN=0,247,255 14 | WHITE=255, 255, 255 15 | RED=255, 0,0 16 | GREEN=0, 255, 0 17 | 18 | lists = ["HS256", "HS512", "HS384"] 19 | code = ["Encode","Decode"] 20 | generating = ["default","generate"] 21 | admin_value = ["true", "false", ""] 22 | 23 | completer = WordCompleter(code, ignore_case=True) 24 | completer2 = WordCompleter(lists, ignore_case=True) 25 | completer3 = WordCompleter(admin_value, ignore_case=True) 26 | completer4 = WordCompleter(generating, ignore_case=True) 27 | 28 | 29 | print(color(""" 30 | 31 | ___ ________ ______ __ 32 | / / | / /_ __/ /_ __/___ / /_____ ____ 33 | __ / /| | /| / / / / / / / __ \/ //_/ _ \/ __ \\ 34 | / /_/ / | |/ |/ / / / / / / /_/ / ,< / __/ / / / 35 | \____/ |__/|__/ /_/ /_/ \____/_/|_|\___/_/ /_/ 36 | 37 | Drink Coffe, Enjoy Generate JWT-Token By 0xPwn1 / v1.2 38 | 39 | """,(PURPLE))) 40 | 41 | x = prompt("[~] Choose (Encode \ Decode): ",completer=completer).lower() 42 | 43 | def header(): 44 | global alg 45 | global jwt_type 46 | 47 | alg = prompt(" > Enter Value alg: ",completer=completer2).upper() 48 | 49 | while not alg in lists: 50 | print(color(" => Only Alowed Functions Are:\n{}".format(" - ".join(lists)),(RED))) 51 | alg = prompt(" > Enter Value alg: ",completer=completer2).upper() 52 | 53 | jwt_type = input(" > Enter Value type: ") 54 | 55 | 56 | def payload_Default(): 57 | global admin, sub, name, iat 58 | sub = "" 59 | while type(sub) != int : 60 | try : 61 | sub = int(input(" > Enter Value sub: ")) 62 | except: 63 | print(color(" => Only Number !!!!!",(RED))) 64 | name = "" 65 | while name == "": 66 | name = input(" > Enter Value name: ") 67 | admin = prompt(" > User is admin [true/false] (For Skip Click 'Enter'): ",completer=completer3).lower() 68 | while not admin in admin_value: 69 | print(color(" => Only Alowed Functions Are:\n{} - (Enter To Skip)".format(" - ".join(admin_value[:-1])),(RED))) 70 | admin = prompt(" > User is admin [true/false] (For Skip Click 'Enter'): ",completer=completer3).lower() 71 | 72 | def playload_Generating(): 73 | custom_payload = {} 74 | stop = 0 75 | while not stop: 76 | try: 77 | keyvalue = input("[~] Example Syntaxt => key:value (Enter To Stop): ") 78 | if keyvalue == '': 79 | break 80 | key, value = keyvalue.split(':') 81 | custom_payload[key] = value 82 | except: 83 | print(color("Error: Syntaxt => key:value",(RED))) 84 | return custom_payload 85 | 86 | def signature(): 87 | global secret 88 | secret = input(" > Enter Your Secret Key (Enter To Skip): ") 89 | 90 | 91 | def encode_header(): 92 | header1 = '{{"alg":"{}","typ":"{}"}}'.format(alg, jwt_type) 93 | en_header = base64.b64encode(header1.encode()).decode() 94 | return en_header 95 | 96 | 97 | def encode_payload(admin): 98 | if admin in ('true', 'false'): 99 | payload1 = '{{"sub":"{}","name":"{}","admin":"{}"}}'.format(sub, name, admin) 100 | else: 101 | payload1 = '{{"sub":"{}","name":"{}"}}'.format(sub, name) 102 | en_payload = base64.b64encode(payload1.encode()).decode() 103 | return en_payload.replace("=", "") 104 | 105 | 106 | def encode_payload_generation(payload): 107 | payload1 = json.dumps(payload, separators=(",", ":")) 108 | en_payload = base64.b64encode(payload1.encode()).decode() 109 | return en_payload.replace("=", "") 110 | 111 | 112 | def HMACSHA_encode(alg, en_header, en_payload, secret): 113 | algos = {"HS256": hashlib.sha256, "HS512": hashlib.sha512, "HS384": hashlib.sha384} 114 | # Encode header and payload as bytes 115 | header_bytes = en_header.encode() 116 | payload_bytes = en_payload.encode() 117 | 118 | # Calculate the HMAC-SHA256 signature 119 | signature = hmac.new(secret.encode(), header_bytes + b'.' + payload_bytes, algos[alg]) 120 | 121 | # Get the digest and encode as base64 122 | signature_base64 = base64.urlsafe_b64encode(signature.digest()).decode() 123 | 124 | return signature_base64.replace("=", "") 125 | 126 | 127 | if x == 'encode': 128 | print(color("---------- Header -----------",(PURPLE))) 129 | header() 130 | encoded_header = encode_header() 131 | print("") 132 | print(color("---------- Payload -----------",(PURPLE))) 133 | payload = prompt(" > Generating Payload / or / Default Payload: ", completer=completer4) 134 | print(color(" [!] - Wanted: Order is Very Imported !!!",(RED))) 135 | print("") 136 | 137 | if payload == "default": 138 | print(color(""" 139 | { 140 | "sub": "1234567890", 141 | "name": "John Doe", 142 | "admin": "true" 143 | } 144 | """,(GREEN))) 145 | payload_Default() 146 | encoded_payload = encode_payload(admin) 147 | 148 | elif payload == "generate": 149 | encoded_payload = encode_payload_generation(playload_Generating()) 150 | print("") 151 | print(color("---------- Signature -----------",(PURPLE))) 152 | 153 | signature() 154 | result = HMACSHA_encode(alg, encoded_header, encoded_payload, secret) 155 | print("") 156 | print(color("[$] Your Token is: ",(RED))+encoded_header + "." + encoded_payload + "." + result) 157 | 158 | elif x == 'decode': 159 | jwt_token = input("[~] Enter Your JWT Token: ") 160 | print("") 161 | 162 | secret = None 163 | if len(jwt_token.split('.')) == 3: 164 | header2, payload2, secret = jwt_token.split('.') 165 | else: 166 | header2, payload2 = jwt_token.split('.') 167 | 168 | 169 | # Add padding if it's missing from the payload 170 | while len(payload2) % 4 != 0: 171 | payload2 += '=' 172 | 173 | # Decode the header and payload from base64 174 | header2_bytes = base64.b64decode(header2.encode()) 175 | payload2_bytes = base64.b64decode(payload2.encode()) 176 | 177 | # Decode the bytes to UTF-8 strings 178 | header2_decoded = header2_bytes.decode('utf-8') 179 | payload2_decoded = payload2_bytes.decode('utf-8') 180 | 181 | print(color("---------- Decode JWT Token -----------",(PURPLE))) 182 | print(color("[+] Your Header is: ",(PURPLE))+header2_decoded) 183 | print(color("[+] Your Payload is: ",(PURPLE))+payload2_decoded) 184 | if secret: 185 | print(color("[+] Your Signature is: ",(PURPLE))+secret) 186 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip3 install -r requirements.txt 4 | sudo mv Script.py /usr/local/bin/jwt-token 5 | sudo chmod +x /usr/local/bin/jwt-token 6 | sudo rm -rf ../JWT-Token && cd .. 7 | 8 | echo "JWT-Token is Installed !!!" 9 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | color-it==2.1.3 --------------------------------------------------------------------------------