-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjwt-token.py
More file actions
72 lines (49 loc) · 1.77 KB
/
jwt-token.py
File metadata and controls
72 lines (49 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'''
Script para Gerar um Token JWT a partir de uma lista de Key IDs.
'''
import jwt
import os
import random
import sys
import time
os.system('clear')
if len(sys.argv) != 3:
os.system('clear')
print(f'''
---------
- HELP! -
---------
Usage: python3 {sys.argv[0]} CHAVE-MD5 SECRET-MD5
Github: https://github.com/MarcosRCarvalhoAzion/JWT
''')
sys.exit(0)
kids_and_secrets = { f'{sys.argv[1]}' : f'{sys.argv[2]}' }
# get a random kid with secret
selected_kid, selected_secret = random.choice(list(kids_and_secrets.items()))
current_time = int(time.time())
_10_minutes_in_seconds = 10 * 60
expiration = current_time + _10_minutes_in_seconds
payload = {'exp': expiration, 'iat': current_time, 'my_data_1': 'x', 'my_data_2': 'y'}
headers = {'kid': selected_kid}
generated_jwt = jwt.encode(payload, selected_secret, algorithm='HS256', headers=headers)
authorization_token = f'Bearer {generated_jwt}'
msg = f'''
--------------------------
- AZION MOVE TO THE EDGE -
--------------------------
[+] [JWT] Gerado com sucesso!
[!] CHAVE selecionada para gerar o JWT: {selected_kid}
[!] SECRET selecionado para gerar o JWT: {selected_secret}
-------------------------------------------------------------
Adicione o Header abaixo na Request:
---------------------------
Header Name: Authorization
---------------------------
---------------------------
Header Value: {authorization_token}
---------------------------
'''
# Salva o resultado num arquivo de texto: information.txt
with open('information.txt', 'w', encoding='utf-8') as _file:
_file.write(msg)
print(msg)