From 93d31d5c2c679575b58dea6ad0c64a08e3fa762e Mon Sep 17 00:00:00 2001 From: Jirawat I Date: Wed, 1 Dec 2021 16:28:38 +0700 Subject: [PATCH] Improve JWT RegExp #211 - add new RegExp for JWT that check header and payload length and prefix `eyJ` and `e` - add valid/invalid examples - This idea comes from observing that the minimum length of each parts of JWT is 20, 3, 43, respectively ``` Header {"alg":"HS256"} Payload {} ``` - --- pywhat/Data/regex.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pywhat/Data/regex.json b/pywhat/Data/regex.json index b8ff4f1..a88cec7 100644 --- a/pywhat/Data/regex.json +++ b/pywhat/Data/regex.json @@ -2376,7 +2376,7 @@ }, { "Name": "JSON Web Token (JWT)", - "Regex": "(?i)^((?=.*[a-z])(?=.*[0-9])(?:[a-z0-9_=]+\\.){2}(?:[a-z0-9_\\-\\+\\/=]*))$", + "Regex": "(?i)^((?=eyJ)(?:[a-z0-9_=\\-]{17,})\\.(?=e)(?:[a-z0-9_=\\-]{2,})\\.(?:[a-z0-9_=\\-]{43,}))$", "plural_name": false, "Description": null, "Rarity": 0.2, @@ -2389,9 +2389,16 @@ ], "Examples": { "Valid": [ - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", + "eyJhbGciOiJIUzI1NiJ9.e30.4E_Bsx-pJi3kOW9wVXN8CgbATwP09D9V5gxh9-9zSZ0", + "eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiIxMjM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