(headDict, paylDict, sig)
| 1293 | return headDict, paylDict, sig, contents |
| 1294 | |
| 1295 | def rejigToken(headDict, paylDict, sig): |
| 1296 | cprintc("=====================\nDecoded Token Values:\n=====================", "white") |
| 1297 | cprintc("\nToken header values:", "white") |
| 1298 | for claim in headDict: |
| 1299 | if isinstance(headDict[claim], dict): |
| 1300 | cprintc("[+] "+claim+" = JSON object:", "green") |
| 1301 | for subclaim in headDict[claim]: |
| 1302 | if headDict[claim][subclaim] == None: |
| 1303 | cprintc(" [+] "+subclaim+" = null", "green") |
| 1304 | elif headDict[claim][subclaim] == True: |
| 1305 | cprintc(" [+] "+subclaim+" = true", "green") |
| 1306 | elif headDict[claim][subclaim] == False: |
| 1307 | cprintc(" [+] "+subclaim+" = false", "green") |
| 1308 | elif type(headDict[claim][subclaim]) == str: |
| 1309 | cprintc(" [+] "+subclaim+" = \""+str(headDict[claim][subclaim])+"\"", "green") |
| 1310 | else: |
| 1311 | cprintc(" [+] "+subclaim+" = "+str(headDict[claim][subclaim]), "green") |
| 1312 | else: |
| 1313 | if type(headDict[claim]) == str: |
| 1314 | cprintc("[+] "+claim+" = \""+str(headDict[claim])+"\"", "green") |
| 1315 | else: |
| 1316 | cprintc("[+] "+claim+" = "+str(headDict[claim]), "green") |
| 1317 | cprintc("\nToken payload values:", "white") |
| 1318 | comparestamps, expiredtoken = dissectPayl(paylDict) |
| 1319 | if len(comparestamps) >= 2: |
| 1320 | cprintc("\nSeen timestamps:", "white") |
| 1321 | cprintc("[*] "+comparestamps[0]+" was seen", "green") |
| 1322 | claimnum = 0 |
| 1323 | for claim in comparestamps: |
| 1324 | timeoff = int(paylDict[comparestamps[claimnum]])-int(paylDict[comparestamps[0]]) |
| 1325 | if timeoff != 0: |
| 1326 | timecalc = timeoff |
| 1327 | if timecalc < 0: |
| 1328 | timecalc = timecalc*-1 |
| 1329 | days,hours,mins = 0,0,0 |
| 1330 | if timecalc >= 86400: |
| 1331 | days = str(timecalc/86400) |
| 1332 | days = int(float(days)) |
| 1333 | timecalc -= days*86400 |
| 1334 | if timecalc >= 3600: |
| 1335 | hours = str(timecalc/3600) |
| 1336 | hours = int(float(hours)) |
| 1337 | timecalc -= hours*3600 |
| 1338 | if timecalc >= 60: |
| 1339 | mins = str(timecalc/60) |
| 1340 | mins = int(float(mins)) |
| 1341 | timecalc -= mins*60 |
| 1342 | if timeoff < 0: |
| 1343 | timeoff = timeoff*-1 |
| 1344 | prepost = "[*] "+claim+" is earlier than "+comparestamps[0]+" by: " |
| 1345 | cprintc(prepost+str(days)+" days, "+str(hours)+" hours, "+str(mins)+" mins", "green") |
| 1346 | else: |
| 1347 | prepost = "[*] "+claim+" is later than "+comparestamps[0]+" by: " |
| 1348 | cprintc(prepost+str(days)+" days, "+str(hours)+" hours, "+str(mins)+" mins", "green") |
| 1349 | claimnum += 1 |
| 1350 | if expiredtoken: |
| 1351 | cprintc("[-] TOKEN IS EXPIRED!", "red") |
| 1352 | cprintc("\n----------------------\nJWT common timestamps:\niat = IssuedAt\nexp = Expires\nnbf = NotBefore\n----------------------\n", "white") |
no test coverage detected