(paylDict, count=False)
| 1197 | return newContents.encode().decode('UTF-8') |
| 1198 | |
| 1199 | def dissectPayl(paylDict, count=False): |
| 1200 | timeseen = 0 |
| 1201 | comparestamps = [] |
| 1202 | countval = 0 |
| 1203 | expiredtoken = False |
| 1204 | nowtime = int(datetime.now().timestamp()) |
| 1205 | for claim in paylDict: |
| 1206 | countval += 1 |
| 1207 | if count: |
| 1208 | placeholder = str(countval) |
| 1209 | else: |
| 1210 | placeholder = "+" |
| 1211 | if claim in ["exp", "nbf", "iat"]: |
| 1212 | timestamp = datetime.fromtimestamp(int(paylDict[claim])) |
| 1213 | if claim == "exp": |
| 1214 | if int(timestamp.timestamp()) < nowtime: |
| 1215 | expiredtoken = True |
| 1216 | cprintc("["+placeholder+"] "+claim+" = "+str(paylDict[claim])+" ==> TIMESTAMP = "+timestamp.strftime('%Y-%m-%d %H:%M:%S')+" (UTC)", "green") |
| 1217 | timeseen += 1 |
| 1218 | comparestamps.append(claim) |
| 1219 | elif isinstance(paylDict[claim], dict): |
| 1220 | cprintc("["+placeholder+"] "+claim+" = JSON object:", "green") |
| 1221 | for subclaim in paylDict[claim]: |
| 1222 | if type(castInput(paylDict[claim][subclaim])) == str: |
| 1223 | cprintc(" [+] "+subclaim+" = \""+str(paylDict[claim][subclaim])+"\"", "green") |
| 1224 | elif paylDict[claim][subclaim] == None: |
| 1225 | cprintc(" [+] "+subclaim+" = null", "green") |
| 1226 | elif paylDict[claim][subclaim] == True and not paylDict[claim][subclaim] == 1: |
| 1227 | cprintc(" [+] "+subclaim+" = true", "green") |
| 1228 | elif paylDict[claim][subclaim] == False and not paylDict[claim][subclaim] == 0: |
| 1229 | cprintc(" [+] "+subclaim+" = false", "green") |
| 1230 | else: |
| 1231 | cprintc(" [+] "+subclaim+" = "+str(paylDict[claim][subclaim]), "green") |
| 1232 | else: |
| 1233 | if type(paylDict[claim]) == str: |
| 1234 | cprintc("["+placeholder+"] "+claim+" = \""+str(paylDict[claim])+"\"", "green") |
| 1235 | else: |
| 1236 | cprintc("["+placeholder+"] "+claim+" = "+str(paylDict[claim]), "green") |
| 1237 | return comparestamps, expiredtoken |
| 1238 | |
| 1239 | def validateToken(jwt): |
| 1240 | try: |
no test coverage detected